5

I have this strange problem. My TMP 36 sensor works fine when it is the only thing connected to my Arduino Uno board. The voltage measurements, and thus the temperature, are accurate and consistent. However, when I attach an LCD screen to the Uno and have a program print the TMP's measurements to the screen, the values become inconsistent, and can change up to 10 degrees F from one reading to another. (I have the sensor take a measurement every second.) This does not happen when the LCD screen is not plugged in. I decided to remove separate connectors from the screen and see when the measurements became consistent again. I tried this once and found that a ground wire that goes to connection 5 on the screen caused to value to change when I repeatedly inserted and removed it from a ground pin. The TPM values were changing even when there was nothing else connected to the LCD (it wasn't on) except for the ground wire. I don't understand how this is possible, and I don't know if this is a hardware or software issue.

I rewired the LCD screen starting with sensor wires, then ground wires, and then the two 5V connections, with one of them having a 220 ohm resistor. I did this while the circuit was powered, and watched the values for any large changes. The first change was a few seconds after I wired the last 5V wire. The sensor measured 80 degrees F and then 85 degrees F one second later. It then went to 81 for a few seconds, then 87. The values continued to change, but not by as much as previous times. By the way, the temperature in the area that the Arduino is in is about 82 degrees F.

TMP values do not change by more than 3 degrees F when the LCD is not connected to the screen. I don't understand what could be causing this. Has anyone else had this problem before, or know the cause?

Here is the layout.

#include <LiquidCrystal.h>

LiquidCrystal lcd(12,11,5,4,3,2);
const int sensorPin = A5;
const float baselineTemp = 20.0;

void setup() {
  Serial.begin(9600);
}

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);
  Serial.print(", degrees C: ");
  float temperature = (voltage - .5) * 100;
  Serial.print(temperature);
  Serial.print(", degrees F: ");
  float fahrenheit = (temperature * 1.8 + 32);
  Serial.println(fahrenheit);
  delay(1000);
  lcd.begin(16,2);
  lcd.print(fahrenheit);
  lcd.print(" degrees F");
  float averageTemp;
  if(temperature < baselineTemp) {
    lcd.setCursor(0,1);
    lcd.print("Below room temp");
  }
}
  • 5
    You could have any of several issues: electrical noise, sagging power supply under load in a circuit which does not factor that out, or perhaps power consumption of the circuit (the majority of which will end up as heat) causing the assembly to heat a bit above ambient. Your question is not really answerable without precise details of your setup - schematics, part numbers, and physical layout. – Chris Stratton Aug 21 '16 at 23:11
  • Can you please try putting a Diode (like an LED) between them? That way you'll eliminate the possibility that the LCD may be back feeding. Can you also tell us what Temperature sensor you're using? I've done a similar project (with DS18B20) but it didn't cause funny readings ...... – Mero55 Aug 22 '16 at 7:25
  • I have added my code just in case, though I highly doubt it has anything to do with this. I will add the layout as well. – MICROexchange6 Aug 26 '16 at 16:20
  • Layout is in the post. – MICROexchange6 Aug 26 '16 at 19:19
  • Your "layout" is nearly uninterpretable, but try giving the temperature sensor its own leads to the power supply so it does not share with the LCD, and add some bypass capacitors. – Chris Stratton Aug 26 '16 at 20:37
2

Don't take power for LCD from Uno pins. Connect LCD power to separate power source.

  • +1, Useful suggestion b/c TMP 36 is an analog sensor and power supply noise or sag would affect the reading. Why the drive-by downvote, @someone? – JRobert Aug 28 '16 at 12:03
  • I didn't downvote but this isn't a complete answer at all. It's just general advice without any reasoning written in. It should explain why the LCD power should be from a separate power source, and how it relates to the question. – redstarcoder Jan 25 '17 at 19:03
2

For an analog sensor like the TMP36, the Arduino uses the 5V as reference. If the 5V changes (but the TMP36 voltage stays the same), the Arduino thinks that the temperature has changed. The value returned by analogRead() increases. That is why the temperature seems to raise if the 5V is lowered.

The TMP36 (with resistor) outputs a certain voltage. That is different from 'ratiometric' sensors, they output a voltage relative to the 5V, and changes to the 5V have no effect on the result. A 'ratiometric' sensor is for example a wheatstone bridge, or a LDR with resistor.

With the TMP36, you need a good voltage reference to read the actual voltage. The internal voltage reference can be used. Perhaps an extra voltage divider is needed. Or use a power supply to the power barrel jack and let the onboard voltage regulator create a fixed voltage of 5V which can be used as reference.

When using digital temperature sensors, like the DS18B20, all these problems are gone instantly.

The 5V should never be connected to AREF. It is already internally connected to VCC at default, and when the internal voltage reference is selected, the AREF pin changes the voltage. In that case, an internal shortcut is created when AREF is connected to 5V. There is no need to add 100nF to AREF, since the Arduino Uno has already 100nF to AREF and GND.

A breadboard can have bad contacts. Since the current of the LCD uses the same GND and +5V wires, it can have influence on the TMP36. It is better to use seperate wires as already mentioned by Chris Stratton. To reduce noise you could take a number of analogRead() values and use the average. For an analog temperature sensor it is common practice to average a number of samples.

0

I don't see +5v -> Aref (and Aref -> bypass capacitor -> Gnd). Necessary, if you are using the power supply voltage as a reference, as you appear to be.

0

Try powering your circuit using a 9V battery. I have also had this problem and it worked when I used a separate power supply. It seems to be an electrical noise caused by your computer USB. The answer posted by JRobert should be necessary if you want to power from the computer.

0

I had this issue and put a 0.1 µF capacitor across the sensor and got much reduced noise (to within half a degree which is really +- one tick).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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