I have this setup here (for more pictures):Arduino IoT: RTD PT 100 Sensores Industriales Parte I – Santiapps – Arduino, Raspberry Pi, Python, Internet Of Things, IoT, iOS, Android
Im using this code to map:
temperature=map(sensorValue,205,1023,-500,1500);
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:
temperature=map(sensorValue,205,1023,-50,150);
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?