Convert reed switch disconnection or SPST off to single “LOW” pulse

arduinointerruptsreedswitches

I'm trying to wake up my Arduino and run some code when a reed switch or SPST switch connected to an interrupt is opened. If my Arduino is in powered off mode, only LOW interrupts are accepted (not changes, which would make things much easier).

Is there a simple hardware way to send a single LOW pulse when the switch is disconnected? I'm trying to avoid the interrupt continually triggering my Arduino to wake up while the switch is open; I only need the code to run once, and then I want my Arduino to power back off until the switch is eventually closed and then reopened again.

I've been exploring using a 555 timer in monostable mode, perhaps with a transistor inverter to make the pulse low, but it appears that that solution will eventually trigger again (more than once) if the reed switch remains open for a prolonged period.

Best Answer

Sounds like capacitively coupling it might work well. Reed switch goes from power a pull-down resistor and one side of the cap. The other side of the cap goes to a pull-up resistor and the GPIO pin. When the reed switch is closed, both sides of the cap will sit on the power rail. When you open the switch, the pull down resistor will pull that side of the cap down. If the cap is large enough and the resistors are properly sized, the GPIO pin will be pulled down as well until the cap can charge up. When the switch is closed, the capacitor will discharge. It might be a good idea to add a clamp diode to power on the GPIO pin side of the cap so the cap can discharge through the diode instead of the chip's ESD protection diodes. You'll need to play around with the values of the resistors and capacitor to get a pulse of the right length, though the pull-down will have to be significantly smaller than the pull-up - I would suggest trying a 10k pull-down with a 100k pull-up. To figure out about how long the pulse will be, calculate the time constant, tau = RC. This will be approximately how long the pulse will be. A 10k and 100k resistor with a 0.1 uF capacitor will give you a tau of about 110e3 * 0.1e-6 = 0.011 seconds.