My faithful RT-N66U router died last night. Luckily I was only using it as an access point and wifi was all that was affected. The unit’s power was completely out. I feared that the wall adapter had gone bad. I noticed that the push-on/push-off power button was in the out/off position (see below).
Upon pressing the power button in the power would come on, but the power button would no longer lock into the in/on position. A wonderful piece of technology was at the mercy of one of its absolutely cheapest parts.
To repair it I decided to open it up and bypass the power switch altogether (I never used it in the first place). I’m sorry, I didn’t think to take any pictures, but I will endeavor to describe my process in the repair.
The RT-N66U has several screws on the bottom holding the top cover in place. Once removed you have to gently pry the top cover off. There are tabs around the front and sides holding the cover on.
With the cover off, the board slips right out of position and is easily removed. To get to the underside of the power switch the metal RF shield on the bottom has to be removed. After removing the screws holding it, it pulls away without issue.
The power switch has 4 soldered pins. From the above picture, the top-most and bottom-most pins are attached to the metal frame surrounding the switch. The 3 center pins control the switch contacts. Using a continuity meter, I found that when the switch is on the out/off position it connects the top pin with the center pin and that this connection is to the ground leg of the power connector. When the switch is in its in/on position the center and bottom pin are connected. The bottom pin is connected to the positive leg of the power connector. This configuration means that we cannot simply bridge across the switch without removing the switch as the power would then be shorted.
Once the switch was removed it became a trivial matter of using a small piece of jumper wire between the center pin and the bottom pin to create and always-on connection. Now my faithful access point is back in action for hopefully many more years to come.
For the garage door state detection I decided to go old school with a magnetic contact switch. I chose these for their simple implementation and ease in interfacing them to the RPI. Two per door will be used to detect when the door has reached its fully open and closed positions. The design includes the ability to actuate the existing garage door opener with a relay.
P1 is the HAT header of the RPI. P2 & P3 are the door actuator relay outputs. P4-P7 are the door position switch inputs. When the magnet closes the switch on one of the inputs its corresponding RPI GPIO is pulled low to a logical 0. TOP corresponds to the top of the garage door and indicates that the door is in its full open position. Likewise BOT is the bottom of the door and indicates the door is in its full closed position.
The Input Circuit
Studying the input circuit surrounding P4, the diode D9 allows for the use of a door sensor that outputs voltage instead of a switch closure. If you use the magnetic switches it isn’t necessary. The resistor R9 act as a pull-up for the input to define a logical 1 since the magnetic switch does not provide a voltage. The LED D5 is strictly a visual indicator for the user to see when the input is being actuated. The resistor R5 is used to limit the amount of current that is sourced/sinked from the RPI’s gpio pin. It is primarily used as a buffer should the RPI gpio pin ever be accidentally put into output mode it won’t short against a closed external switch and damage the RPI.
The Actuation Circuit
Studying the output circuit surrounding P2, the relay K1 can be any general purpose 5 volt relay. The diode D3 is needed if the relay doesn’t come with one. It is used to short out the fly-back current produced by the relay coil when it is switched off. The fly-back current can at minimum cause the RPI to reset and at worst damage it. The resistor LED pair R3 & D1 are purely for visual indication that the relay is being actuated. Transistor Q1 is used to gate the relay since it cannot be driven directly from the RPI gpio without damaging the RPI. The transistor used can be any general purpose NPN or N channel FET. I used 2N3904 transistors because I had an ample supply of them in my personal inventory. The transistor needs to be sized to handle the current draw of the selected relay. In the case of a NPN type transistor the series resistor R1 is needed. In the case of an N channel FET, R1 would instead be attached to ground to bias the FET in the off state when the RPI gpio is an input. The RPI gpio’s are generally set to inputs whenever the RPI is reset. The last thing you want is the door inadvertently opening/closing in the case the RPI is power-cycled or reboot.
The Board So Far
Here we see the current board in all its glory. This is build with an original RPI Zero without the built in wifi, hence the TrendNet wifi adapter. Pay no attention to the ATTINY26. That was an experimental expansion that later proved to be unnecessary. I’ll discuss it more in an installment about the choice of temperature measurement and the radon abatement detection that was ultimately chosen but not yet added to the board.
The door interface is quite simple and easy to build. In the next part I’ll cover the code I wrote to turn the inputs into an MQTT message for the HAB system to digest.