Using a cars door switch with arduino

Thread Starter

Ping pong

Joined Feb 13, 2022
91
The door switch that basically tells the cars ECU if the doors open or closed has a single wire going to it. This wire is either at 5v or 2v depending if the car is in its sleep state or not. When the door is opened however, this wire shows a ground signal or 0v.

I want to tap into this wire and connect it to the Arduino to act as a trigger for a small project I'm working on. To keep it simple, I want a relay to turn on when the door is opened and turn off when the door is closed.

Now this would have been easy if the wire didn't drop to 2v in the cars sleep state as the Arduino thinks that anything below 3v is a low signal, hence turning on the relay.

I searched a bit on the internet and it suggests to use an npn transistor (2n2222) in the following manner:
Connect the emitter of the NPN transistor to ground. Connect the collector of the NPN transistor to the Arduino digital input pin (e.g., pin 2) with a pull-up resistor (10kΩ) between this input pin and the Arduino’s 5V. This will keep the input HIGH when the transistor is off. Connect the door switch wire to the base of the transistor through a 10kΩ resistor.

Before I go out and buy the components, I wanted to ask you guys whether this'll work with the varying voltage in the door switch wire or if there is a better way of using this door switch as a trigger with Arduino.
 

sghioto

Joined Dec 31, 2017
8,633
That might work depending on the ECU signal. Have you actually measured this signal, as I suspect it's probably a PWM.
Using a scope would be the best way to measure.
 

sghioto

Joined Dec 31, 2017
8,633
I don't have one on hand. Using a multimeter however shows a constant 5v/2v. That's all I have to test the signal.
Does your multimeter measure frequency?
This circuit will work if the ECU signal is truly 2 volts in the sleep mode.
1731180699824.png
Alternative circuit if ECU signal is PWM. Value of C1 may need to be changed depending on the duty cycle of the ECU signal.
1731180161362.png
 
Last edited:

KeithWalker

Joined Jul 10, 2017
3,603
The door switch that basically tells the cars ECU if the doors open or closed has a single wire going to it. This wire is either at 5v or 2v depending if the car is in its sleep state or not. When the door is opened however, this wire shows a ground signal or 0v.

I want to tap into this wire and connect it to the Arduino to act as a trigger for a small project I'm working on. To keep it simple, I want a relay to turn on when the door is opened and turn off when the door is closed.

Now this would have been easy if the wire didn't drop to 2v in the cars sleep state as the Arduino thinks that anything below 3v is a low signal, hence turning on the relay.
Instead of connecting the switch to a digital input on the Arduino, connect it to an analog input. Then set the software to activate if the measured voltage is >1.5V.
 

Thread Starter

Ping pong

Joined Feb 13, 2022
91
As Keith suggested.
Regardless if the signal is DC or PWM a simple series filter will suffice.
Yeah I did consider that as well but considering that I'll be taping into the car unlock and lock wires as well which work in the same manner will mean the Arduino will have to work into overdrive to check voltage on all triggers. Plus that would draw more power as well.
 

Thread Starter

Ping pong

Joined Feb 13, 2022
91
Does your multimeter measure frequency?
I'm not sure, it probably doesn't because its one of those super cheap ones. Does have a wave symbol but don't really know if it's that. How will I test it tho? Connect one end of the probe to the switch wire and the other to ground?
 

Thread Starter

Ping pong

Joined Feb 13, 2022
91
Why would that draw more current if the Arduino has to scan several inputs?
Hmm, come to think of it, a nano probably doesn't draw much power anyways. I do plan on keeping it plugged into the car, just don't want to end up with a dead battery.
 

sghioto

Joined Dec 31, 2017
8,633
That looks like it.
Read from the wire to ground when at 5 and 2 volts.
BTW that nano shouldn't be a problem running down a car battery.
 

KeithWalker

Joined Jul 10, 2017
3,603
If you are really concerned about running the battery down, have the Arduino go into sleep mode after a pre-determined inactive period and wake it up with an interrupt from an active input signal.
 
Top