Common ground when using an Optocoupler?

Thread Starter

Ping pong

Joined Feb 13, 2022
78
i am working on a small Arduino project that involves using the cars door trigger to initiate a task.
The door trigger wire usually holds 5v unless the car is in its sleep state (no key and idle 5-10seconds) when this voltage drops down to 2v. when the door is opened however, this wire is grounded, allowing the car ecu to know that the door has been opened. Below is the factory wiring diagram to give you a clearer idea on how this system works.
View attachment Toyota-2009-2010-Electrical-Wiring-Diagram.jpg
Now i could just code the Arduino to read the voltages on any of the door trigger wires (green, white and brown) and initiate the task when the voltage drops below 2v. But that would probably cause a greater power draw as the Arduino would have to constantly read the voltages and make the relevant calculations.
Hence why i plan on using an optocoupler instead with the trigger wires connected to the anode side of the opto led. this will keep the optocoupler active until the door is opened at which point the opto led would turn off due to the ground signal in the trigger wire and hence allow the Arduino to initiate this super secret task.
The schematic for this has been prepared by yours truly which include a buck converter stepping down the car batteries 12v to 5v to power the arduino and the optocoupler. (this was my first attempt on making one from scratch hence why the complete rats nest of wires)
Optocoupler_schem.png
There is also a second way of implementing this where the trigger wire is connected to the cathode which would mean that the opto led will stay off until the door is opened, giving it the ground signal to complete the circuit. this will be done in the following manner (schematic not made by me but you could probably tell that anyways lol):
1705856163803.png
From what I've learned, optocouplers are useful to isolate the microcontroller from the trigger source but as you can see, in this case the grounds are all connected together which defeats the purpose as some might say. Hence why i need your suggestion on the matter. Is there a better way of using an optocoupler in this configuration? Can i improve this schematic because from what i can see, there is no secondary ground in the car.
 

nsaspook

Joined Aug 27, 2009
13,297
A small 5v battery perhaps?
Battery for what?
You have a existing DC to DC converter in the diagram. What's the source for the trigger switch voltage? I assume you want to keep the trigger voltage and common isolated from the controller voltage and common.
 

Ian0

Joined Aug 7, 2020
9,826
If your 5V is provided by a buck regulator, then it has a common ground with the car, therefore there is nothing to isolate, and you don't need an isolator.
A comparator will do the job, detect the voltages accurately and protect the microprocessor from an nasty voltages on the car wiring.
 
Top