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


