MHZ19 sensor working ??
Moderators: grovkillen, Stuntteam, TD-er
MHZ19 sensor working ??
Hi
Trying to interface my MHZ19 sensor I falshed the dev firmware in my ESP. I have then setup it in web interface (not wired sensor yet) and since my ESP reboots automatically nearly all the time ! I can reach it few seconds every 2/3 minutes ! Is the driver unusable in the dev branch ?? or is it because I did not wire sensor first ??
Thanks
Vincèn
Trying to interface my MHZ19 sensor I falshed the dev firmware in my ESP. I have then setup it in web interface (not wired sensor yet) and since my ESP reboots automatically nearly all the time ! I can reach it few seconds every 2/3 minutes ! Is the driver unusable in the dev branch ?? or is it because I did not wire sensor first ??
Thanks
Vincèn
Re: MHZ19 sensor working ??
Which firmware?
Which hardware setup?
If you want help, you need to tell a LOT more!!!
Which hardware setup?
If you want help, you need to tell a LOT more!!!
Re: MHZ19 sensor working ??
+1 for that.
If the sensor is not connected it's diffucult to say what's going on.
Anyways we need a lot of more info.
Regards
Shardan
Regards
Shardan
Shardan
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: MHZ19 sensor working ??
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



Re: MHZ19 sensor working ??
I am also testing the plugin, with http to domoticz, no MQTT.
I have connected it to a WEMOS. This is the plugin settings: I often get this kind of readings in the serial port:
Any idea why it give a Unstable reading that often?
EVENT: Clock#Time=Sun,15:38
FF 86 5 47 3F 4 2A 3F 82
MHZ19: Unstable reading, ignoring! PPM value: 1351 Temp/S/U values: 23/4/10815.00
EVENT: Clock#Time=Sun,15:39
WD : Uptime 1 ConnectFailures 0 FreeMem 18240
WD : Uptime 1 ConnectFailures 0 FreeMem 18264
FF 86 4 B1 3F 4 2A 3F 19
MHZ19: Unstable reading, ignoring! PPM value: 1201 Temp/S/U values: 23/4/10815.00
EVENT: Clock#Time=Sun,15:40
WD : Uptime 2 ConnectFailures 0 FreeMem 18264
IMPT : [MQTT#Solar] : 1428.00
EVENT: MQTT#Solar=1428.00
WD : Uptime 2 ConnectFailures 0 FreeMem 18392
FF 86 4 90 3F 8 2A 3F 36
MHZ19: Unstable reading, ignoring! PPM value: 1168 Temp/S/U values: 23/8/10815.00
EVENT: Clock#Time=Sun,15:41
WD : Uptime 3 ConnectFailures 0 FreeMem 18416
I modified the code a bit, so it now accepts commands like mhzreset. I use in the serial port: MHZ19,mhzreset etc.
The software now also prints the Hex codes of the input stream.
This is what I changed in the WRITE part:
case PLUGIN_WRITE:
{
String tmpString = string;
int argIndex = tmpString.indexOf(',');
if (argIndex)
tmpString = tmpString.substring(0, argIndex);
if (tmpString.equalsIgnoreCase(F("MHZ19")))
{
success = true;
argIndex = string.lastIndexOf(',');
tmpString = string.substring(argIndex + 1);
// String command = parseString(string, 1);
Serial.print("MHZ: ");Serial.println(tmpString);
if (tmpString.equalsIgnoreCase(F("mhzcalibratezero")))
{
Plugin_049_SoftSerial->write(mhzCmdCalibrateZero, 9);
addLog(LOG_LEVEL_INFO, F("MHZ19: Calibrated zero point!"));
success = true;
}
if (tmpString.equalsIgnoreCase(F("mhzreset")))
{
Plugin_049_SoftSerial->write(mhzCmdReset, 9);
addLog(LOG_LEVEL_INFO, F("MHZ19: Sent sensor reset!"));
success = true;
}
if (tmpString.equalsIgnoreCase(F("mhzabcenable")))
{
Plugin_049_SoftSerial->write(mhzCmdABCEnable, 9);
addLog(LOG_LEVEL_INFO, F("MHZ19: Sent sensor ABC Enable!"));
success = true;
}
if (tmpString.equalsIgnoreCase(F("mhzabcdisable")))
{
Plugin_049_SoftSerial->write(mhzCmdABCDisable, 9);
addLog(LOG_LEVEL_INFO, F("MHZ19: Sent sensor ABC Disable!"));
success = true;
}
if (tmpString.equalsIgnoreCase(F("mhzmeasurementrange1000")))
{
Plugin_049_SoftSerial->write(mhzCmdMeasurementRange1000, 9);
addLog(LOG_LEVEL_INFO, F("MHZ19: Sent measurement range 0-1000PPM!"));
success = true;
}
if (tmpString.equalsIgnoreCase(F("mhzmeasurementrange2000")))
{
Plugin_049_SoftSerial->write(mhzCmdMeasurementRange2000, 9);
addLog(LOG_LEVEL_INFO, F("MHZ19: Sent measurement range 0-2000PPM!"));
success = true;
}
if (tmpString.equalsIgnoreCase(F("mhzmeasurementrange3000")))
{
Plugin_049_SoftSerial->write(mhzCmdMeasurementRange3000, 9);
addLog(LOG_LEVEL_INFO, F("MHZ19: Sent measurement range 0-3000PPM!"));
success = true;
}
if (tmpString.equalsIgnoreCase(F("mhzmeasurementrange5000")))
{
Plugin_049_SoftSerial->write(mhzCmdMeasurementRange5000, 9);
addLog(LOG_LEVEL_INFO, F("MHZ19: Sent measurement range 0-5000PPM!"));
success = true;
}
break;
}
}
case PLUGIN_READ:
I have connected it to a WEMOS. This is the plugin settings: I often get this kind of readings in the serial port:
Any idea why it give a Unstable reading that often?
EVENT: Clock#Time=Sun,15:38
FF 86 5 47 3F 4 2A 3F 82
MHZ19: Unstable reading, ignoring! PPM value: 1351 Temp/S/U values: 23/4/10815.00
EVENT: Clock#Time=Sun,15:39
WD : Uptime 1 ConnectFailures 0 FreeMem 18240
WD : Uptime 1 ConnectFailures 0 FreeMem 18264
FF 86 4 B1 3F 4 2A 3F 19
MHZ19: Unstable reading, ignoring! PPM value: 1201 Temp/S/U values: 23/4/10815.00
EVENT: Clock#Time=Sun,15:40
WD : Uptime 2 ConnectFailures 0 FreeMem 18264
IMPT : [MQTT#Solar] : 1428.00
EVENT: MQTT#Solar=1428.00
WD : Uptime 2 ConnectFailures 0 FreeMem 18392
FF 86 4 90 3F 8 2A 3F 36
MHZ19: Unstable reading, ignoring! PPM value: 1168 Temp/S/U values: 23/8/10815.00
EVENT: Clock#Time=Sun,15:41
WD : Uptime 3 ConnectFailures 0 FreeMem 18416
I modified the code a bit, so it now accepts commands like mhzreset. I use in the serial port: MHZ19,mhzreset etc.
The software now also prints the Hex codes of the input stream.
This is what I changed in the WRITE part:
case PLUGIN_WRITE:
{
String tmpString = string;
int argIndex = tmpString.indexOf(',');
if (argIndex)
tmpString = tmpString.substring(0, argIndex);
if (tmpString.equalsIgnoreCase(F("MHZ19")))
{
success = true;
argIndex = string.lastIndexOf(',');
tmpString = string.substring(argIndex + 1);
// String command = parseString(string, 1);
Serial.print("MHZ: ");Serial.println(tmpString);
if (tmpString.equalsIgnoreCase(F("mhzcalibratezero")))
{
Plugin_049_SoftSerial->write(mhzCmdCalibrateZero, 9);
addLog(LOG_LEVEL_INFO, F("MHZ19: Calibrated zero point!"));
success = true;
}
if (tmpString.equalsIgnoreCase(F("mhzreset")))
{
Plugin_049_SoftSerial->write(mhzCmdReset, 9);
addLog(LOG_LEVEL_INFO, F("MHZ19: Sent sensor reset!"));
success = true;
}
if (tmpString.equalsIgnoreCase(F("mhzabcenable")))
{
Plugin_049_SoftSerial->write(mhzCmdABCEnable, 9);
addLog(LOG_LEVEL_INFO, F("MHZ19: Sent sensor ABC Enable!"));
success = true;
}
if (tmpString.equalsIgnoreCase(F("mhzabcdisable")))
{
Plugin_049_SoftSerial->write(mhzCmdABCDisable, 9);
addLog(LOG_LEVEL_INFO, F("MHZ19: Sent sensor ABC Disable!"));
success = true;
}
if (tmpString.equalsIgnoreCase(F("mhzmeasurementrange1000")))
{
Plugin_049_SoftSerial->write(mhzCmdMeasurementRange1000, 9);
addLog(LOG_LEVEL_INFO, F("MHZ19: Sent measurement range 0-1000PPM!"));
success = true;
}
if (tmpString.equalsIgnoreCase(F("mhzmeasurementrange2000")))
{
Plugin_049_SoftSerial->write(mhzCmdMeasurementRange2000, 9);
addLog(LOG_LEVEL_INFO, F("MHZ19: Sent measurement range 0-2000PPM!"));
success = true;
}
if (tmpString.equalsIgnoreCase(F("mhzmeasurementrange3000")))
{
Plugin_049_SoftSerial->write(mhzCmdMeasurementRange3000, 9);
addLog(LOG_LEVEL_INFO, F("MHZ19: Sent measurement range 0-3000PPM!"));
success = true;
}
if (tmpString.equalsIgnoreCase(F("mhzmeasurementrange5000")))
{
Plugin_049_SoftSerial->write(mhzCmdMeasurementRange5000, 9);
addLog(LOG_LEVEL_INFO, F("MHZ19: Sent measurement range 0-5000PPM!"));
success = true;
}
break;
}
}
case PLUGIN_READ:
Re: MHZ19 sensor working ??
Every time, after a few hours, the MHZ19 starts to show:
EVENT: Clock#Time=Sun,21:57
WD : Uptime 177 ConnectFailures 0 FreeMem 18392
WD : Uptime 178 ConnectFailures 0 FreeMem 18416
FF 86 0 15 40 40 2D 89 2F
MHZ19: PPM value: 21 Temp/S/U values: 24/64/11657.00
EVENT: CO2#PPM=21.00
EVENT: CO2#Temperature=24.00
EVENT: CO2#U=11657.00
EVENT: Clock#Time=Sun,21:58
WD : Uptime 178 ConnectFailures 0 FreeMem 18392
WD : Uptime 179 ConnectFailures 0 FreeMem 18296
FF 86 0 15 40 40 2D 89 2F
MHZ19: PPM value: 21 Temp/S/U values: 24/64/11657.00
EVENT: CO2#PPM=21.00
EVENT: CO2#Temperature=24.00
EVENT: CO2#U=11657.00
EVENT: Clock#Time=Sun,21:59
Any idea?
EVENT: Clock#Time=Sun,21:57
WD : Uptime 177 ConnectFailures 0 FreeMem 18392
WD : Uptime 178 ConnectFailures 0 FreeMem 18416
FF 86 0 15 40 40 2D 89 2F
MHZ19: PPM value: 21 Temp/S/U values: 24/64/11657.00
EVENT: CO2#PPM=21.00
EVENT: CO2#Temperature=24.00
EVENT: CO2#U=11657.00
EVENT: Clock#Time=Sun,21:58
WD : Uptime 178 ConnectFailures 0 FreeMem 18392
WD : Uptime 179 ConnectFailures 0 FreeMem 18296
FF 86 0 15 40 40 2D 89 2F
MHZ19: PPM value: 21 Temp/S/U values: 24/64/11657.00
EVENT: CO2#PPM=21.00
EVENT: CO2#Temperature=24.00
EVENT: CO2#U=11657.00
EVENT: Clock#Time=Sun,21:59
Any idea?
Re: MHZ19 sensor working ??
I also got Unstable reading almost all the time and can't figure it out why? Could it be a wrong soldering?BertB wrote: ↑23 Jul 2017, 15:45 I am also testing the plugin, with http to domoticz, no MQTT.
I have connected it to a WEMOS. This is the plugin settings:
MHZ19.png
I often get this kind of readings in the serial port:
Any idea why it give a Unstable reading that often?
EVENT: Clock#Time=Sun,15:38
FF 86 5 47 3F 4 2A 3F 82
MHZ19: Unstable reading, ignoring! PPM value: 1351 Temp/S/U values: 23/4/10815.00
EVENT: Clock#Time=Sun,15:39
WD : Uptime 1 ConnectFailures 0 FreeMem 18240
WD : Uptime 1 ConnectFailures 0 FreeMem 18264
FF 86 4 B1 3F 4 2A 3F 19
MHZ19: Unstable reading, ignoring! PPM value: 1201 Temp/S/U values: 23/4/10815.00
EVENT: Clock#Time=Sun,15:40
WD : Uptime 2 ConnectFailures 0 FreeMem 18264
IMPT : [MQTT#Solar] : 1428.00
EVENT: MQTT#Solar=1428.00
WD : Uptime 2 ConnectFailures 0 FreeMem 18392
FF 86 4 90 3F 8 2A 3F 36
MHZ19: Unstable reading, ignoring! PPM value: 1168 Temp/S/U values: 23/8/10815.00
EVENT: Clock#Time=Sun,15:41
WD : Uptime 3 ConnectFailures 0 FreeMem 18416
I modified the code a bit, so it now accepts commands like mhzreset. I use in the serial port: MHZ19,mhzreset etc.
The software now also prints the Hex codes of the input stream.
This is what I changed in the WRITE part:
case PLUGIN_WRITE:
{
String tmpString = string;
int argIndex = tmpString.indexOf(',');
if (argIndex)
tmpString = tmpString.substring(0, argIndex);
if (tmpString.equalsIgnoreCase(F("MHZ19")))
{
success = true;
argIndex = string.lastIndexOf(',');
tmpString = string.substring(argIndex + 1);
// String command = parseString(string, 1);
Serial.print("MHZ: ");Serial.println(tmpString);
if (tmpString.equalsIgnoreCase(F("mhzcalibratezero")))
{
Plugin_049_SoftSerial->write(mhzCmdCalibrateZero, 9);
addLog(LOG_LEVEL_INFO, F("MHZ19: Calibrated zero point!"));
success = true;
}
if (tmpString.equalsIgnoreCase(F("mhzreset")))
{
Plugin_049_SoftSerial->write(mhzCmdReset, 9);
addLog(LOG_LEVEL_INFO, F("MHZ19: Sent sensor reset!"));
success = true;
}
if (tmpString.equalsIgnoreCase(F("mhzabcenable")))
{
Plugin_049_SoftSerial->write(mhzCmdABCEnable, 9);
addLog(LOG_LEVEL_INFO, F("MHZ19: Sent sensor ABC Enable!"));
success = true;
}
if (tmpString.equalsIgnoreCase(F("mhzabcdisable")))
{
Plugin_049_SoftSerial->write(mhzCmdABCDisable, 9);
addLog(LOG_LEVEL_INFO, F("MHZ19: Sent sensor ABC Disable!"));
success = true;
}
if (tmpString.equalsIgnoreCase(F("mhzmeasurementrange1000")))
{
Plugin_049_SoftSerial->write(mhzCmdMeasurementRange1000, 9);
addLog(LOG_LEVEL_INFO, F("MHZ19: Sent measurement range 0-1000PPM!"));
success = true;
}
if (tmpString.equalsIgnoreCase(F("mhzmeasurementrange2000")))
{
Plugin_049_SoftSerial->write(mhzCmdMeasurementRange2000, 9);
addLog(LOG_LEVEL_INFO, F("MHZ19: Sent measurement range 0-2000PPM!"));
success = true;
}
if (tmpString.equalsIgnoreCase(F("mhzmeasurementrange3000")))
{
Plugin_049_SoftSerial->write(mhzCmdMeasurementRange3000, 9);
addLog(LOG_LEVEL_INFO, F("MHZ19: Sent measurement range 0-3000PPM!"));
success = true;
}
if (tmpString.equalsIgnoreCase(F("mhzmeasurementrange5000")))
{
Plugin_049_SoftSerial->write(mhzCmdMeasurementRange5000, 9);
addLog(LOG_LEVEL_INFO, F("MHZ19: Sent measurement range 0-5000PPM!"));
success = true;
}
break;
}
}
case PLUGIN_READ:
Re: MHZ19 sensor working ??
I have the same problem.
I always get Unstable Reading ...
33093152 : MHZ19: Unstable reading, ignoring! PPM value: 350 Temp/S/U values: 24/0/0.00
I think the wiring isn't the problem as it's really simple.
I'm using the latest dev Version from Github.
Any tipps?
I always get Unstable Reading ...
33093152 : MHZ19: Unstable reading, ignoring! PPM value: 350 Temp/S/U values: 24/0/0.00
I think the wiring isn't the problem as it's really simple.
I'm using the latest dev Version from Github.
Any tipps?
Re: MHZ19 sensor working ??
You have the new "B" version.
There is already a pull request for this.
The problem is that the current MH-Z19 plugin is only accepting S-values of 64, where you have a 0.
The old sensor had always 1 bit active for that value (64 = good reading, 32/16/8/4 = unstable reading, 1 = init after boot).
So a simple patch for you would be to allow all S-values equal to either 0 or 64.
Re: MHZ19 sensor working ??
Yes thats correct.
I removed the stability check myself.
Now it's reporting the values to MQTT.
I calibrated the sensor after I put it outdoor for an hour and it showed about 400ppm.
But when I take it inside it always reports about 900 and above even when I open all windows for some time.
Is this normal?
Now I calibrated it indoor after all windows have been opened for some time.
I will look over time if the values are now plausible.
I removed the stability check myself.
Now it's reporting the values to MQTT.
I calibrated the sensor after I put it outdoor for an hour and it showed about 400ppm.
But when I take it inside it always reports about 900 and above even when I open all windows for some time.
Is this normal?
Now I calibrated it indoor after all windows have been opened for some time.
I will look over time if the values are now plausible.
Re: MHZ19 sensor working ??
I would advice not to calibrate it yourself.
Perhaps have the ABC on (default setting) and let it rest for a day or two in a well ventilated room, or at least a room which is not populated by humans/animals for a longer time.
Also make sure your sensor is not exposed to direct sunlight. The sensor operates on IR light absorption.
And the CO2 measurement is also temperature and humidity dependent.
It is best to let the sensor hang in stable air, not in turbulent air. I saw higher reported values when the sensor was in the opening of a door to the garden. Perhaps all CO2 from our living room passed the sensor
Perhaps have the ABC on (default setting) and let it rest for a day or two in a well ventilated room, or at least a room which is not populated by humans/animals for a longer time.
Also make sure your sensor is not exposed to direct sunlight. The sensor operates on IR light absorption.
And the CO2 measurement is also temperature and humidity dependent.
It is best to let the sensor hang in stable air, not in turbulent air. I saw higher reported values when the sensor was in the opening of a door to the garden. Perhaps all CO2 from our living room passed the sensor

Re: MHZ19 sensor working ??
I read that you could calibrate it outdoor as outdoor is always around 400ppm.
I already noticed that i get higher readings when there was an airflow at the sensor.
Now i put it into an enclosure to prtotect it from airflows and other light.
Maybe the indirect light on my table was causing this.
I will have an eye on the values as i don't need exact values.
Plausible ones are enough to determine when to open the windows
I already noticed that i get higher readings when there was an airflow at the sensor.
Now i put it into an enclosure to prtotect it from airflows and other light.
Maybe the indirect light on my table was causing this.
I will have an eye on the values as i don't need exact values.
Plausible ones are enough to determine when to open the windows

Re: MHZ19 sensor working ??
Since you did some manual calibration yourself, please leave the ABC enabled for a few days to let it reset itself to some sensible levels.
Re: MHZ19 sensor working ??
Just flashed my ESP with the rev 12 of 2.0.0 ESPEasy and now it reads values of my MHZ but still sees them all as invalid in logs. I have let the ABC in Normal. Should I just let the sensor in my living for a while and it'll then stabilize and starts to work correctly ??
Update: I had to wait just few minutes and now I have some values that sounds logical
What is U by the way reported by the sensor ??
Thanks
Update: I had to wait just few minutes and now I have some values that sounds logical

Thanks
Re: MHZ19 sensor working ??
Hi guys
I am just having the same issue :
Unstable reading, ignoring! PPM value: 715 Temp/S/U values: 21/0/0.00
I am running with v2.0.0-dev12. So I supposed that I have the B version of the sensor. Do you know if the modification has been implemented in the Dev 12 version or not ?
By the way, I've just received the sensor so what are you advising me with the ABC ? Should I disable it or leave it to normal ?
Many thanks
I am just having the same issue :
Unstable reading, ignoring! PPM value: 715 Temp/S/U values: 21/0/0.00
I am running with v2.0.0-dev12. So I supposed that I have the B version of the sensor. Do you know if the modification has been implemented in the Dev 12 version or not ?
By the way, I've just received the sensor so what are you advising me with the ABC ? Should I disable it or leave it to normal ?
Many thanks
Re: MHZ19 sensor working ??
The last version of the source in the V2.0 branch will have a fix for this.
And this will be released in dev-13.
You can also build yourself from GitHub and then also choose the mega branch, which will add even more filtering options.
About the ABC.
If you just connected the sensor for the first time (within 24h of operations), I advice you to set ABC disabled.
Then you can see if the room will be ventilated enough (reaching close to 400 ppm), based on the factory calibration.
ABC enabled (the default) will ruin this option, since the sensor will set the lowest measured value as being 400 ppm and if you're not ventilating enough, then the values shown will be too low after a while.
And this will be released in dev-13.
You can also build yourself from GitHub and then also choose the mega branch, which will add even more filtering options.
About the ABC.
If you just connected the sensor for the first time (within 24h of operations), I advice you to set ABC disabled.
Then you can see if the room will be ventilated enough (reaching close to 400 ppm), based on the factory calibration.
ABC enabled (the default) will ruin this option, since the sensor will set the lowest measured value as being 400 ppm and if you're not ventilating enough, then the values shown will be too low after a while.
Re: MHZ19 sensor working ??
That is a very usefull answer thank you very much !!!TD-er wrote: ↑10 Dec 2017, 18:44 The last version of the source in the V2.0 branch will have a fix for this.
And this will be released in dev-13.
You can also build yourself from GitHub and then also choose the mega branch, which will add even more filtering options.
About the ABC.
If you just connected the sensor for the first time (within 24h of operations), I advice you to set ABC disabled.
Then you can see if the room will be ventilated enough (reaching close to 400 ppm), based on the factory calibration.
ABC enabled (the default) will ruin this option, since the sensor will set the lowest measured value as being 400 ppm and if you're not ventilating enough, then the values shown will be too low after a while.
Stupid me, I did not think about the mega branch... Now I just have to figure out why I can't compil it with the Arduino IDE...

Thanks !!!
Re: MHZ19 sensor working ??
As a follow up, it is working like a charm.
I do have another problem but I'll open a new topic
I do have another problem but I'll open a new topic
Who is online
Users browsing this forum: Bing [Bot] and 0 guests