diff --git a/.gitignore b/.gitignore index 8126b3a..8f64da7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.DS_Store .pio .idea .vscode diff --git a/src/main.cpp b/src/main.cpp index 9dcc8b6..e699b84 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,11 +3,7 @@ #include "Adafruit_AHTX0.h" #include "LiquidCrystal_I2C.h" -#define RX_PIN 16 // Rx pin which the MHZ19 Tx pin is attached to -#define TX_PIN 17 // Tx pin which the MHZ19 Rx pin is attached to -#define BAUDRATE 9600 // Device to MH-Z19 Serial baudrate (should not be changed) - -MHZ19 myMHZ19; // Constructor for library +MHZ19 myMHZ19; Adafruit_AHTX0 aht; LiquidCrystal_I2C LCD(0x27,2,1,0,4,5,6,7,3,POSITIVE); @@ -36,12 +32,11 @@ void IRAM_ATTR BacklightToggle() { void setup() { - Serial.begin(9600); // Device to serial monitor feedback + Serial.begin(9600); + Serial2.begin(9600, SERIAL_8N1, 16, 17); - Serial2.begin(BAUDRATE, SERIAL_8N1, RX_PIN, TX_PIN); // (Uno example) device to MH-Z19 serial start - myMHZ19.begin(Serial2); // *Serial(Stream) refence must be passed to library begin(). - - myMHZ19.autoCalibration(); // Turn auto calibration ON (OFF autoCalibration(false)) + myMHZ19.begin(Serial2); + myMHZ19.autoCalibration(); myMHZ19.setRange(2000); Serial.println("MHZ19 init:"); @@ -109,7 +104,7 @@ void loop() { int co2 = myMHZ19.getCO2(false); if (myMHZ19.errorCode != RESULT_OK) { Serial.print("Error. Response Code: "); - Serial.println(myMHZ19.errorCode); // Get the Error Code value + Serial.println(myMHZ19.errorCode); return; } LCD.setCursor(0, 1);