The best way to trigger an interrupt use GND in a car

I'm hoping there is a reasonably obvious answer to this. Here is my scenario. It's simple but I'm trying to over-explain it so that it's clear:

I've created a GPS tracker based on the Arduino Nano. I want to take action when someone opens the vehicle's door. This is an OLD vehicle that does not use a CAN bus. The wire in door jamb switch, connected to the interior lights, is always +12V, except when the door is opened, the door jamb switch connects to ground, completing the circuit. I will tap into this wire to sense a connection to ground when the door is open. I am using the vehicle's battery to power the Arduino.

So I would like to trigger an interrupt when I connect the interrupt pin to the vehicle's ground. Currently, I simply have the interrupt pin set as INPUT_PULLUP, and I have a diode allowing current from the Nano to the car, preventing current from the car to the Nano to avoid burning out the Arduino. I was considering also including a small resistor. I have a different solution involving a relay, but I'd like to avoid this.

Testing in my house, when I connect a 10 foot wire to the diode (nothing on the other end of the wire) the interrupt triggers just by tapping the wire to the diode. When I tap it with my finger, it also triggers. I was told months ago that it is likely the 110VAC mains of the house.

Basically, I want this interrupt trigger to be reliable and not wonky... falsely triggered by EMFs and whatnot. My background is in software, and I'm a novice hardware person compared to a lot of the people on this forum. Any advice would be appreciated.

The safest approach would be a DIY transformer to detect the current flow in the wire when the switch is grounded. With a bit of additional circuitry it would produce a short voltage spike that could trigger a rising HIGH interrupt, and would provide complete electrical isolation for the Arduino. The design in your schematic won't do that.

The starting point would be to determine the current in the wire when the switch is closed. Then, you could experiment with a commercial CT (current transformer), by winding a couple of turns through the center, and work toward a 5V pulse on the output. One of these would work: CS60-010 50/60 Hz Current Sensor | Coilcraft

Or make your own from some steel washers: Making a Current Transformer from Washers - YouTube

For an intro to CTs see Current Transformers (CT) - YouTube

Warning: automotive electrical systems are a harsh environment for electronics. You need to plan for possible polarity reversal, and voltage spikes of several hundred volts.

And if the light being turned on by the door switch happens to burn out, what then?

Replace the bulb?

If the light burns out, it doesn't change the part of the circuit I care about, but good question. Here is a clearer diagram:

if using a current sense transformer, your question is more relevant than I thought!

Oh boy, that makes sense. You're saying what I've heard, i.e. it's a very harsh environment. Isolation is definitely ideal. I looked at some current transformers and based on the Frequency Range spec I imagine they're typically used for AC, while the car of course is DC. It sounds like you are saying when the current started flowing, it would for a brief instant detect the single change in current from 0 to > 0.

This makes sense, but is more complex than I'd hoped. And actually, this makes Paul_KD7HB's question very relevant!

Ok, I was trying to avoid a relay, but this seems like it would provide isolation. I realized I could use a cheap, low power relay and simply use a tap to tap into the door jamb switch wire, instead of having to cut it as I think I'd have to do with most commercial CTs.

Does this seem like a reasonable approach? I've used Bosch style relays and the small, typically blue Arduino starter-kit relays, but would a solid state relay work for this, and would it be preferable, or a terrible idea, or it kind of works either way?

IF you can access the +12V I'd use a conventional relay designed for use in a car - cheap, reliable and robust, and gives excellent isolation. Wire it between the door switch and the +12 (so across the light). Use the contacts to connect to the arduino, and debounce with a capacitor and a pullup. And interrupt on LOW.

Current TRANSFORMERs (clue) only work on AC current. OK or transients - but in a noisy environment I'd not choose that.

Thanks John, I found some small, light, fairly cheap, 12mm cube relays that I'll probably use. They say they are automotive, but look like they're for a PCB, as opposed to Bosch style, but that's fine.

The relay to 12V is a good idea and I don't know why I did not think of that. An optocoupler work work too. You don't need the diode shown in the schematic, and don't forget that LEDs require current limiting resistors.

The 12V to 5V converter needs to be designed for an automotive environment, with protection from polarity reversal and high voltage transients.

jremington, johnerrington,
I combined the circuits into what I hope will be the final circuit.

1.I added a flyback diode to the relay
2.It's actually not an LED, it's incandescent, but I couldn't find a symbol for that

Given those 2 things... but actually even without the flyback diode... it seems to me that if both of the switches are open, the 12V-5V converter could be unintentionally powered from the interior lighting circuit, would you agree? I think I actually put the diode in the blue box to prevent spikes coming from the lighting circuit (LOL, I generally do not understand circuit protection), but now I'm thinking it is necessary to prevent unintentionally powering the 12V-5V conv.

I'm sourcing +12V from near the 12V-5V converter because it's actually much easer in practice. Also, sourcing across the light might not work now that it's incandescent.

Thank you both for your help, I really appreciate your time and expertise!

You dont really need a flyback diode in an automotive circuit - but it wont do any harm, and some relays come with them built in anyway.
Youre right about the diode in the blue box; had you connected it to the other side of "arduino switch " it would not have been needed.
"LED1" is your interior light no resisitor needed
You MAY need to put a small cap from D2 to ground to debounce the signal - relays often exhibit a LOT of bounce.

You may want to add a decoupling capacitor across the arduino +5 to ground - say 100uF; and an additional pullup of about 1k D2 to +5 and capacitor D2 to ground (maybe 0.1uF) to avoid noise on D2.

I agree with johnerrington's comments. Looks OK, if the 12V to 5V converter is designed for an automotive electrical system (should have a TVS diode to suppress high voltage transients).

1 Like

Thank you both again! I hope that other people will also find this helpful, as it seems like something people would want to do. I searched and was surprised not to find it here already.

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.