Electronic – arduino – Using/Charging a backup battery in a 12VDC circuit

arduinoautomotivebatteriesrelayvoltage divider

EDIT: I've revised the circuit in response to comments from Andy aka. I have also updated my questions to make it more clear what I am asking. I'm leaving the top paragraphs for completeness' sake.

I am trying to design a circuit using an Arduino (U2) that will detect the incoming voltage from my car (V1) in addition to detecting the voltage on a backup battery (V2) in the circuit. I wrote all of the Arduino code for this before even realizing that the schematic design for this circuit was beyond my beginner's knowledge. I've taken a crack at producing the schematic of my system, below.

The Arduino code triggers a relay that energizes my load (a raspberry pi computer with some other accessories) when the car is providing voltage (my cigarette lighter is keyed with the accessory switch) and when the system loses power, it will run from battery for 30 minutes before gracefully shutting down the raspberry pi. It's just about done except for the circuit in this post. While the system is operating, I am hoping that the input current from the car electrical system will top-off the battery (it is a 12V SLA deep-cycle.)

When I run the simulator on this circuit, the voltage out at VBat is not 12 or 13.8V as I was anticipating, so I'm hoping that someone else can shed some light. I'm also curious about how I can prevent the voltage from the backup battery in this circuit from seeping back into the car electric system (I'm assuming I need a diode, however I was unable to make a diode behave as I would expect in the below circuit)

What is the proper way to hook up a backup battery in this scenario so that the battery not only is appropriately isolated from sending back-voltage to the car, but also receives charging voltage from the car?

schematic

simulate this circuit – Schematic created using CircuitLab


After Andy Aka's circuit revision, I have a now properly-operating circuit according to circuitlab. The only problem I need to solve for is how to properly charge the 12V battery from the 13.8V line. Andy aka's answer below makes reference to a Schottky diode but I'm not sure how I would wire that up to provide charging voltage to the battery.

schematic

simulate this circuit

Best Answer

This is more of a comment than an answer because your requirements are made fuzzy by your illogical (don't take it to heart) circuit:

Are you looking for this type of basic configuration of your batteries: -

enter image description here

If so, then add the relay contact either in series with the 12V battery or in series with Vout. I'm assuming that your arduino will always take power from one of the supplies. I guess you'll need some kind of charge circuit for the 12V to keep it topped up too. This can be done with a schottky diode in series with a resistor from 13.8V directly to 12V BUT it depends on your battery type and I'm no expert on battery chargers.