MH-Z14 NDIR Infrared gas module is a common type, small size sensor, using non-dispersive infrared (NDIR) principle to detect the existence of CO2 in the air, with good selectivity, non-oxygen dependant and long life.
MH-Z14 has a PWM output, with a sensitivity range of 0ppm to 2000ppm CO2, an accurancy of ±200ppm.
The cycle is 1004ms±5%, given the duty cicle Th (pulse high), Tl is 1004-Th, we can convert it to CO2 value using the formula:
CO2ppm = 2000 * (Th - 2ms) /(Th + Tl - 4ms)
This library read PWM output, and convert it to CO2ppm.
This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 8MHz
Code
Notes
- read risk disclaimer
- excuse my bad english
This comment has been removed by the author.
ReplyDeleteHello Davide, I like ur blog :D, well I have a question for mh z14, how I calibrate this sensor for 0 to 5000 ppm? Thanks for read This :)
ReplyDeleteHello, and thank you for your feedback. By datasheet this sensor has a resolution ratio of 5ppm between 0̚ and 2000ppm, 10ppm between 2000̚ and 5000ppm, 20ppm between 5000̚ and 10000ppm. If you would like to check the resolution ration, or to improve the calibration, you have to correlate this sensor to a accurate sensor. Basically you get data from your prof sensor against this sensor, then you take out a correlation curve. Once you get this curve, you can corretale any value you get from this sensor the the correlated value, imposing an offset or a gain correlation factor.
DeleteHello i have a question which controller are you using is it micro controller or NI elvies and can we used as NI ELVIES
ReplyDeletethan you
I'm using an Atmega8, reading the PWM output from the sensor with this MCU.
DeleteThis comment has been removed by the author.
ReplyDeleteDear Mr. David,
ReplyDeleteI have read there are two ways UART and PWM that the sensor can be used in arduino. in documentation, it should be used logic level converter at UART mode. I have doubt should we use level converter for the PWM pin at PWM mode?
thanks.
Hello, I use PWM mode using just PIN 12, but my code is avrgcc plain, I don't use the Arduino framework.
Delete