Yes, you can charge a lithium-ion battery from two sources. Both sources must have the same voltage to work together. One charger will provide most of the current, while the other may stop.
Can I use a power supply with a higher voltage?
You could use a power supply with a higher voltage than the battery, both the battery and the power supply have their own diode feeding the Arduino. As long as the mains are good the higher voltage will block the current from the battery. When the mains fail the battery will have a higher voltage and provide power through its diode.
How does a DC power supply work?
With mains present, the DC supply will maintain/charge the battery and power connected peripherals at the same time. You need to regulate the DC supply output voltage to match the battery maintenance-charge level (about 13.7V). At this level, you can leave it connected/powered at all times. Switchover is instant as this is a hot standby connection.
Can I use a battery instead of a relay?
A relay will have some switching time with no power output. You could use a power supply with a higher voltage than the battery, both the battery and the power supply have their own diode feeding the Arduino. As long as the mains are good the higher voltage will block the current from the battery.
Can a DC supply be used as a battery charger?
The common solution to this challenge is to use the mains regulated DC supply as a battery charger. With mains present, the DC supply will maintain/charge the battery and power connected peripherals at the same time. You need to regulate the DC supply output voltage to match the battery maintenance-charge level (about 13.7V).
Can I use a relay if the mains power fails?
Unless both devices are tied to the power connection you will have a problem if the mains power fails. A relay will have some switching time with no power output. You could use a power supply with a higher voltage than the battery, both the battery and the power supply have their own diode feeding the Arduino.
Do you need a power source for a portable electronic device?
Many setups require two or more power sources and there can be problems when switching between them. For example, almost all portable electronic devices have integrated rechargeable batteries and a USB port for charging. This requires a solution for seamlessly transitioning between the internal battery and the external power sources.