enter image description hereMy son just did the Love-o-meter project in the Arduino Start Kit. However, the sensor readings of the LM35 temperature control vary widely. Below is a sample. What could be wrong?

Sensor Value: 217, Volts: 1.06, degrees C: 105.96
Sensor Value: 587, Volts: 2.87, degrees C: 286.62
Sensor Value: 125, Volts: 0.61, degrees C: 61.04
Sensor Value: 320, Volts: 1.56, degrees C: 156.25
Sensor Value: 445, Volts: 2.17, degrees C: 217.29
Sensor Value: 141, Volts: 0.69, degrees C: 68.85
Sensor Value: 510, Volts: 2.49, degrees C: 249.02
Sensor Value: 247, Volts: 1.21, degrees C: 120.61
Sensor Value: 168, Volts: 0.82, degrees C: 82.03
Sensor Value: 595, Volts: 2.91, degrees C: 290.53
Sensor Value: 125, Volts: 0.61, degrees C: 61.04
Sensor Value: 206, Volts: 1.01, degrees C: 100.59
Sensor Value: 606, Volts: 2.96, degrees C: 295.90
Sensor Value: 125, Volts: 0.61, degrees C: 61.04
Sensor Value: 290, Volts: 1.42, degrees C: 141.60
Sensor Value: 487, Volts: 2.38, degrees C: 237.79

Here's the code:

const int sensorPin = A0;
const float baselineTemp = 25.0;

void setup(){
  Serial.begin(9600); // open a serial port
  for(int pinNumber = 2; pinNumber<5; pinNumber++){
    digitalWrite(pinNumber, LOW);

void loop(){
  int sensorVal = analogRead(sensorPin);
  Serial.print("Sensor Value: ");
  // convert the ADC reading to voltage
  float voltage = (sensorVal/1024.0) * 5.0;
  Serial.print(", Volts: ");
  Serial.print(", degrees C: ");
  // convert the voltage to temperature in degrees
  float temperature = (voltage) * 100;

  if(temperature < baselineTemp){
    digitalWrite(1, LOW);
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
  }else if(temperature >= baselineTemp+2 &&
    temperature < baselineTemp+4){
    digitalWrite(1, HIGH);
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
  }else if(temperature >= baselineTemp+4 &&
    temperature < baselineTemp+6){
    digitalWrite(1, HIGH);
    digitalWrite(2, HIGH);
    digitalWrite(3, LOW);
  }else if(temperature >= baselineTemp+6){
    digitalWrite(1, HIGH);
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);

The GND is connected to the left most connector in the LM35, the A0 to the middle, and the power to the right most connector.

  • Maybe you mistyped the code? Didn't wire correctly? We need more information.
    – Nick Gammon
    Aug 4, 2017 at 7:54
  • 1
    Either the person can't decide if they are in love or not, there is a problem with the power supply (is it a battery?), there is some dodgy wiring, you are reading the values too fast or there is a bad earth. Is it possible to post your code and a photo of your setup? Aug 4, 2017 at 7:54
  • A link to this project would help, or copy and paste the code.
    – Nick Gammon
    Aug 4, 2017 at 7:56
  • Point 1 - Don't use D0 and D1 (the first two), because they are the Rx and Tx ports for the serial line, at best the it won't work. Aug 4, 2017 at 9:08
  • 1
    Looking at ti.com/lit/ds/symlink/lm35.pdf (page 3, LP package) and the way the sensor is facing in the picture, the pinout is 5V, Signal, GND, but you switched 5V and GND? (in this case of reverse polarity you have probably burned out your sensor already.) Aug 4, 2017 at 15:52

1 Answer 1


I've had a look round and spotted this:


In summary it says that the fault maybe that the Arduino's 5V isn't stable enough, so you need to decouple it. For once it seems that running from batteries may have been a better idea.

I've also seen posts saying there should be a 500Ohm resistor between the Ground of the LM35 and Ground. Apparently it says 499Ohm on the datasheet.

And as a final resort I saw said that the 'Data Direction Register' influenced the analog pins. If it was set to digital output this could lead to unstable readings for the ADC. Basically it implied you needed to set the analog pin's to pinMode (A0, output). But I really don't think this will work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.