Good day, please i want just bought Arduino Uno R3, and i want the code that will enable me to switch to battery when power is out. Thanks.
(deleted)
as quick as you can help me thanks very much.
(deleted)
Sorry i forgot to mention, i need the battery to be charging using the arduino. i have power from wall socket which i passed it through adaptor, which the adaptor provide me with 12v as my power supply, so i want the arduino to take over and switch it over to the battery it was charging. So now my device will be powered by the battery through arduino for sometime before the battery drains off.
(deleted)
Why not use the wall connection to keep the battery charged and at the same time power the Arduino from the battery. If the mains power fails the Arduino will continue working from the battery.
If you want the Arduino to detect when the mains power fails put a diode between the wall supply and the battery (so the battery can't back-feed power to the wall supply) and test the voltage upstream of the diode. Use a voltage divider (2 resistors) to bring the wall supply voltage a bit below 5v for the Arduino test point.
...R
Robin2:
Why not use the wall connection to keep the battery charged and at the same time power the Arduino from the battery. If the mains power fails the Arduino will continue working from the battery.If you want the Arduino to detect when the mains power fails put a diode between the wall supply and the battery (so the battery can't back-feed power to the wall supply) and test the voltage upstream of the diode. Use a voltage divider (2 resistors) to bring the wall supply voltage a bit below 5v for the Arduino test point.
...R
He doesn't even need an Arduino for this, just a 12V relay and a diode. When the power is on, it pulls the relay in to charge the battery. If the power goes off, the relay drops out switching the supply to come from the battery. The diode is, like you said, to stop the battery back-feeding the relay and charger. I've got an emergency lighting system in my house that uses exactly that circuit. If the mains fails (usually because the RCD trips) the emergency lights automatically come on and obviates the need to find a torch in the dark. An old car battery, 12Volts, gives me about 30 minutes of light, plenty of time to sort out the problem or evacuate the house if needed. When the power comes back, on the lights go off and the battery starts recharging, automatically. The only addition I've made to the circuit is a 'test' button that, when pressed, disconnects the charger to simulate a mains failure. The battery and charger are hidden in the attic.
Henry_Best:
He doesn't even need an Arduino for this,
I thought the OP wanted an uninterruptible supply for the Arduino (but maybe I didn't read the spec properly).
...R
Robin2:
Henry_Best:
He doesn't even need an Arduino for this,I thought the OP wanted an uninterruptible supply for the Arduino (but maybe I didn't read the spec properly).
...R
The OP isn't very forthcoming, but it appears he wants to power 'a device' of some sort and use the Arduino as the controller for the battery back-up. The limited details we have could mean that I'm wrong and you're correct. My crystal ball isn't that accurate. The damn thing needs recalibrating again.