I’m thinking about a simple project for the BBB, and have a couple questions about it. I have an idea how I want to solve the problem below, but if there’s a simpler way to proceed, advice on that would be appreciated.
I’m a software guy with not much knowledge about hardware other than playing with 555 chips on a breadboard.
The current setup consists of networked BBB in my computer room. I’d like to detect when the deep freezer one floor down in the basement is opened and closed. (Detecting temperature would be a later project.)
I have a deceased Dell 1710n printer, which has a door-open switch that I can pull out and rig onto the freezer to open and close along with the freezer door. I can run a pair of wires from that to the BBB, which could then detect when the freezer is opened and closed. Will the switch generate spikes that hit the BBB? What’s a good way to protect against that? Perhaps the Dell includes circuitry that addresses that very issue so the switch doesn’t fry the printer, and that circuitry could be pulled along with the switch.
if you keep the cable to the switch short you should be able to wire it straight into two GPIO pins. Configure one to output and always high. The other to input and simply query it or check if it can generate an interrupt in case it goes from low to high.
The rest is software.
Hmm, There’s about 30 feet between the freezer and the BBB. I guess that’s not “short.” What’s the issue with a long run?
All you really need is the switch. Wire it to a GPIO pin set to input, and then then poll the GPIO to see if the switch is open or closed.
I guess the issue with a long run is that the resistance of the wire would draw significant current from the board? Perhaps a large-gauge wire would mitigate this sufficiently.
I would be worried about both voltage drop and isolation… I wouldn’t want something with such long wiring connected directly to the GPIOs as the GPIO pins aren’t protected (I dont think)…
Easiest would be to wire up a relay to provide a clean contact to the GPIO…
Using a 12V relay, wire the coil to the switch (switch now controls relay). And then feed the NO or NC to your GPIO. Keep in mind the back EMF suppression diode on the relay…
This page may be handy in understanding what I mean (just after a quick google search)-
I’m not much help with your precise question. I’m quite a noob with hardware/circuits in general…
That said, I can’t help but wonder if one of those inexpensive ($19.97 Amazon Prime) GE/etc wireless home security kits might be hackable to help overcome your distance issue? Of course, “inexpensive” is nowhere near as cool as already-paid-for if you’ve already got all the parts on hand that you need!
Anyway, if the GE option were tried, maybe you could mount one of the kit’s door sensors to the side of your freezer door…
Then, if you intercepted the signal to the siren on the base unit, maybe you could jumper that into a GPIO that could then be polled for the “siren-on” signal?
Here’s a link to the GE kit I’m referring to:
Hmm, a variety of good ideas, thank you all. Juan, you say “Keep in mind the back EMF…” As a software guy, I’m not sure what to watch out for here. Will the back EMF cause a spike that I’ll need a suppression diode to block, and/or get a relay with the diode suppression?
yeah exactly that… The coil will generate a voltage spike when the magnet gets pulled back in… The diode provides a path for this (fitted reverse polarity across the coil).
I haven’t used relays in a while, but I’m sure you should be able to get built in suppression diodes if you search hard enough… But for the $$$ vs. effort required, I’d keep it all separate.