Arduino starter kit - Love-o-meter

Hi,

I received the Arduino starter kit for Christmas and am working my way through the projects book that comes with it. However, I am having issues with the Love-o-Meter project. I have setup the circuit and uploaded the code to the board as directed. However the serial output values I am getting are totally wrong, for example:

Sensor value: 949, Volts: 4.63, degrees C: 413.38
Sensor value: 942, Volts: 4.60, degrees C: 409.96
Sensor value: 946, Volts: 4.62, degrees C: 411.91
Sensor value: 948, Volts: 4.63, degrees C: 412.89
Sensor value: 942, Volts: 4.60, degrees C: 409.96
Sensor value: 947, Volts: 4.62, degrees C: 412.40

I am really unsure what it is I am doing wrong. Any help would be much appreciated. Code is pasted below.

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

void setup(){
  Serial.begin(9600);
  for(int pinNumber = 2; pinNumber < 5; pinNumber++){
    pinMode(pinNumber, OUTPUT);
    digitalWrite(pinNumber, LOW);
  }
}

void loop(){
  int sensorVal = analogRead(sensorPin);
  Serial.print("Sensor value: ");
  Serial.print(sensorVal);
  float voltage = (sensorVal/1024.0) * 5.0;
  Serial.print(", Volts: ");
  Serial.print(voltage);
  float temperature = (voltage - .5) * 100;
  Serial.print(", degrees C: ");
  Serial.println(temperature);
  
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);

  if(temperature >= baselineTemp + 2){
    digitalWrite(2, HIGH);
  }
  if(temperature >= baselineTemp + 4){
    digitalWrite(3, HIGH);
  }
  if(temperature >= baselineTemp + 6){
    digitalWrite(4, HIGH);
  }
  
  delay(1);
  
}

The sensor value and voltage conversion look fine. It's just the temperature conversion that looks wrong.

I don't have your kit so can only assume your 'sensor' is some kind of temperature sensor. The formula, (voltage - 0.5) * 100, looks wrong as you're only ever going to get something under 100 degrees if the raw reading is less than 1.5v.

To determine a correct conversion from analog value to temperature we need to know what the device is and how it is wired up. Is there a link to the tutorial with wiring diagram and code?

I don't know this project, but I guess it is using a thermistor / resistor pair as a voltage divider. In that case, one possible reason for the very high readings you're getting is that you have accidentally connected the resistor where the thermistor is supposed to go, and vice versa.

Did you ever figure it out? I am having a similar issue, but the values I'm getting are very low. They are also not very consistent. Sometimes the sensor value is 0 (sometimes 80). My touching the sensor (and supposedly warming it up) does nothing to affect the values. The sensor is a TMP36.

For what its worth, Adafruit has a tutorial on working with the tmp36 here: Overview | TMP36 Temperature Sensor | Adafruit Learning System

I am having the same problem with the temperature being to low. I think that the sensors that I have are not TMP36. The ones that I have do not say that on the side. They say this on the flat portion:

B347
B
-C28

Your code works for me

But, my thermistor is marked

TMP
36GZ
#1228
407596

The sort of values I'm getting are:

Sensor value: 153, Volts: 0.75, degrees C: 24.71
Sensor value: 153, Volts: 0.75, degrees C: 24.71
Sensor value: 152, Volts: 0.74, degrees C: 24.22
Sensor value: 153, Volts: 0.75, degrees C: 24.71
Sensor value: 153, Volts: 0.75, degrees C: 24.71
Sensor value: 153, Volts: 0.75, degrees C: 24.71
Sensor value: 152, Volts: 0.74, degrees C: 24.22
Sensor value: 152, Volts: 0.74, degrees C: 24.22
Sensor value: 152, Volts: 0.74, degrees C: 24.22
Sensor value: 152, Volts: 0.74, degrees C: 24.22

For what it's worth I had to hunt around for that thermistor, it's longer and thinner than the drawing in the book. I confused it with one of the other rounded components initially

Also had a problem of getting insanely high voltages from the temperature sensor. The problem was that the wire going to ground was not connected properly.

I'm getting ridiculously high values and its the exact same as the code at the top. No idea why.

Please help!

I had this problem too. Turns out I was not using the TMP36 like I thought I was. It's hard to tell from the book diagram and description which piece in your box is the TMP36. If you run into impossibly high yet consistent temperature readings double check that you are in fact using a TMP36.

Hi everyone,

I ran into a problem where my code has uploaded and everything seems to be connected but instead of lighting up after i touch the sensor. Once i plug in the power source all the LEDs are already lit.

I am not sure what happened here

Ladyp:
Hi everyone,

I ran into a problem where my code has uploaded and everything seems to be connected but instead of lighting up after i touch the sensor. Once i plug in the power source all the LEDs are already lit.

I am not sure what happened here

Check your room temperature, if it's above 26 degrees celcius, all the LEDs will light up according to your instructions. Try adjusting the value of the baseline temperature and see if it makes a difference.

I myself made a mistake in the program: the sensorPin was set to 40 instead of A0.
The effect was: sensor reading looked like a too high voltage/temperature.
A good advice for troubleshooting: disconnect the middlepin of the TMP36 temp sensor while watching the serial debug output. Does the reading change at all?

Had the same issue. Was getting way to high numbers. +50 degrees in my room :smiley:
Issue was that the connection from the tmp to the ground was not fully plugged in. Once I did that, the values seemed right.

Lesson learned!