1 #include <SoftwareSerial.h>
2 #include <LiquidCrystal.h>
5 const int rx_pin = 2; // connect to TX on MHZ19
6 const int tx_pin = 3; // connect to RX on MHZ19
8 const int led_green_pin = 4;
9 const int led_yellow_pin = 5;
10 const int led_red_pin = 6;
12 const int buzzer_pin = 13;
14 const int co2_warning_thr = 1000;
15 const int co2_alarm_thr = 1500;
17 MHZ19 mhz19 = MHZ19(rx_pin,tx_pin);
18 LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
25 void buzz(unsigned long pause, int count) {
26 for (int i = 0; i <= count; i++) {
27 digitalWrite(buzzer_pin, HIGH);
29 digitalWrite(buzzer_pin, LOW);
30 if (i < count - 1) delay(pause);
37 Serial.println("Time,CO2,Temp");
40 mhz19.begin(rx_pin, tx_pin);
45 lcd.print("Airing Butler");
47 lcd.print("says hello!");
50 pinMode(led_green_pin, OUTPUT);
51 pinMode(led_yellow_pin, OUTPUT);
52 pinMode(led_red_pin, OUTPUT);
53 digitalWrite(led_green_pin, HIGH);
55 digitalWrite(led_green_pin, LOW);
56 digitalWrite(led_yellow_pin, HIGH);
58 digitalWrite(led_yellow_pin, LOW);
59 digitalWrite(led_red_pin, HIGH);
61 digitalWrite(led_red_pin, LOW);
64 pinMode(buzzer_pin, OUTPUT);
74 measurement_t m = mhz19.getMeasurement();
84 digitalWrite(led_red_pin, co2 >= co2_alarm_thr);
85 digitalWrite(led_yellow_pin, co2 >= co2_warning_thr && co2 < co2_alarm_thr);
86 digitalWrite(led_green_pin, co2 < co2_warning_thr);
88 if (co2 >= co2_alarm_thr && lastppm < co2_alarm_thr) {
92 if (co2 >= co2_warning_thr && lastppm < co2_warning_thr) {
103 lcd.print(" C +/- ");