I have this setup here (for more pictures):http://santiapps.com/?p=2483
Im using this code to map:
As I follow the analog readings with a voltmeter and onscreen, they look fine. I measured the voltage and got:
2.90V for room temp water
2.75V for water cooler water
3.90V for office hot coffee
At least the linearity exists and it is correlated in the right direction. The problem seems to be my mapping code. From what I’ve read 1V = 205 and 5V=1023. This code above I got from an online post and the OP mentions that he multiplies the 4/20 scale of -10 to 150C by 10 because map doesnt work well with floats.
The problem is that I was getting:
-27 for 2.90V for room temp water
-30 for 2.75V for water cooler water
-1.0 for 3.90V for office hot coffee
I modified the code to this:
and you can see the results here where I print out the analog value of 290 for room temp. So as arduino maps the 290 analog value to a scale that starts at 205, it must give a negative value because it has to go back from 290 to 205.
How can I fix this?