SGP30 Gas Sensor
The SGP30 is a metal-oxide gas sensor with multiple sensing elements on a single chip. It integrates four gas sensing elements and provides fully calibrated air quality output signals. In addition, the SGP30 is easy to integrate, allowing the metal-oxide gas sensor to be embedded into mobile devices, opening new possibilities for environmental monitoring in smart homes, home appliances, and IoT applications. It is primarily used for formaldehyde detection!
Module Source
Purchase Link: https://item.taobao.com/item.htm?spm=a21n57.1.0.0.1925523cK81vXF&id=629652345522&ns=1&abbucket=0
You can also buy:
https://item.taobao.com/item.htm?spm=a21n57.1.0.0.1925523cK81vXF&id=609271054989&ns=1&abbucket=0
Baidu Netdisk Download Link:
https://pan.baidu.com/s/16ITjdV34J8K2Wu24sB_iPg
Password: 1vds
Specifications
Operating Voltage:3.3V
Operating Current:40mA
Output Method: IIC
Pin Count: 4 Pins
Hardware Interface
- The VCC pin of the SGP30 is connected to the 3.3V of the development board.
- GND is connected to the GND pin of the development board.
- SDA (Serial Data Line) is connected to the A4 (SDA) pin of the development board.
- SCL (Serial Clock Line) is connected to the A5 (SCL) pin of the development board.
Usage Method
To use the SGP30, you need to install an Arduino library that is compatible with the sensor. Adafruit provides a library for the SGP30, which can be installed via the Arduino IDE’s Library Manager. In the IDE, go to “Tools” > “Manage Libraries…,” then search for “Adafruit SGP30” and install it.
Enter the code:
/******************************************************************************
* Test Hardware: LCSC ColorEasyDuino Development Board
* Version Number: V1.0
* Modified By: www.lckfb.com
* Modification Date: April 10, 2024
* Function Overview:
*****************************************************************************
* Open-source development board hardware and software information and related projects hardware and software information on official website
* Development board official website: www.lckfb.com
* Technical support resident forum, any technical problems are welcome at any time to exchange learning
* LCSC Forum: club.szlcsc.com
* Follow our Bilibili account: [立创开发板], stay toned to our latest news!
* We focus on cultivating Chinese engineers rather than profiting from board sales.
******************************************************************************/
#include "Adafruit_SGP30.h"
Adafruit_SGP30 sgp;
void setup() {
Serial.begin(9600);
if (!sgp.begin()){
Serial.println("Sensor not found :(");
while (1);
}
Serial.print("Found SGP30 serial #");
Serial.print(sgp.serialnumber[], HEX);
Serial.print(sgp.serialnumber[], HEX);
Serial.println(sgp.serialnumber[], HEX);
}
void loop() {
if (! sgp.IAQmeasure()) {
Serial.println("Measurement failed");
return;
}
Serial.print("TVOC ");
Serial.print(sgp.TVOC);
Serial.print(" ppb\t");
Serial.print("eCO2 ");
Serial.println(sgp.eCO2);
delay(1000);
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Usage Testing
After programming and uploading the code to your board, open the “Serial Monitor” in the Arduino IDE and you will see the TVOC and eCO2 readings. The sensors will take some time to stabilize and may require some calibration to get accurate readings.