I'm aware that there are a lot of LM35 topics, but I have not been able to find a solution for my specific situation. It doesn't help that I'm quite new to electronics development.
I have tried different methods of wiring the LM35(DZ) to the Arduino.
- When I just connect +5V, GND and A0, my readings are all over the place. I get readings, but also a lot of 0 values. Vout is giving me about 2 mV on the multimeter.
- I tried adding a 100K resistor between Vout and GND (as seen in different topics) but that did not help. Vout becomes 0mV.
Any ideas?
I used this code:
/*
The simplest LM35 Thermometer
*/
const int analogIn = A0;
int RawValue= 0;
double Voltage = 0;
double tempC = 0;
double tempF = 0;
void setup(){
Serial.begin(9600);
}
void loop(){
RawValue = analogRead(analogIn);
Voltage = (RawValue / 1023.0) * 4870; // 5000 to get millivots.
tempC = Voltage * 0.1;
tempF = (tempC * 1.8) + 32; // conver to F
Serial.print("Raw Value = " ); // shows pre-scaled value
Serial.print(RawValue);
Serial.print("\t milli volts = "); // shows the voltage measured
Serial.print(Voltage,0); //
Serial.print("\t Temperature in C = ");
Serial.print(tempC,1);
Serial.print("\t Temperature in F = ");
Serial.println(tempF,1);
delay(500);
}
If correctly connected pin1->5V, pin3->GND... and you get 0V @ pin2 (in room temp) => defective sensor
Pin 1 is left when seeing flat side, pins down.
knut_ny:
If correctly connected pin1->5V, pin3->GND... and you get 0V @ pin2 (in room temp) => defective sensor
Pin 1 is left when seeing flat side, pins down.
I have wired it correctly.. Strange thing is that I have three LM35's, and none of them is working.
And should I measure pin 2 voltage against GND? When I measure against pin 1 I do actually get a voltage.
output voltage if ref. to ground (Upin2 -> Upin3)
I can agree that three defectives seems odd, but theese are 'straitforward' and shouldn't give you problems!?
try
// test LM35
// put sensor, face away from arduino board, at pins A0..A2
void setup()
{
pinMode(A0, 1); pinMode(A2, 1);
digitalWrite(A0, 1); digitalWrite(A2, 0);
Serial.begin(9600);
}
void loop()
{
Serial.println(analogRead(1));
delay(999);
}
Thanks, I'm getting a voltage on pin 2 now with your code. Apparently the wiring/breadboard is interfering in some way.
The voltage/temp on pin 2 keeps fluctuating a lot though (between 13-40 degrees C), and it's not usable.
BTW, when measuring with the multimeter (red on pin 2, black on pin 3), I'm getting a negative voltage on pin 2, which I don't understand?
Try change the analog reference to EXTERNAL - and connect 3v3 to the A-ref-pin.
If this helps (a little) I suspect your 5V supply has a lot of noise.
(the neg. voltage ??? - fuc.... sensor)
Hi reynard80
I'm having exactly the same issues as you're experiencing. My lm35 readings are all over the place, I posted a thread and it contains a serial logger plot chart so you can see the rising and falling of the output voltage. I have a pack of lm35's being delivered today so hopefully I'll get one working.
Someone also pointed out to me that it might be noise or even mains hum, but my Arduino is powered from the USB on my MacBook, so I'm not sure why that might be happening. Maybe I should look to power the Arduino with some external power supply!
Hope you manage to sort it.
Thanks all for the replies. I still haven't been able to get the LM35 working. I have decided to use DS18B20s instead. Those are working fine now!
reynard80:
Thanks all for the replies. I still haven't been able to get the LM35 working. I have decided to use DS18B20s instead. Those are working fine now!
I discovered that the LM35 supplied with my starter kit was faulty. I bought a pack of 5 from elsewhere and it worked perfectly. You might have a dead LM35?
theMusicMan:
I discovered that the LM35 supplied with my starter kit was faulty. I bought a pack of 5 from elsewhere and it worked perfectly. You might have a dead LM35?
That's what I was thinking. But initially I had three units non-working. Having them ordered in China, I suspected they might be rejects or something, so I ordered a few from a reputable local source. These had the same problematic behaviour though. Still not sure what the problem is, but I seem to like DS18B20s better anyway.
As long as you're up and running that's the main thing.