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?
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.