I have been trying to build a simple thermometer circuit using Arduino uno and LM 35 temperature sensor , the code i wrote is:
int pin_val = 0 ;
float tempC = 0.0 ;
float voltage ;
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
void loop() {
pin_val = analogRead(0);
voltage = (pin_val * 5.0) / 1023.0; // reading the voltage
tempC = (pin_val * 5.0 * 100.0) / 1023.0; // reading the temperature in C
// print out the value you read:
Serial.print(voltage);
Serial.print(" V");
Serial.print(" ");
Serial.print(tempC ,1);
Serial.println(" deg C");
delay(500);
}
when i upload it to arduino it first work fine in measuring room temp and it swings between 21 to about 26 degrees . but strange things would happen when i try to heat it up or to cool it down.
when i try to cool it through a fan , the temp sharply decreases to about 5 to 7 degrees , i don't know if this is normal .
the bigger problem is that when i heat it up , the temp would never exceed 29 or 30 degrees , i tried to heat it up using heater , my fingers , lighter ... and the reading would never change .
I ve tried to change Vref to 1.1 V and still no change. any suggestions to solve that problem. thanks so much .
Wawa:
If that doesn't work, try to measure the voltage on the output of the LM35 with a DMM.
Should be 10mV/degreeC, so 25C is 250mV.
Leo..
Hi Wawa thanks for the reply , actually i have changed the baud rate to 115200 , changed Vref to 1.1 V , still i get the the same results , the reading won't exceed 29 or 30 degrees C even if it get hot. when i tried to measure Vout with DMM , the output voltage becomes 0.0 C and 0.0 V in both the serial monitor and the DMM as soon as i connect the DMM leads to Vout and GND .
Wawa:
e.g. a common problem is a breadboard with interrupted ground/supply rails.
Leo..
I tried to connect it directly to Arduino board without a breadboard using 3 female-male jumper wires (for Vcc , Vout , gnd) and i get the same results , it's strange that when i heat it up with the lighter very close to it , and it becomes hot, then the reading would be decreased to about 6 degrees which is absolutely wrong. any other suggestions please .
should i buy another LM 35 ? or still there's hope
WalidJ:
I tried to connect it directly to Arduino board without a breadboard using 3 female-male jumper wires (for Vcc , Vout , gnd) and i get the same results , it's strange that when i heat it up with the lighter very close to it , and it becomes hot, then the reading would be decreased to about 6 degrees which is absolutely wrong. any other suggestions please .
should i buy another LM 35 ? or still there's hope
If you're 100% sure you're connecting it correctly, and the sensor's output is definitely connected to analogue pin A0 as in the code, then if I were you I'd be trying another sensor.
This is a good reason to buy more than 1 of parts like this. I try to buy at least two of everything, and usually more.
Also, I see that you still didn't go back and edit your original post to place the code between code tags. So easy, yet you totally ignored the suggestion in reply #2. Have some consideration for those that want to help you, and do things the right way.
A picture was requested.
So you're sure this is an LM35 or TMP35.
And you never connected the chip backwards.
And you never heated it above 200C with your lighter.
And connected it right.
When you hold the chip with the pins down, facing the writing, ground pin is on the right and Vs is on the left.
Leo..
Wawa:
So you're sure this is an LM35 or TMP35.
And you never connected the chip backwards.
And you never heated it above 200C with your lighter.
And connected it right.
When you hold the chip with the pins down, facing the writing, ground pin is on the right and Vs is on the left.
Leo..
it's LM35 DZ sensor , and I connected it right , first through a breadboard , then without a breadboard directly through jumper wires , and i get the same results. can i judge that the sensor has a problem and should be replaced ? does this normally occurs for sensors of this type ?
WalidJ:
Is this a good sensor to buy? or may be there are better temp sensors with better precision and performance ?
I'm sure that there are even more accurate sensors than the LM35, but they're fine. I've only used the LM35 and LM335Z, and haven't found them lacking.
If you're just making a "simple thermometer circuit" as you said in your initial post, you don't need anything better.
OldSteve:
If you're just making a "simple thermometer circuit" as you said in your initial post, you don't need anything better.
I will order some other LM 35 sensors , hope they will be ok.
by the way , did you lm 35 sensor read high temps such as 60 or 70 or even 90+ degrees C Steve ?
WalidJ:
I will order some other LM 35 sensors , hope they will be ok.
by the way , did you lm 35 sensor read high temps such as 60 or 70 or even 90+ degrees C Steve ?
According to the National Semiconductor datasheet:-
LM35: -55°C to 150°C
LM35A: -55°C to 150°C
LM35C: -40°C to 110°C.
LM35D: 0°C to 100°C.
Temp range depends on the code, and how you connect the sensor.
With just +5volt, ground, and output to an analogue input, and the code from post#0, sensor range is about 5C to 150C. Lower temps require extra parts and the use of two analogue inputs.
Resolution (temp steps) is not very good (~0.5C/step) with the simple code from post#0.
The code I linked to in post#2 has slightly less range (~5 to 105C), but a better resolution, and is more stable.
If you want to measure below 5C, you could also use the TMP36.
Read the comments in the code I gave you.
Leo..
I have been trying to build a simple thermometer circuit using Arduino uno and LM 35 temperature sensor , the code i wrote is:
int pin_val = 0 ;
float tempC = 0.0 ;
float voltage ;
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
void loop() {
pin_val = analogRead(0);
voltage = (pin_val * 5.0) / 1023.0; // reading the voltage
tempC = (pin_val * 5.0 * 100.0) / 1023.0; // reading the temperature in C
// print out the value you read:
Serial.print(voltage);
Serial.print(" V");
Serial.print(" ");
Serial.print(tempC ,1);
Serial.println(" deg C");
delay(500);
}
when i upload it to arduino it first work fine in measuring room temp and it swings between 21 to about 26 degrees . but strange things would happen when i try to heat it up or to cool it down.
- when i try to cool it through a fan , the temp sharply decreases to about 5 to 7 degrees , i don't know if this is normal .
- the bigger problem is that when i heat it up , the temp would never exceed 29 or 30 degrees , i tried to heat it up using heater , my fingers , lighter ... and the reading would never change .
I ve tried to change Vref to 1.1 V and still no change. any suggestions to solve that problem. thanks so much .