JB
d8882a6a98
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
58 lines
1.1 KiB
C++
58 lines
1.1 KiB
C++
#include <Wire.h>
|
|
#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);
|
|
} |