Hello, I want to use an Atmega328p to meassure three sensor values and light up LED's based on what the temperature is. In order to measure the temperature I need a constant set voltage or send the battery voltage to an analog input so that when the battery voltage drops down the microcontroller knows. My plan is to use 2xAAA batteries so that the total voltage is 3V.
The problem is, I have used up all 6 analog inputs for sensor readings and LED readings. Can I use the AREF to fix my problem if I dont want to use a voltage regulator?
If you guys have any thoughts on improvements, I will be happy if you tell me.
You didn't say which package. The ATMEGA328P-AU, that is SMD, has 2 more analog inputs than the DIP version of the chip. If you don't want to use the SMD package directly, get an Arduino pro mini and strip off the power led and voltage regulator.
Simply stated it will not work, the battery voltage drops as they discharge and so will your reference voltage. The simplest solution is to use a SEPIC converter which will keep you going for a while. Your battery life is going to be short. More battery capacity will help a lot, and using the sleep mode with the micro will also help. I would consider looking at micro power processors. This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil
In order to measure the temperature I need a constant set voltage
No, you don't. A thermistor used as a temperature sensor does not require a fixed reference voltage, and several other types of temperature sensors don't either (e.g. DS18B20*).
Alternatively, (as I do) buy $2 Pro Minis on eBay and use a hot solder pencil to swipe off the voltage regulator and the power LED, to arrive at the same thing.
(*) The DS18B20 is spec'd for 3.0V minimum, but works below that. To be safe, though, I would use 3xAAA as the power source.
A resistor connected to a voltage source will give you a a voltage reading which will change with the supply voltage and temperature. Your idea will work but difficult to achieve and will not be accurate. At low voltage the source resistor you add becomes a major part of the equation. Also most thermistors are not linear, this requires compensation. To properly use a thermistor you need a high compliance current source that remains constant regardless of the supply voltage, then your A/D readings will be consistent. This will also stabilize your temperature conversions. This constant current source can be a several components or a constant current diode such as one in the 1N5283 series. You can look up constant current source designs. This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil
With nonlinear compensation and proper calibration, a thermistor in a simple resistive voltage divider on an Arduino can quite easily be used to measure temperature, with +/- 0.3 C accuracy (over a limited temperature range).
No current source or stabilized voltage reference is required, nor would either be useful.