PWM to Voltage Conversion using Arduino

HI
i am new here
i have sensor MH-Z16 which has output of PWM of 1 hz and cycle time is 1004 ms
can someone guide me how to convert signal PWM to voltage output using arduino
Thanks In advance

No... The Arduino doesn't have an analog output. And, PWM is a "difficult" format to read. PWM can be filtered to varying DC with a low-pass filter.

harjotsira66:
HI
i am new here
i have sensor MH-Z16 which has output of PWM of 1 hz and cycle time is 1004 ms
can someone guide me how to convert signal PWM to voltage output using arduino
Thanks In advance

Hi,
Welcome to the forum.
Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html
PWM has a frequency and a duty cycle.
So what is its frequency?
What is it duty cycle, or ON and OFF times?
Thanks.. Tom... :slight_smile:

You can use the function pulseIn to measure the width of the pulse from the sensor.

This will give you the width of the pulse in micro seconds, divide this by 1000 to get milliseconds, and use the formula given in the datasheet to calculate CO2 concentration.

Looking at the datasheet for the sensor, it appears to have an analogue output and a UART output as well as the PWM output.

You could read the analogue output directly from an Arduino Analog Input.

There have been a couple of recent threads about using this sensor which you might find interesting.

Datasheet mentions indeed analog signal output, but reading a bit further it says:

Vout (0.4~2V,custom made)

which to me implies that not all sensors have this option.

Anyway, the sensor also has UART output, and all of them seem to have that (no "custom made" mark there) that's a lot easier to read with an Arduino than a PWM signal. I'd go for that, then if you must have an analog voltage output indeed PWM output + low pass filter. That should be able to provide a few mA of signal.

Hi,
The PWM output diagram.
pwmoutput.jpg

Frequency = 1004mS Period.
Don’t you hate data sheets that don’t conform to standard terms, yet they have the capacity to make these sort of devices?

Tom… :slight_smile: