I am trying to figure out how I can place the Arduino BT into sleep mode once the battery is low.
I need to know how to read the current power/voltage value of the board so that I can do this.
Does anyone know how to do this? Or is it not possible?
Thanks.
Run a third wire from the power supply + to analog input 1. Have the arduino read that data and if it gets below a certain threshold have it turn of a switch through the digital pins.
The ATmega168 can't read an analog voltage higher than it's Vin. Unless you're doing something with a boost regulator, there's no way you're going to have a supply voltage that's not at least as high as Vin.
That's the sort of reply that feels really uncomfortable. You're being so vague it's not really helpful and it's so basic there are ways you can do it. A voltage divider would work, but then that's 2 resistors. Do you mean a resistor in series with the analog input? That won't do the job. So the fact that there is some way to do it with resistors doesn't make you any more right.
How about just throwing out "try a diode". That would certainly lower the voltage if you put a diode in series with the input. Maybe "try a VCO" and use pulseIn on a digital input?
This could be a fun game. One person names a random part and the other says how it can be used to read a voltage over Vcc on an ATmega168.
The voltage at r2 will be determined by this formula: VR2 = (R2 / (R1 + r2)) * Vbattery. Pick the total resistance in the branch first. 100k should be fine. So now we have VR2 = (R2 / 100k) * Vbattery.
I assume the ArduinoBT uses 5 volts for vcc. Lets assume that you are using a 9 volt battery to run the system. Let's also assume that we don't want the voltage into the analog pin to go above 4 volts to keep from damaging the pin with a healthy battery. Now we have this:
4 = (R2 / 100k) * 9
I'll step into the basic algebra to be clear so feel free to skip this if you don't need further clarification
Divide both sides by 9:
.444 = R2 / 100k
Multiply both sides by 100k:
44.44k = R2
Now we know that R2 = 44.44k we can figure R1 by subtracting 44.44k from 100k. (100k -44.44k = 55.56 k). Now we know R1 = 55.56k.
Now we have this:
R2 = 44.44k
R1 = 55.56k
From the analogRead() page (http://www.arduino.cc/en/Reference/AnalogRead) each unit read by analog read = 4.9mV so we can deduce that a battery at 9v will be 4 volts a on our analog pin. 4v / 4.9mV = 816.
Figure out what the voltage should be to trigger the sleep and scale it using the above formulas. You may want to make sure to add some debouncing or delays to aid in noise immunity. A small capacitor on the analog pin may help as well.
I hope this has been helpful!
edit: I think the Arduino BT uses 3.3v for vcc. Simply use the formulas above and scale everything back so that you don't exceed Vcc at the analog pin.
edit: I think the Arduino BT uses 3.3v for vcc. Simply use the formulas above and scale everything back so that you don't exceed Vcc at the analog pin.
The Arduino BT uses both 5V and 3.3V on the board. As I mentioned earlier inthe thread, there is a swithcing regulator that takes the input voltage and generates 5V. This is used for the AVR processor chip.
There is then a linear regulator which takes the 5V and produces 3.3V which is used by the WT-11 Bluetooth radio.