I am using a USB-powered Duemilanove to measure temperature using a TMP36 sensor (3-pin TO-92 package) and I display the results on a 16x2 LCD display.
When the LCD backlight is connected the analogRead() returns a different value because the LCD backlight load pulls down the Vcc from 4.98V to 4.61V
The TMP36 sensor has a steady output voltage even when it's input voltage drops. However, the voltage at AREF follows Vcc down, I guess this is what causes the analogRead() to misread the voltage on analogue input 0.
LCD Backlight off on
+5V from Duemilanove (V) 4.98 4.61
Temperature sensor output (V) 0.73 0.73
analogRead 147 161
Should I use a better power supply or is there a way to compensate for the drop in Vcc?
There are several ways to deal with that problem. A lot depends on how you are, or wishing, to power your Arduino board. If you must utilize the USB then changing the A/D reference voltage source is the best method. Check out the link to see what A/D references are avalible for your consideration:
The easy, but not so cool solution is to power the display from its own seperate powersupply.
I suggest to implement this solution with independent power supply. If you do not need the USB port for data transfer during normal operation I suggest to disconnect from USB.
Test with an external power supply the current you need to run the arduino and the LCD.
Using analogReference(INTERNAL) meant the analogRead() returned much more consistent results when the LCD backlight was on or off. The internal 1.1V reference limits it to measuring temperatures below 50C - which is OK for me at the moment. This is with power coming from USB.
When I made the measurements in my initial posting, I didn't have a series resistor in the LCD's back light. I've tried a few resistor values and they do decrease the amount that Vcc is pulled down (also reducing the brightness of the backlight as you'd expect). The problem is reduced but it is still there and affecting analogRead's accuracy.
I tried unlugging the USB connector and connecting a 9V wall-wart to the Duemilanove. Vcc was much less affected by the LCD backlight and so the analogRead was much more accurate.
Thank you all for the ideas. This forum is pretty good!