本例程使用的是Raspberry Pi 3 Model B,提供BCM2835、WiringPi、文件IO、RPI(Python)库例程
AS7341 Spectral Color Sensorr | 树莓派(BCM) |
VCC | 3.3V/5V |
GND | GND |
SDA | SDA(2) |
SCL | SCL(3) |
INT | 4 |
GPIO | - |
- sudo raspi-config
- #选择 Interfacing Options -> I2C ->yes 启动 i2C 内核驱动
- sudo reboot
- wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.60.tar.gz
- tar zxvf bcm2835-1.60.tar.gz
- cd bcm2835-1.60/
- sudo ./configure
- sudo make
- sudo make check
- sudo make install
- sudo apt-get install wiringpi
- #对于树莓派4B可能需要进行升级:
- cd /tmp
- wget https://project-downloads.drogon.net/wiringpi-latest.deb
- sudo dpkg -i wiringpi-latest.deb
- gpio -v
- sudo apt-get install p7zip-full
- wget https://www.waveshare.net/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
- cd AS7341_Spectral_Color_Sensor_code/AS7341_Spectral_Color_Sensor_code/RaspberryPi/c
- make clean
- make
执行
- sudo ./main data
来验证测试程序
- cd
- cd AS7341_Spectral_Color_Sensor_code/AS7341_Spectral_Color_Sensor_code/RaspberryPi/python/examples
执行
- sudo python data.py
来验证测试程序
所有测试程序的功能及需要注意的地方已在Arduino教程中介绍过,同样的,当执行sudo ./main syns 或 python syns.py时,需要给GPIO口上拉再下拉产生一个下降沿信号,可将GPIO脚接到短暂的接触高电平引脚再放开以此来产生一个下降沿信号