# Arduino and LM35DZ Centigrade thermistor.

Ok I can't figure out what im doing wrong here. I have this thermistor on a bread board I have +5v from arduino going to the +Vs I have Vout going into the Arduino analog port A0 and the ground going to arduino's ground. Here is the data sheet for the LM35DZ (http://www.ti.com/lit/ds/symlink/lm35.pdf). Here is the Code I am using to see the output.

int SensorPin =A0; int Temp =0;

void setup() { Serial.begin(9600); }

void loop() { int Temp = analogRead(SensorPin); Serial.println (Temp); delay (600); }

Here is what I get back.

53 52 53 52 52 52 52 52 52 53 52 52 52 52

What am I doing wrong? Im just confused because a few hours ago I was working on this and it was about 65 degrees F in here and my reading was 64-63 and now Im still messing with it trying to figure out what is going on 4 hours later it is 53 degrees F roughley and It's reading this. It is like the V out is being converted to fahrenheit or something.

the LM35 output is 10mV per degree C. You are displaying the raw value you read, and not converting it first.

``````  int Temp = analogRead(SensorPin);
``````

should be something like:

``````  int Temp = analogRead(SensorPin) * 500 / 1024;
``````

or

``````  int Temp = (analogRead(SensorPin)  * 900 / 1024 ) + 32;
``````

for Fahrenheit That is a rearrangement of * 5 / 1024 * 100 and (* 9 / 5) + 32

• 5 / 1024 gives the actual voltage on the pin.
• 100 converts that to the number of 10 mV steps (* 9 / 5) + 32 converts C to F if desired

Note: as wired, you cannot measure less than 0c Note: change 5 in the above formulas if the arduino is changed from running at 5v.

Hey thanks for the response I have no idea where you are getting the number 1024. I took the code you gave me and put it in like this.

int SensorPin =A0; int Temp =0;

void setup() { Serial.begin(9600); }

void loop() { int Temp = (analogRead(SensorPin) * 900 / 1024 ) + 32; //int Temp = analogRead(SensorPin); Serial.println (Temp); delay (600); }

Now my output in the serial monitor is around 13 or 14. and My Vout is .25v ( on my multi- meter) I assume the /1024 has something to do with the resolution on the analog header but my mind cant grasp why I would divide it by the total resolution.

int SensorPin =A0; int Temp =0;

void loop() { int Temp = (analogRead(SensorPin) * 900 / 1024 ) + 32; //int Temp = analogRead(SensorPin); Serial.println (Temp); delay (600); }

It shouldn't matter, but you are defining Temp twice. Remove the "int" before Temp = in the loop.

Now my output in the serial monitor is around 13 or 14.

I'm not sure why that is yet.

My Vout is .25v ( on my multi- meter)

Is your room 25C (~80F) ?

Your above readings of 52-53 also equate to ~.25v. 52 * 5 / 1024 = ~.254