Template: SGP40 VOC Sensor Pi Guide
From Waveshare Wiki
Raspberry Pi
Hardware connection
AS7341 Spectral Color Sensor | Raspberry Pi(BCM) |
VCC | 3.3V/5V |
GND | GND |
SDA | SDA(2) |
SCL | SCL(3) |
Working with Raspberry Pi
Enable I2C interface
- Open a terminal and run the following commands:
sudo raspi-config #Choose Interfacing Options -> I2C -> yes to enable the I2C interface
- Restart Raspberry Pi
sudo reboot
Install libraries
- Install BCM2835, open the terminal, and run the following command.
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
- Install wiringpi
sudo apt-get install wiringpi cd /tmp wget https://project-downloads.drogon.net/wiringpi-latest.deb sudo dpkg -i wiringpi-latest.deb gpio -v
Download and test the demo codes
sudo apt-get install p7zip-full wget https://files.waveshare.com/upload/6/62/SGP40_Voc_Sensor_code.7z 7z x SGP40_Voc_Sensor_code.7z -r -o./SGP40_Voc_Sensor_code sudo chmod 777 -R SGP40_Voc_Sensor_code
C codes
cd cd SGP40_Voc_Sensor_code/RPI/c sudo make clean sudo make sudo ./main
python codes
cd cd SGP40_Voc_Sensor_code/RPI/python sudo python SGP40.py
- Note: This sensor is extremely sensitive to ethanol.
- Note: The sensor starts with a heating process, during which the raw data slowly increases until it stabilizes.