strange-v / MHZ19

Arduino library for MH-Z19/MH-Z19B CO2 sensor
GNU General Public License v3.0
57 stars 12 forks source link

Temperature not showing correctly on MH-Z19C #14

Closed vignesh8458 closed 2 years ago

vignesh8458 commented 3 years ago

Hi,

I have used the same code on mhz-19b it's working.

In mh-z19c temperature value showing continuously -40

I am getting this error(temperature:-40):

Min CO2: 0 Temperature: -40 Accuracy: 0 CO2: 1031 Min CO2: 0 Temperature: -40 Accuracy: 0 CO2: 1030 Min CO2: 0 Temperature: -40 Accuracy: 0 CO2: 1030 Min CO2: 0 Temperature: -40 Accuracy: 0

Connection:

MH-Z19C | ESP -12E

Vin | 5V GND | GND Tx | D1 Rx | D2

CODE:

include

include

SoftwareSerial ss(5,4); MHZ19 mhz(&ss);

void setup() { Serial.begin(115200); Serial.println(F("Starting..."));

ss.begin(9600); }

void loop() { MHZ19_RESULT response = mhz.retrieveData(); if (response == MHZ19_RESULT_OK) { Serial.print(F("CO2: ")); Serial.println(mhz.getCO2()); Serial.print(F("Min CO2: ")); Serial.println(mhz.getMinCO2()); Serial.print(F("Temperature: ")); Serial.println(mhz.getTemperature()); Serial.print(F("Accuracy: ")); Serial.println(mhz.getAccuracy()); } else { Serial.print(F("Error, code: ")); Serial.println(response); }

delay(15000); }

strange-v commented 3 years ago

Hi,

I haven't heard about MH-Z19C till today, so have no experience using it. It is a new sensor with a new firmware that is not fully compatible with the library.

According to the MH-Z19C datasheet, it uses the same command to init reading and the same output format for CO2 value. All other values are not mentioned there (for MH-Z19B they were deducted by enthusiasts) also, the datasheet contains only one additional command 0x79- On/Off Self-calibration for Zero Point in MH-Z19B 0x79 was used to turn ABC logic on/off.

vignesh8458 commented 3 years ago

Do you suggest any code for the temperature issues?

strange-v commented 2 years ago

This is not an issue with the library. You are using a new sensor that may not have temperature data (at least in the same format). Unfortunately, cannot help with this.

strange-v commented 2 years ago

Closed due to inactivity.

vignesh8458 commented 2 years ago

Thanks for the clarification.