Code cleanup
This commit is contained in:
parent
78920d7f3a
commit
34f37b9dda
|
@ -1,3 +1,4 @@
|
|||
.DS_Store
|
||||
.pio
|
||||
.idea
|
||||
.vscode
|
||||
|
|
17
src/main.cpp
17
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);
|
||||
|
|
Loading…
Reference in New Issue