| |
| materiels:capteurs:gaz:gaz [2024/06/26 17:18] – [2.3 SCD4X - CO2, T, (P), RH] phil | materiels:capteurs:gaz:gaz [2025/06/19 19:30] (Version actuelle) – modification externe 127.0.0.1 |
|---|
| </pane> | </pane> |
| </tabs> | </tabs> |
| | |
| | \\ |
| |
| ==== 2. Capteurs de CO2 ==== | ==== 2. Capteurs de CO2 ==== |
| * //**Connexion** à un shield// <html><a href="https://webge.fr/doc/wikis/pdf/TinkerkitV2.pdf" target="_blank">Tinkerkit v2</a></html>. {{ :materiels:capteurs:mg811_2.jpg?nolink&600 |}} | * //**Connexion** à un shield// <html><a href="https://webge.fr/doc/wikis/pdf/TinkerkitV2.pdf" target="_blank">Tinkerkit v2</a></html>. {{ :materiels:capteurs:mg811_2.jpg?nolink&600 |}} |
| |
| {{ :materiels:capteurs:distance:arduinoico.png?nolink&50|}} | {{ :materiels:capteurs:distance:arduinoico.png?nolink&40|}} |
| * // **Exemple** pour tester le capteur// | * // **Exemple** pour tester le capteur// [<html><a href="https://webge.fr/doc/wikis/code/Arduino/ARD_Uno_MG811.zip"><b>Télécharger</b></a></html>] |
| | |
| <code cpp *.cpp> | |
| /*******************Demo for MG-811 Gas Sensor Module V1.1***************************** | |
| Author: Tiequan Shao: tiequan.shao@sandboxelectronics.com | |
| Peng Wei: peng.wei@sandboxelectronics.com | |
| | |
| Lisence: Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) | |
| | |
| Note: This piece of source code is supposed to be used as a demostration ONLY. More | |
| sophisticated calibration is required for industrial field application. | |
| | |
| Sandbox Electronics 2012-05-31 | |
| ************************************************************************************/ | |
| | |
| /************************Hardware Related Macros************************************/ | |
| #define MG_PIN (A0) //define which analog input channel you are going to use | |
| #define BOOL_PIN (2) | |
| #define DC_GAIN (8.5) //define the DC gain of amplifier | |
| | |
| /***********************Software Related Macros************************************/ | |
| #define READ_SAMPLE_INTERVAL (50) //define how many samples you are going to take in normal operation | |
| #define READ_SAMPLE_TIMES (5) //define the time interval(in milisecond) between each samples in | |
| //normal operation | |
| | |
| /**********************Application Related Macros**********************************/ | |
| //These two values differ from sensor to sensor. user should derermine this value. | |
| #define ZERO_POINT_VOLTAGE (0.220) //define the output of the sensor in volts when the concentration of CO2 is 400PPM | |
| #define REACTION_VOLTGAE (0.030) //define the voltage drop of the sensor when move the sensor from air into 1000ppm CO2 | |
| | |
| /*****************************Globals***********************************************/ | |
| float CO2Curve[3] = {2.602,ZERO_POINT_VOLTAGE,(REACTION_VOLTGAE/(2.602-3))}; | |
| //two points are taken from the curve. | |
| //with these two points, a line is formed which is | |
| //"approximately equivalent" to the original curve. | |
| //data format:{ x, y, slope}; point1: (lg400, 0.324), point2: (lg4000, 0.280) | |
| //slope = ( reaction voltage ) / (log400 –log1000) | |
| | |
| void setup() | |
| { | |
| Serial.begin(9600); //UART setup, baudrate = 9600bps | |
| pinMode(BOOL_PIN, INPUT); //set pin to input | |
| digitalWrite(BOOL_PIN, HIGH); //turn on pullup resistors | |
| | |
| Serial.print("MG-811 Demostration\n"); | |
| } | |
| | |
| void loop() | |
| { | |
| int percentage; | |
| float volts; | |
| | |
| volts = MGRead(MG_PIN); | |
| Serial.print( "SEN0159:" ); | |
| Serial.print(volts); | |
| Serial.print( "V " ); | |
| | |
| percentage = MGGetPercentage(volts,CO2Curve); | |
| Serial.print("CO2:"); | |
| if (percentage == -1) { | |
| Serial.print( "<400" ); | |
| } else { | |
| Serial.print(percentage); | |
| } | |
| | |
| Serial.print( "ppm" ); | |
| Serial.print("\n"); | |
| | |
| if (digitalRead(BOOL_PIN) ){ | |
| Serial.print( "=====BOOL is HIGH======" ); | |
| } else { | |
| Serial.print( "=====BOOL is LOW======" ); | |
| } | |
| | |
| Serial.print("\n"); | |
| | |
| delay(500); | |
| } | |
| | |
| /***************************** MGRead ********************************************* | |
| Input: mg_pin - analog channel | |
| Output: output of SEN-000007 | |
| Remarks: This function reads the output of SEN-000007 | |
| ************************************************************************************/ | |
| float MGRead(int mg_pin) | |
| { | |
| int i; | |
| float v=0; | |
| | |
| for (i=0;i<READ_SAMPLE_TIMES;i++) { | |
| v += analogRead(mg_pin); | |
| delay(READ_SAMPLE_INTERVAL); | |
| } | |
| v = (v/READ_SAMPLE_TIMES) *5/1024 ; | |
| return v; | |
| } | |
| | |
| /***************************** MQGetPercentage ********************************** | |
| Input: volts - SEN-000007 output measured in volts | |
| pcurve - pointer to the curve of the target gas | |
| Output: ppm of the target gas | |
| Remarks: By using the slope and a point of the line. The x(logarithmic value of ppm) | |
| of the line could be derived if y(MG-811 output) is provided. As it is a | |
| logarithmic coordinate, power of 10 is used to convert the result to non-logarithmic | |
| value. | |
| ************************************************************************************/ | |
| int MGGetPercentage(float volts, float *pcurve) | |
| { | |
| if ((volts/DC_GAIN )>=ZERO_POINT_VOLTAGE) { | |
| return -1; | |
| } else { | |
| return pow(10, ((volts/DC_GAIN)-pcurve[1])/pcurve[2]+pcurve[0]); | |
| } | |
| } | |
| </code> | |
| </pane> | </pane> |
| <pane id="tab-mg811esp_1"> | <pane id="tab-mg811esp_1"> |
| * PDF du SCD40 à télécharger <html><a href="https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/datasheet/unit/co2/SCD40.pdf" target="_blank"><b>ici</b></a></html> | * PDF du SCD40 à télécharger <html><a href="https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/datasheet/unit/co2/SCD40.pdf" target="_blank"><b>ici</b></a></html> |
| * Schéma à télécharger <html><a href="https://webge.fr/doc/projets/datasheets/SCD40_schematic.png" target="_blank"><b>ici</b></a></html> | * Schéma à télécharger <html><a href="https://webge.fr/doc/projets/datasheets/SCD40_schematic.png" target="_blank"><b>ici</b></a></html> |
| | {{ :materiels:capteurs:environnement:iconechronogrammes.png?nolink&50|}} |
| | * //**Chronogrammes**// |
| | * Relevé des signaux du bus I2C faite lors d'une mesure : **CO2=854ppm**, **T=25,90°C** **RH=71,24%**. A télécharger <html><a href="https://webge.fr/doc/wikis/img/Mesures_SCD40.zip" target="_blank"><b>ici</b></a></html>. |
| | |
| \\ | \\ |
| |
| <pane id="tab-scd40duino_2"> | <pane id="tab-scd40duino_2"> |
| * //**Ressources**// | * //**Ressources**// |
| * <html><a href="https://docs.m5stack.com/en/unit/co2" target="_blank"><b>Wiki</b></a></html> M5STACK | * <html><a href="https://docs.m5stack.com/en/unit/co2" target="_blank"><b>Wiki</b></a></html> M5STACK{{ :materiels:capteurs:intensite:doc.gif?nolink|}} |
| | * //**Fiche guide**// pour l'étude d'une chaîne d'information comprenant un **SCD40** <html><a href="https://webge.fr/doc/projets/tsin/0_Fiches guide TSIN/TSIN_FGA_SCD40.zip">[Télécharger]</a></html> |
| | * //**Connexion**// à une <html><a href="https://wiki.seeedstudio.com/Base_Shield_V2/" target="_blank">Base Shield V2</a></html> montée sur une Arduino Uno {{ :materiels:capteurs:gaz:scd40_arduino.jpg?nolink |}} |
| {{ :materiels:capteurs:distance:arduinoico.png?nolink&40|}} | {{ :materiels:capteurs:distance:arduinoico.png?nolink&40|}} |
| * //**Exemple** de l'IDE Arduino pour tester le capteur// \\ Dans l'IDE Arduino, sélectionner : Fichier → Exemples -> Sensirion I2C SCD4x -> **exampleUsage** | * //**Exemple** de l'IDE Arduino pour tester le capteur// \\ Dans l'IDE Arduino, sélectionner : Fichier → Exemples -> Sensirion I2C SCD4x -> **exampleUsage** |
| * Plages de mesure | * Plages de mesure |
| * 400 à 60000ppm d'**eCO2** (dioxyde de carbone calculé équivalent, résolution: 11 ppm) | * 400 à 60000ppm d'**eCO2** (dioxyde de carbone calculé équivalent, résolution: 11 ppm) |
| * 0 à 60 000ppb de COVT (composé organique volatile total, résolution: 13 ppb) | * 0 à 60 000ppb de <html><a href="https://www.pranaair.com/fr/what-is-voc/" target="_blank" title="Qu'est-ce que le VOC?"><b>COVT</b></a></html> (composé organique volatile total, résolution: 13 ppb) |
| * éthanol: 0 à 1000 ppm (précision: 15%, résolution: 0,2 %) | * éthanol: 0 à 1000 ppm (précision: 15%, résolution: 0,2 %) |
| * H2: 0 à 1000 ppm (précision: 10%, résolution: résolution: 0,2 %) | * H2: 0 à 1000 ppm (précision: 10%, résolution: résolution: 0,2 %) |
| {{ :materiels:capteurs:acrobate.gif?nolink&40|}} | {{ :materiels:capteurs:acrobate.gif?nolink&40|}} |
| * //**Documentation**// \\ | * //**Documentation**// \\ |
| * PDF à télécharger <html><a href="https://www.mouser.fr/datasheet/2/737/adafruit_sgp30_gas_tvoc_eco2_mox_sensor-1396564.pdf" target="_blank"><strong>ici</strong></a></html> | * PDF à télécharger <html><a href="https://www.mouser.fr/datasheet/2/737/adafruit_sgp30_gas_tvoc_eco2_mox_sensor-1396564.pdf" target="_blank"><b>ici</b></a></html> |
| | * Tableau de valeurs <html><a href="https://webge.fr/doc/wikis/img/AQI tvoc.webp" target="_blank"><b>TVOC</b></a></html> |
| |
| \\ | \\ |
| == 2.5.2 Bibliothèques == | == 2.5.2 Bibliothèques == |
| <tabs> | <tabs> |
| * [[#tab-sgp30duino_1|Arduino UNO]] | |
| * [[#tab-sgp30esp_1|ESP (Arduino)]] | * [[#tab-sgp30esp_1|ESP (Arduino)]] |
| * [[#tab-sgp30pico_1|Rpi Pico (µPython)]] | * [[#tab-sgp30pico_1|Rpi Pico (µPython)]] |
| |
| <pane id="tab-sgp30duino_1"> | <pane id="tab-sgp30esp_1"> |
| * //A partir du gestionnaire de bibliothèques de l'**IDE Arduino**, installer :// {{ :materiels:capteurs:gaz:sgp30_adafruit.png?nolink |}} | * //A partir du gestionnaire de bibliothèques de l'**IDE Arduino**, installer :// {{ :materiels:capteurs:gaz:sgp30_adafruit.png?nolink |}} |
| </pane> | </pane> |
| <pane id="tab-sgp30esp_1"> | |
| * Avenir | |
| </pane> | |
| <pane id="tab-sgp30pico_1"> | <pane id="tab-sgp30pico_1"> |
| * Avenir | * <color #ed1c24>A venir</color> |
| </pane> | </pane> |
| </tabs> | </tabs> |
| == 2.5.3 Exemples de code == | == 2.5.3 Exemples de code == |
| <tabs> | <tabs> |
| * [[#tab-sgp30duino_2|Arduino UNO]] | |
| * [[#tab-sgp30esp_2|ESP (Arduino)]] | * [[#tab-sgp30esp_2|ESP (Arduino)]] |
| * [[#tab-sgp30pico_2|Rpi Pico (µPython)]] | * [[#tab-sgp30pico_2|Rpi Pico (µPython)]] |
| <pane id="tab-sgp30duino_2"> | <pane id="tab-sgp30esp_2"> |
| {{ :materiels:capteurs:distance:arduinoico.png?nolink&40|}} | {{ :materiels:capteurs:distance:arduinoico.png?nolink&40|}} |
| * //**Exemple** de l'IDE Arduino pour tester le capteur// \\ Fichier -> Exemples -> Adafruit SGP30 Sensor -> **sgp30test.ino** | * //**Exemple** de l'IDE Arduino pour tester le capteur// \\ Fichier -> Exemples -> Adafruit SGP30 Sensor -> **sgp30test.ino** |
| <callout type="tip" icon="true"><html><a href="https://webge.fr/doc/wikis/code/Arduino/ARD_PIO_ESP8266_SGP30.zip" target="_blank">Télécharger</a></html> le projet PlatformIO pour VSCode.</callout> | <callout type="tip" icon="true"><html><a href="https://webge.fr/doc/wikis/code/Arduino/ARD_PIO_ESP8266_SGP30.zip" target="_blank">Télécharger</a></html> le projet PlatformIO pour VSCode.</callout> |
| </pane> | </pane> |
| <pane id="tab-sgp30esp_2"> | |
| * A venir | |
| </pane> | |
| <pane id="tab-sgp30pico_2"> | <pane id="tab-sgp30pico_2"> |
| * A venir | * <color #ed1c24>A venir</color> |
| </pane> | </pane> |
| </tabs> | </tabs> |
| ==== Pour aller plus loin ... === | ==== Pour aller plus loin ... === |
| * **Exemple de projet** \\ <html><a href="https://www.hackster.io/naveenbskumar/co2-levels-monitoring-and-airflow-control-using-wio-terminal-a5a241" target="_blank"> Surveillance des niveaux de CO2 et contrôle du débit d'air à l'aide du terminal Wio</a></html> | * **Exemple de projet** \\ <html><a href="https://www.hackster.io/naveenbskumar/co2-levels-monitoring-and-airflow-control-using-wio-terminal-a5a241" target="_blank"> Surveillance des niveaux de CO2 et contrôle du débit d'air à l'aide du terminal Wio</a></html> |