 I have a sensor which states that operating voltage is 0 - 4 VDV and the output is 0 - 2000ppm. From your reply it is ated as follow:

``````Y = U/4*FS
float milliVolts = analogRead(A0) * 4.8828125;  // * 5000/1024
int PPM = milliVolts /4 * 2;  // 2 iso 2000  => millivolts to volts again.
``````

If I have a situation of 2000 ppm, does the analogread() give a reading of 1024? If so, the ppm will be greater than 2000, i.e analogread(A0)=1024 milivolts = 1024*5000/1024=5000 ppm =5000/4*2=2500? Thank you

and the output is 0 - 2000ppm

The unit of ppm is not an output value, I have never seen it in this context saying 0 to 2000 ppm makes no sense at all. It is normally used as a tolerance figure.

If I have a situation of 2000 ppm, does the analogread() give a reading of 1024?

This makes no sense.

The analog read reads voltages, when the voltage input equals or exceeds the reference voltage you will get a reading of 1023.

What is the output voltage range of your sensor?

Elektrix

Do you have a link to a datasheet for that sensor? Much better to start with known facts and data.

Lefty

I have a similar sensor as this “If 0V is 0ppm and 4V is 2000ppm and the device is linear and are using the standard 5V analog reference, then:
ppm = (analog_reading * 2000 * 5)/(1024 * 4)”
From the REFERENCE is state that : analogread(A0) will return from 0 to 1023, depending on response from the sensor. From what I understand, when the concentration is 2000 ppm, the voltage is 4 V and analogread() will give a value of 1024. So let substitute the value of analog_reading with 1024 at 2000 ppm.
ppm = (102420005)/(1024*4)
= 2500 ? - confused!

retrolefty: Do you have a link to a datasheet for that sensor?

So lets take that as a no.

@mohdrais - you told us that already, repeating nonsense does not make it any more sensible. PPM stands for parts per million, it is not a reading it is an accuracy. You will only ever get a reading of 1023 for a voltage at or above the voltage reference.

when the concentration is 2000 ppm, the voltage is 4 V and analogread() will give a value of 1024

AH the word concentration so this is some sort of a gas sensor?

So no, if the voltage is 4V the reading you will get is ( 1024/5 ) * 4 = 819

The Arduino can know nothing of what that voltage stands for unless you tell it. By the way gas sensors are very non linear and almost impossible to calibrate.

Thank you for the answer. Maybe I get confused with the return value of analogread(). I am right for me to assumed that for 5V, analogread() will return values from 0 - 1024 and when the reference volt is 4, the analogread() will return 0 - 819? Attached is the user manual for the sensor

Users Manual.pdf (132 KB)

I am right for me to assumed that for 5V, analogread() will return values from 0 - 1024

close the reading will be between 0 - 1023.

and when the reference volt is 4, the analogread() will return 0 - 819?

No, the same 0 to 1023. The reference voltage is not the input voltage. With an input voltage of 4V and a reference voltage of 5V you will get a reading of 891.

I think you are not understanding what a reference voltage is. The arduino has a reference of 5V unless you switch it to external in software and then put a voltage into the Vref pin. If so that voltage becomes the reference voltage.

Thanks for the manual. Once you get a voltage reading you convert that reading into a concentration value by applying the graph on page 5 of the sheet

Tha user manual says:

Relationship between concentration and voltage output is linearity: Y=U/4 * FS Y is the CO2 concentration (ppm); U is voltage, units of V; FS is full scale, unit of ppm (2000ppm or 5000ppm).

You have indicated that your unit is 2000ppm full scale. Therefore, Y = U/4 * 2000ppm, where U is the output voltage. But U = (A * Vref)/1024, where A is the value returned by analogRead, and Vref is the analog reference voltage. So Y = (A * Vref * 2000)/(1024 * 4) ppm. If Vref is 5V, we get Y = (A * 10000)/(1024 * 4) ppm. Eliminating the common factor, this yields:

Y = (A * 625)/256.

Two words of caution:

1. To evaluate this, you need to use unsigned long arithmetic or floating point arithmetic. If you use ordinary integer arithmetic, the multiplication of A by 625 will overflow for readings above about 128ppm.

2. The 5V supply is not a very accurate or stable reference, especially if you are using USB power. Consider using a precision 4.096V voltage reference for Vref instead.