Pins are Getting Blown by Switch

So I’ve used a Sparkcore to build a bathroom status detector at our office. We have 15 employees and one bathroom, so folks have gotten pretty dependent on being able to see if the bathroom is free by checking a webpage ( rather than having to get up only to find it’s occupied.

The way I’ve rigged it is to just have a wire that goes from the 3.3v pin to D0 and the latch on the bathroom door closes the connection. It’s not a proper switch, just two pieces of metal coming together. I have a resistor that goes from D0 to ground to prevent floating voltage on the pin. My problem is that once a month the thing stops working and I have to switch to a different pin because whichever one it was in stops working.

Because of the wiring to the latch, I think maybe I’m getting a spark when the latch closes that drives the voltage to something higher than the safe voltage for the pin.

Anyone have any other thoughts and is there something I can put in the circuit that will prevent this?

Hi @rosshere

This is actually kind of a known problem, particularly if the wiring to the switch is long. Lots of things could be going wrong but inductive spikes due to long wires and static electricity are the most common problems.

Here’s a link to a description of some input protection circuits you can use:

Be sure to read all the way to the zener diode circuit at the end but either of the last two ideas should work for you.


Thanks - this is the second thing you’ve given me good advice on.

So, a zener diode seems the simplest route, and it seems like I can just wire a 3v diode inline with the switch I am using. Does that sound right to you?

I would use something similar to the circuit I linked to above. The series resistor is key if you don’t want to blow out the zener diode too.

1 Like