#include <MHZ.h>
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
// pin for pwm reading
#define CO2_IN 10
// pin for uart reading
#define MH_Z19_RX 4 // D7
#define MH_Z19_TX 0 // D6
MHZ co2(MH_Z19_RX, MH_Z19_TX, CO2_IN, MHZ19B);
void setup() {
Serial.begin(9600);
pinMode(CO2_IN, INPUT);
delay(100);
Serial.println("MHZ 19B");
lcd.begin(16,1); // ***** 16 columns, 1 row
lcd.clear(); // ***** clear the display, cursor upper left
lcd.print("hello, world!"); // ***** print something so we know it's working
delay(5000); // ***** allow time to read it before proceeding
// ***** get rid of the delay() when everything is working *****
// enable debug to get addition information
// co2.setDebug(true);
if (co2.isPreHeating()) {
Serial.print("Preheating");
while (co2.isPreHeating()) {
Serial.print(".");
delay(5000);
}
Serial.println();
}
}
void loop() {
Serial.print("\n----- Time from start: ");
lcd.clear(); // ***** position the cursor at upper left
lcd.print(millis() / 1000);
Serial.println(" s");
int ppm_pwm = co2.readCO2PWM();
lcd.print("PPM:"); // ***** these will go right after the " s"
lcd.print(ppm_pwm);
Serial.println("\n------------------------------");
delay(5000);
}