Garage Door Hacking

Warning! Mains Voltage! This article in no way implies any endorsement of the following methods. Safety and fitness is not guaranteed or even suggested. I do not claim or imply that these instructions are in conformance with electrical or building codes of any jurisdiction.

Between a neighbor of mine and Vivint soliciting with a demo service, I have officially contracted the home automation bug. And somehow I got it in my mind that a garage door opener and sensor was the most important first step.

Well, not quite, I first needed a “system”, or software services that do things with and to the smart things. I tried OpenHab and HomeAssistant, and decided to go with the latter. But in the meantime I had already begun plotting and scheming for the garage door. Starting with checking out the opener itself.

Before opening the case of the opener, I unplugged it. Again, we’re talking about mains voltages here. I identified several components that might be useful, power supplies, rectifiers, where the mains are, etc. But the most important piece was the endstops! I didn’t take a picture of mine, so here’s a stock photo. The two screws on either side are what you adjust from the outside of the opener, to set the travel limits. Note again that the inside of the case contains MAINS VOLTAGES. The case is not intended to be opened, and the mains circuitry and wires are not protected once inside the case. It is not recommended to add stuff like this!

I could not find a very obvious and accessible source of 5V power rail, so I set out on a circuit that would be powered entirely by the new interface. I probed and prodded, and determined that the center contact (black in this photo) was a direct ground connection (vss or common) and the red and blue each have a 10kOhm resistance to +5V, or a pullup. See Figure 1. What this means is that the blue or red wire is HIGH (+5V) unless the travel has reached that limit and the center contact is touching it and then it is driven LOW. I decided to use standard switch transistors to “read out” these levels for my own selfish purposes, at first NPN transistors as diagrammed in Figure 2. When I finally got my circuit connected up for testing, I quickly found that the gate current was sufficient to pull the blue and red wires LOW, which the garage opener machine definitely noticed. It refused to go anywhere. So a quick mod to the design and a few transistors later, I had instead PNP transistors as diagrammed in Figure 3. This of course inverts the logic which was actually better for the LEDs. This configuration now worked without side effects on the machine. Yes!

As you can see I planned to use some CAT5/5e/6 cable to run my signals, which I soon had connected up to my LittleWire. At the time I only had a single PNP transistor so I could only detect one endstop on the LittleWire, but that one was working! Alas, when I drove the command pin HIGH on the LittleWire, the garage opener would respond, but the LittleWire or the USB bus would then immediately reset, which was not super useful. My theory now is that the capacitance in the cable was drawing too much current from the LittleWire, which hit me when I was reading an excellent tl;dr on protecting Raspberry PI pins (“Don’t drive capacitive loads!” Do’h). And yes, I migrated to a Raspi for the final piece of the project.

This is getting long, and the above was, IMO, the more interesting aspects of the project. On the raspi I used pi-mqtt-gpio from github to bridge the signals into HomeAssistant, another breadboard for buffering the raspi gpio (including a current resistor to the cable for sending the close signal), and an awesome idea to zip tie the raspi to cardboard for mounting.  Here’s the rest of the pictures to wrap it up!

RC Networks, They Matter!

After a long hiatus, I’m finally dusting off some projects and getting back into them, well, one in particular, the sous vide controller. I knew there were board errors from the prints I ordered early last year, I had even started to fix some of them. I got the boards and components and eagerly assembled one. Once I powered it on, there was one immediate problem. The LCD contrast with a diode that I wrote about previously, well, it’s not giving so constant a contrast on this board. Maybe it’s a poor diode, maybe I’ll build a bench power supply to vary the voltage across different diodes and see how they respond.

After putting some code on the chip, I found another problem. The push button on the encoder would not work. I got nothing at all from it. From probing the board and the resistors, I discovered that the button was active high, but my idle resistors were also pull-up. Tsk tsk. Ah well, that’s an “easy” fix, just scratch out some traces, re-route (in this case a power rail) around them, no problem, and connect the common side of those resistors to GND instead.

That got the button working, but not the encoder. Long story short, I played with the hard-to-see LCD for a while and then set it down for many moons. Oh that’s right, I also had to cut the common freewheel diode leg from the transistor array because apparently that’s not supposed to connect to “common”. Oops.

Fast forward, and now I dust it off, scratch my head, and try writing some simple encoder and button tests onto it. When they failed, I turned to my schematics, and scratched my head again. What I noticed actually pretty quickly is that the encoder legs were active LOW, but the push button active HIGH! *sigh* “I see why I did that,” in a way at least. I had to tie the push button active high because it shared with the common anode on the encoder LEDs. And it would seem I found that out after I made the quadrature active low.

So, I fixed all of that. I’m determined now to get this board to work. Of course I’ll make another run with corrections, but only after I find all the corrections. A few more trace cuts, more jumpers, and I got all the inputs working. Well, kinda… The rotary worked, a little bit. But not nearly fast enough. First I sped up the polling and that helped, only a little. Then I went full on PCINT driven, and no more improvement was to be found. At this point  I was beginning to suspect the RC network was too slow.

debounce-old

I plugged those values into units (not that that would be particularly needed in this case, but just the same, I highly recommend units!) and looky there. Fall time of 15ms! Yikes.

So I replaced the capacitors with some 15pF I found at Ra-Elco, and now it works flawlessly.

Moral is, don’t make board mistakes.
Moral is, you’re probably going to make board mistakes.
Moral is, don’t just pick component values because … whatever? Ya, don’t do that.

Introducing Boxy

Watch this video on YouTube.

Here’s the up-to 15 amp wall socket switch I’ve been working on, dubbed “boxy”. With a big enough heatsink you can use it for 15 amps and with no heat sink 5 amps may be too much. My primary use for this contraption is going to be for “sous vide”, a cooking method based on tightly controlled temperature. And for this the boxy will be switching a 1100 watt countertop hotplate, and that means about 10 amps. I’ll need a heatsink, but a moderate sized one should do.

Note that only the 2 yellow jumper wires closest to the battery are doing anything (and this demonstration would have worked with only one of those). All the other wires are just left overs from previous tinkers.

Now for the features of the boxy:

  • Completely isolated (from mains voltage) control circuitry accessed through 4 wires exiting the boxy
  • internal (and also isolated) zero cross detector – pulses every zero cross (120Hz for home sockets in the US)
  • simple control on one pin, drive it high to switch on, drive low to switch off
  • common ground for the zero cross

In the video I have the control wires exposed by a regular 4-wire phone cable and connector, though you could use whatever 4 pin connecter is most convenient for you (like a TRRS, RJ45, screw terminals, molex, etc)

Made from:

  • 1x Steel handy/utility box, $0.91 at Lowes
  • 1x 1 ft extension cord (sometimes called “Power Strip Savers”) cut in half, $8.50/5 on amazon
  • 2x NM cable connector (plastic: 20 cents each in a 10 pack, adjustible steel: $0.40 each)
  • 1x Cover for the steel box (in the video I have an aluminum plate which helps for heat dissipation, I have no source for these, though you could cut/fab your own), Lowes has a cover with a punch out hole (useful for the heatsink) for $0.98
  • 1x heatsink, necessary for any appreciable currents (lights would be fine without)
  • PCB and electronic components (to be included with the build instructions) ~$5-$10?

When I post the build instructions I’ll have a tighter cost estimate (and probably even kits for sale), but I think this could be built for under $20 apiece. Stay tuned for the build post!