in one of my projects I want to have my arduino being powered through an AC-to-DC adapter, but in case that electricity stops, to get power from a backup battery. My thought is to connect the adapter to arduino through the barrel jack and connect the battery using the VIN at the same time.
Since I am not good at electronics, I would like to know if this is feasible and if there are any issues that I should take care or if there are alternative ways to implement it. I would like to add that the battery is 9v and I have both rechargable batteries and normal ones. The external adapter is going to be a 12v adapter.
A had a quick look at the Leonardo schematic diagram.
The Leonardo supply seems to be different from other Arduinos.
There is no series diode between DC jack in and Vin, just an anti-parallel protection diode to ground.
So DC jack in and Vin are the same...
If you use a normal battery, use a (schottky) diode between +batt and Vin. Cathode (ring) to Vin. Batt- to ground.
If you use a 9volt rechargeable NiCad or MiMH battery, you could put a ~470ohm resistor across the diode.
That will trickle-charge the battery.
Supposed to be bad for them, but practically they will last a long time.
Don't do this with LiPo batteries...