From d8882a6a98fca532deb9fc4ee23d0bc965d5b4de Mon Sep 17 00:00:00 2001 From: JB Date: Tue, 11 Oct 2022 15:55:51 +0200 Subject: [PATCH] =?UTF-8?q?Transf=C3=A9rer=20les=20fichiers=20vers=20''?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Code fait par Ettore à partir de ce document : https://nousaerons.fr/makersco2/documents/co2meter_nousaerons_cablage_v9-1.pdf page 7 page du wiki de ce projet : https://projets.cohabit.fr/redmine/projects/projets-du-fablab/wiki/Co2-Covid-LieuxClos --- main.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 main.cpp diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..bfcd315 --- /dev/null +++ b/main.cpp @@ -0,0 +1,58 @@ +#include +#include "SparkFun_SCD30_Arduino_Library.h" +#include "LiquidCrystal_I2C.h" +#define LED_PIN3 +/*int ledR =2; +int ledO =4; +int ledV =5;*/ +int ledR =5; +int ledO =18; +int ledV =19; +SCD30 airSensor; + +void setup() +{ +Serial.begin(9600); +Serial.println("SCD30 Example"); +Wire.begin(); +if (airSensor.begin() == false) +{ +Serial.println("Air sensor not detected. Please check wiring. Freezing..."); +while (1) +; +} +pinMode(ledR, OUTPUT); +pinMode(ledO, OUTPUT); +pinMode(ledV, OUTPUT); +} +void loop() +{ +int taux_co2; +if (airSensor.dataAvailable()) +{ +taux_co2 = (int)airSensor.getCO2(); +Serial.print("co2(ppm):"); +Serial.print(taux_co2); +Serial.print(" temp(C):"); +Serial.print(airSensor.getTemperature(), 1); +Serial.print(" humidity(%):"); +Serial.print(airSensor.getHumidity(), 1); +Serial.println(); +if (taux_co2 < 800){ +digitalWrite(ledV,HIGH); +digitalWrite(ledO,LOW); +digitalWrite(ledR,LOW); +} +else if (taux_co2 >= 800 && taux_co2 < 1000){ +digitalWrite(ledO,HIGH); +digitalWrite(ledV,LOW); +digitalWrite(ledR,LOW); +} +else if (taux_co2 >= 1000){ +digitalWrite(ledR,HIGH); +digitalWrite(ledO,LOW); +digitalWrite(ledV,LOW); +} +} +delay(500); +} \ No newline at end of file