Good morning everyone!
Recently, I´ve been dealing with a problem that I cannot work out.
I’m using a WIFI LoRa 32 V2.1 alongside a Co2 sensor, specifically the MH-Z19B.
This sensor use is connected to the ESP32 through UART via Serial Port.
I’ve been using this sketch but it doesn´t work. All the co2 values that I get are 0, always
#include <SoftwareSerial.h> // Remove if using HardwareSerial
#define RX_PIN 4 // Rx pin which the MHZ19 Tx pin is attached to (SCL)
#define TX_PIN 15 // Tx pin which the MHZ19 Rx pin is attached to (SDA)
#define BAUDRATE 9600 // Device to MH-Z19 Serial baudrate (should not be changed)
MHZ19 myMHZ19; // Constructor for library
SoftwareSerial mySerial(RX_PIN, TX_PIN);
unsigned long getDataTimer = 0;
Wire.begin(4, 15); mySerial.begin(BAUDRATE); myMHZ19.begin(mySerial); myMHZ19.autoCalibration();
if (millis() - getDataTimer >= 5000)
CO2 = myMHZ19.getCO2(); Serial.print("CO2 (ppm): "); Serial.println(CO2); int8_t Temp; Temp = myMHZ19.getTemperature(); Serial.print("Temperature (C): "); Serial.println(Temp); getDataTimer = millis(); }
I tried to modified each parameter, changing the RX and TX pins, trying with different cables and even using another sensor but I don’t know which is the issue.
Besides, I used a ESP8266 with the MH-Z19B and it works perfectly. Therefore, I assume that is an issue related to the WIFI LoRa 32 V2.1.
It might be a matter of incompatibility with some pin. I don’t really know…
Has anyone used this sensor with WIFI LoRa 32 V2.1 and did it work?
I am open to any suggestions.
Thak you very much in advance.