I am trying to set up a simple tmp36 temperature sensor using arduino uno & breadboard. Temp reading is displayed on an LCD. The sketch works fine when connected via USB cable to my PC and shows the correct temp. for example output shows .72 volts & 21.78 degrees C.
However when I disconnect the USB cable & plug in a battery pack to power the uno (4 x AA rechargeable, voltage out from the battery pack is reading 5V on my multimeter) the reading from the tmp36 changes (now showing 1.06V & 56.45 degrees C). Plug the USB cable back in & it goes back to the correct reading.
To minimise power draw the LCD is not using the backlight.
Does anyone have any idea why this is happening ? The documentation for the tmp36 says "Just give the device a ground and 2.7 to 5.5 VDC and read the voltage on the Vout pin. The output voltage can be converted to temperature easily using the scale factor of 10 mV/°C."
thanks.
int tempPin =1;
int tempReading;
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(13, 12, 5, 4, 3, 2);
void setup() {
// setup LCD's number of columns and rows
lcd.begin(16, 2);
}
void loop() {
lcd.noBlink();
tempReading = analogRead(tempPin);
float voltage = tempReading * .004882814;
float temperatureC = (voltage - 0.5) * 100;
lcd.clear();
lcd.print(temperatureC);
lcd.print(" degrees C");
lcd.setCursor(0,1);
lcd.print(voltage);
delay(1000);
}