Difference between revisions of "Template:AS7341 Spectral Color Sensor-RaspberryPi-Guides"
(Created page with "This example uses Raspberry Pi 3 Model B, provides BCM2835, WiringPi, file IO, RPI (Python) library demos. ==Hardware connection== :700px...") |
|||
Line 70: | Line 70: | ||
*【Note】The 'data' here can be changed to flicker, syns, int, pinint, clear to verify different test demos, and its meaning is explained in the code. | *【Note】The 'data' here can be changed to flicker, syns, int, pinint, clear to verify different test demos, and its meaning is explained in the code. | ||
*Take the execution of sudo ./main data as an example, the test result is: | *Take the execution of sudo ./main data as an example, the test result is: | ||
− | :[[File:AS7341_Raspberry_com_c.png| | + | :[[File:AS7341_Raspberry_com_c.png|800px]] |
==python== | ==python== | ||
<pre> | <pre> | ||
Line 80: | Line 80: | ||
*【Note】The 'data' here can be changed to flicker, syns, int, pinint, clear to verify different test demos, and its meaning is explained in the code. | *【Note】The 'data' here can be changed to flicker, syns, int, pinint, clear to verify different test demos, and its meaning is explained in the code. | ||
*Take the execution of data.py as an example, the test result is: | *Take the execution of data.py as an example, the test result is: | ||
− | :[[File:AS7341_Raspberry_com_python.png| | + | :[[File:AS7341_Raspberry_com_python.png|800px]] |
==Demo description== | ==Demo description== | ||
The functions of all test demos and the points that need attention have been introduced in the Arduino tutorial. When executing sudo ./main syns or python syns.py, you need to pull up the GPIO port and then pull it down to generate a falling edge signal. You can connect the GPIO pin to the high-level pin for a short time and then released to generate a falling edge signal. | The functions of all test demos and the points that need attention have been introduced in the Arduino tutorial. When executing sudo ./main syns or python syns.py, you need to pull up the GPIO port and then pull it down to generate a falling edge signal. You can connect the GPIO pin to the high-level pin for a short time and then released to generate a falling edge signal. |
Revision as of 12:21, 22 April 2021
This example uses Raspberry Pi 3 Model B, provides BCM2835, WiringPi, file IO, RPI (Python) library demos.
Hardware connection
AS7341 Spectral Color Sensor | Raspberry Pi (BCM) |
VCC | 3.3V/5V Power input |
GND | Ground |
SDA | SDA(2) |
SCL | SCL(3) |
INT | 4 |
GPIO | / |
Working with Raspberry Pi
Enable I2C interface
- Open terminal, use command to enter the configuration page
sudo raspi-config Choose Interfacing Options -> I2C -> Yes to enable I2C interface
And then reboot the system:
sudo reboot
Libraries Installation
- Install BCM2835 libraries
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.68.tar.gz tar zxvf bcm2835-1.68.tar.gz cd bcm2835-1.68/ sudo ./configure && sudo make && sudo make check && sudo make install
For more details, please refer to http://www.airspayce.com/mikem/bcm2835/
- Install wiringPi libraries
sudo apt-get install wiringpi #For Pi 4, you need to update it: wget https://project-downloads.drogon.net/wiringpi-latest.deb sudo dpkg -i wiringpi-latest.deb gpio -v #You will get 2.52 information if you install it correctly
Download the demo
Open the terminal of the Raspberry Pi, execute command to download demo codes:
sudo apt-get install p7zip-full wget https://www.waveshare.com/w/upload/b/b3/AS7341_Spectral_Color_Sensor_code.7z 7z x AS7341_Spectral_Color_Sensor_code.7z -r -o./AS7341_Spectral_Color_Sensor_code sudo chmod 777 -R AS7341_Spectral_Color_Sensor_code
C
cd AS7341_Spectral_Color_Sensor_code/AS7341_Spectral_Color_Sensor_code/RaspberryPi/c make clean make
Enter the following command to execute the demo:
sudo ./main data
- 【Note】The 'data' here can be changed to flicker, syns, int, pinint, clear to verify different test demos, and its meaning is explained in the code.
- Take the execution of sudo ./main data as an example, the test result is:
python
cd cd AS7341_Spectral_Color_Sensor_code/AS7341_Spectral_Color_Sensor_code/RaspberryPi/python/examples
Enter the following command to execute the demo:
sudo python data.py
- 【Note】The 'data' here can be changed to flicker, syns, int, pinint, clear to verify different test demos, and its meaning is explained in the code.
- Take the execution of data.py as an example, the test result is:
Demo description
The functions of all test demos and the points that need attention have been introduced in the Arduino tutorial. When executing sudo ./main syns or python syns.py, you need to pull up the GPIO port and then pull it down to generate a falling edge signal. You can connect the GPIO pin to the high-level pin for a short time and then released to generate a falling edge signal.