Starting with Arduino. Attempting to read temperature via a LM35 sensor.
Readings appear way high or way low with current set (image attached).
Ambient temp. in my location is about 25-35 deg.C range
LM 35 connected to A2. 5V reference used.
Output, code and picture of connection attached.
Sensor seems fine. It responds to higher and lower temperatures. I tested by having the sensor close to ice and close to warm food
Other attempts made: Tried connecting sensor to A0. Tried with voltages of 5V, 3.3V. All failed to give reasonable readings.
I also read A0 with NOTHING connected, and it seems to read in something, is this normal?
To me everything appears correct. The connections, the code and conversion - yet after repeated attempts, the temperature reading is not coming out right.
Please help.
Serial output: Note sensor connected to A2. A0 nothing connected
Sensor [A2]: 161 units | Sensor [A0]: 208 units | Temp.: 7.87 deg.C
Sensor [A2]: 161 units | Sensor [A0]: 208 units | Temp.: 7.87 deg.C
Sensor [A2]: 161 units | Sensor [A0]: 208 units | Temp.: 7.87 deg.C
Sensor [A2]: 162 units | Sensor [A0]: 208 units | Temp.: 7.92 deg.C
Sensor [A2]: 162 units | Sensor [A0]: 208 units | Temp.: 7.92 deg.C
The only time it appeared close to real temps. is with I used 3.3V Vcc and the following formula. But is this correct? I doubt the line where I set "referenceVoltage = 3.3;"
Consult the LM35 data sheet. It is not guaranteed to run on less than 4V.
The sensor output for the type of connection you have is 10 mV per degree C, in the range of 2 to 150 degrees C. The overall calibration will depend on the ADC reference voltage. So, make sure that you understand how to read a known voltage (like a 1.5 V AA battery) with the ADC, before trying to read the LM35 voltage. A multimeter is handy to check everything.
Unconnected ADC inputs read voltages that vary randomly.
Incidentally - I used the other bit of knowledge from your response (i.e. the full range of 2 to 150 deg. C) to create a linear relation (between this and 0 to 5 V) and it gives me reasonable readings of temperature! But I doubt I have to do this. All data sheets say - one has to simply use the 10 mV/C relation
Linear relation between temp. and voltage:
5 V = 150 oC, 0 V = 2 oC, slope = (150-2)/(5-0) = 29.6 and intercept = 2.0
Please, always post ALL the code you are using, with code tags.
If the "sensorValue" ADC reading really is 163, and you really are using 5.0 V as the ADC reference, then that converts to 0.797 volts, which is indeed way too high.
Use your multimeter to check the ADC input voltage (that is, the sensor output voltage), to see if it really is 0.797 volts.
You could try putting it in melting ice.
If you get ~500mV, you can be sure it's the LM36.
The LM36 has the same resolution as the LM35. 10mV/degreeC.
The only difference is a 500mV offset.
The LM35 can only measure positive temps (without additional tricks), while the LM36 also can measure temps below zero (~-40C).
It should be easy to add that offset in software.
Leo..
Hey Jimbo - I had actually ordered a DHT11 too with the LM35s!
It's expensive (considering I am in India) and I just want to make sure I have a handle on this with the cheaper LM35s and not blow this sensor too :-[
But at one point I do want to try it - I also have an Arduino Ethernet shield ordered in my first purchase. My intention is to eventually build a small web-based project with temp. and humidity readings.
Did you already measure the sensor in melting ice.
As said, it could be the LM36.
I consider the LM36 "better" than the LM35.
It has a wider temp range without using negative voltage "tricks".
With the LM36, -50 degrees C is 0volt, zero degrees C is 500mV. And 1000mV (1volt) is 50 degrees C.
With 1.1volt Aref, you have a digital resolution of 0.1degree C, and a range of about -40 to +60 degrees C.
Leo..
I ordered LM35s. The packet said LM35. It looked 100% like an LM35. But yesterday, I tried to read the inscriptions under strong light and it was still difficult to read what it was.
I took a 16 MP camera and took a picture and zoomed it out - it is a MCP9700!!!
I read the data sheet and Leo, like the LM36, this too had an offset that I programmed into my code and it worked!!
Thank you everyone. Apologies if I wasted your time.
I learnt a lot of lessons in my first small project. Thanks to JRemington, Leo (Wawa) and Larry D
Leo- I will take your advice when I have to build something for a better cause. This is just my learning phase.