-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCO2-Ampel-DIY-Octopus-SCD30.ino
81 lines (68 loc) · 2.16 KB
/
CO2-Ampel-DIY-Octopus-SCD30.ino
1
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. */
#include <SparkFun_SCD30_Arduino_Library.h>
#include <Wire.h>
#include <ESP8266WiFi.h>
int CO2 = 0 ;
//Reading CO2, humidity and temperature from the SCD30 By: Nathan Seidle SparkFun Electronics
//https://github.com/sparkfun/SparkFun_SCD30_Arduino_Library
SCD30 airSensorSCD30; // Objekt SDC30 Umweltsensor
void setup(){ // Einmalige Initialisierung
WiFi.forceSleepBegin(); // Wifi off
pinMode( 12 , OUTPUT);
pinMode( 13 , OUTPUT);
pinMode( 14 , OUTPUT);
Wire.begin(); // ---- Initialisiere den I2C-Bus
if (Wire.status() != I2C_OK) Serial.println("Something wrong with I2C");
if (airSensorSCD30.begin() == false) {
Serial.println("The SCD30 did not respond. Please check wiring.");
while(1) {
yield();
delay(1);
}
}
airSensorSCD30.setAutoSelfCalibration(false); // Sensirion no auto calibration
airSensorSCD30.setMeasurementInterval(2); // CO2-Messung alle 5 s
Serial.begin(115200);
Serial.println();
digitalWrite( 12 , LOW );
digitalWrite( 13 , LOW );
digitalWrite( 14 , LOW );
Wire.setClock(100000L); // 100 kHz SCD30
Wire.setClockStretchLimit(200000L);// CO2-SCD30
}
void loop() { // Kontinuierliche Wiederholung
CO2 = airSensorSCD30.getCO2() ;
Serial.print("CO2:"+String(String(CO2)));
Serial.println();
if (( ( CO2 ) < ( 1000 ) ))
{
digitalWrite( 12 , LOW );
digitalWrite( 13 , LOW );
digitalWrite( 14 , HIGH );
Serial.print("green");
Serial.println();
}
else
{
if (( ( CO2 ) < ( 1400 ) ))
{
digitalWrite( 12 , LOW );
digitalWrite( 13 , HIGH );
digitalWrite( 14 , LOW );
Serial.print("yellow");
Serial.println();
}
else
{
digitalWrite( 12 , HIGH );
digitalWrite( 13 , LOW );
digitalWrite( 14 , LOW );
Serial.print("red");
Serial.println();
}
}
delay( 2000 );
}