I've basically put together an Arduino on a breadboard as a test bed for a standalone project.
For my power supply I'm using either a 9V battery or 3xAA batteries. When I'm using a 9V battery I'm putting this through a 10uF electrolytic capacitor through a 7805 regulator connected to my power rails which has another 10uF electrolytic capacitor. If I use the 3xAA as the power source I just connect this to the power rail that still has the 10uF capacitor, and disregard the 7805.
I'm using a ATmega168P which I've set to run at 8MHz.
I have an LM335 temperature sensor; Pin#1 isn't connected, Pin#2 is connected to the Vcc through a 2.2k resistor. This then feeds back to A0 [pin#23] on the 168P. Pin#3 is connected to ground.
For the readout of the temperature in Celsius, I'm using a 2-digit 7-segment LED.
When I use the 9V as power source the LED shows a value of 31! and When I use the 3xAA it shows 96!!
When I connect a multi-meter to the power rail, I get a reading of:
9V => 4.91V
3xAA => 4.69V
and the voltage reading off of the LM335 pin#2 is:
9V => 3.02V
3xAA => 3.02V
The sketch is:
#include "SevSeg.h"
SevSeg sevseg; //Instantiate a seven segment controller object
int outputPin = 0;
unsigned long timer = 0;
int refreshTime = 5000;
void setup()
{
byte numDigits = 2;
byte digitPins[] = {1, 0};
byte segmentPins[] = {12, 11, 9, 8, 7, 10, 6};
sevseg.begin(COMMON_CATHODE, numDigits, digitPins, segmentPins);
sevseg.setBrightness(90);
}
void loop()
{
int rawvoltage= analogRead(outputPin);
float millivolts= (rawvoltage/1024.0) * 5000;
float kelvin= (millivolts/10);
float celsius= kelvin - 273.15;
unsigned long mils = millis();
if (mils - timer >= refreshTime)
{
timer = mils;
sevseg.setNumber(celsius, 0);
}
sevseg.refreshDisplay();
}
Can anyone advise on a way to accuratley use the LM335 with 3xAA power source? As I don't want to use the 7805 regulator.