# How to make formula for my analog sensor

Hi,

I have analog temp sensor. It gives ouput in between 0 and 5 Volts.

In data sheet i found:

If sensor Output is 0v then temp would be -40 Degree.
If sensor Output is 5V then temp would be +60 Degree

How can i make a Formula to get the temperature.?

Thank you

(deleted)

The map(...) function maps integers. The analogRead(...) function provides integers, but asifsaeed999 did not tell us what Arduino, did not tell us about any other circuitry, and did not tell us what integers would be produced by the analogRead(...) function. The integers from the analogRead(...) function should be used or something similar to the map(...) function used but with the int variables replaced by double or perhaps float.

@vaj4088

Thank you.

I am using analogRead(). I am getting raw value e.g 608. I am converting it back

voltage = (5/1023)*608 = 2.96v

Now i know that my sensor analog Output could be 0 to 5V. In data sheet i have found

at 0V temperature would be -40
at 5v temperature would be +60

i am using map function

temperature = map(voltage,0,5,-40,60)

i am getting the wrong value ,the reason could be i am maping voltage which is double not integar. M i Right??

Thank you.

(deleted)

Uh, no! You are attempting to map voltages and not ADC readings. Try

``````temperature = map(analogRead(0),0,1023,-400,600)/10 ;
``````

Notice the change from 5 to 1023.
Superfluous parentheses removed.

(deleted)