Hello to everyone,
I am using a sensor connected to adc1 channel of ads1115. Data of ads11115 is received at ESP32. Output of sensor is 0.4 Volt to 2.0 Volts for 0 to 250 ppm. I am using the following code
I am expecting values according to the value of input volts.
But in serial monitor values are as -
0 for 0.4 Volt to 0.99 Volt
125 for 1 Volt to 1.99 Volts
250 for 2 Volts
I would be very thankful for any help.
Now my program is printing desired values in serial monitor.
I would like to discuss one more point.
In the meanwhile, I have derived a relation to calculate sensor value as- Sensor Value = ( Vf-V0) X 156.25, Where V0 is initial voltage i.e. 0.4V and Vf is voltage at considered point. Putting this relation in logic is also giving accurate readings. Please tell what should be used function mapf or this relation ? I am very thankful for your kind support.
I am uncertain of your question. Use formula that gives your program more control: Vf - V0 (difference) or map(sensor, minIN, maxIN, minOUT, maxOUT); Post your new code here for better understanding.
You have a voltage span of 2.0 - 0.4 = 1.6V with a zero offset of 0.4V, subtract the offset and you have a voltage span of 0 to1.6V = 0 to 250 PPM. so:
Sorry, perhaps I was unable to explain.
I have two options for achieving sensor readings as-
Using SensorValue = mapf(volts1, .4, 2, 0, 250);
Using SensorValue = ( Vf-V0) * 156.25 ; Where V0 is initial voltage i.e. 0.4V and Vf is voltage at considered point.
Both are giving accurate readings.
My question is that which option is better.