Meta

Category: Electronic Projects

Who left the garage door open?

We have a full house with a lot of activity and visitors. There have been several times when the garage door is left open for extended periods of time. While our Christmas decorations and paint supplies may not be a treasure most would be thieves would desire, it is still not the most comforting thing to think about leaving the garage open for all passerby to see. I often thought it would be great to have a way to notify whoever is in the house that the garage is open.

Phase 1 – LED Indicator

I decided that my first step would be to design a way to detect “door open” by providing a simple indicator light. I explored a few optical ways to do this (light beam, camera, reflectors) but quickly pivoted my approach when I found some unused microswitches.

I found a good place to detect “closed” on the main track. I thought about piggybacking on the garage opener sensors but dismissed that as I didn’t want to risk an undesirable interaction with the opener and more importantly, I wanted to have the detection work even if power to the opener was interrupted.

This required that I build a bracket to mount the switch to and a ramp plate to compress the switch when the door was in the down position.

I used an aluminum sheet, cut with sheet metal snips, bent and drilled holes to mount the microswitch and eventually attach it to the garage door track. It took a few tries to get the right fit and right placement of the micro switch.

My first attempt destroyed the microswitch after a few uses. The garage door track sled has a straight edge that collides with the microswitch roller. It created too much force on the small roller and eventually popped it loose. To help with that, I added an aluminum ramp to the sled so that the microswitch roller would gently rise as the sled entered the “closed” position.

I decided to make the “door open” state be the closed circuit condition so that phase 1 of the project could start as a simple LED circuit indicator.

I attached the switch and drilled some pilot holes and mounted the bracket to the garage door track right above the sled when the door is in the closed position.

I added a 9V battery, a 470 ohm resister and a red LED to the circuit. To complete this phase, I ran the wire from the garage to our entry hall and mounted an LED and housing above the HVAC controls. Now we can all see the brilliant red LED glowing when the garage door is open. That covers some of our use cases but I also want a more proactive notification. Now on to phase 2…

Phase 2 – Raspberry Pi – Home Automation Sentry

Now that I have a working “door closed” sensor and indicator, I am ready to add the proactive home automation component, specifically the Raspberry Pi (RPI). It just so happens that I have a spare RPI Model 3 that needed a project, and I wanted to experiment with AWS IoT services.

I used the RPI to detect the state of the switch. To do that, I will need to wire the circuit into the RPI’sGPIO headers. I decided to use GPIO Pin 23 and the adjacent ground (GND) pin.

Here is the code that is used to detect the closed circuit (indicating an open door):

Sentry Alert – Send a text message to contacts when an alert condition is reached.

Dashboard – Provide an automation dashboard for realtime status.

Other Sensor Data:

Temperature Sensors

Barometric Pressure Sensor

Humidity Sensor

Motion Sensor

To set up a web based dashboard, I decide to use static HTML, CSS and JS (jQuery, Chart.js and the AWS JavaScript SDK) so it can be hosted on a simple S3 bucket, a web server, or the RPi itself. See here for the code.

A friend of mine at work has crafted a tiny HTTP web server in C to run on the Arduino Uno to provide an interface to manipulate external devices (imagine turning on lights, adjusting the thermostat or even opening the garage door).

Wouldn’t it be cool if you could control your MIDI equipped digital piano from your iPhone? Imagine a player piano capable of jukebox queuing up MIDI or Audio files and playing them in order. That was my goal! RPI to the rescue.

My original thought was to turn the Yamaha speakers into a AirPlay device for our many iOS devices. It’s nice to pipe in background tunes without having to hook up a device. AirPlay is great way to do that but I didn’t want to spend $100+ to be able to do that. The Raspberry Pi is more than capable of doing this. I found an extremely helpful blog post here: http://www.raywenderlich.com/44918/raspberry-pi-airplay-tutorial

NOTE: Power is a big issue for the Raspberry Pi. If you are using a WiFi dongle or any other USB device, I recommend making sure your power supply has enough kick to keep the RPI going. I started out with a microUSB adapter that advertised 700mA but performance became very unstable, especially under load. I switched to a 12W Apple adapter that I had handy and the problems disappeared. The RPI FAQ recommends 1.2A (1200mA).

Setup for AirPiano – MIDI Control

Dequeue Service: Run the cron.sh script to have the RPI scan for new midi or wave files to play. Run it with:

bash -x cron.sh 0<&- 1>/dev/null 2>/dev/null &

Apache: Install apache http with mod_php and mysql support

Website Code: Install index.php, setup.php and the folder.png files into the document root of your webserver. Upload the MIDI (*.mid) and WAVE (*.wav) files to this location. Be sure to update $globalBase in setup.php to the folder where these files are located.

AirPlay via Raspberry Pi

Adam Burkepile has the best tutorial I’ve found on how to set up a RPI for AirPlay:

I wanted to put together a simple two LED flasher circuit that would use the fewest parts and low power. My first project of this type used the NE555 timer IC but besides the chip, it requires more power than what I would like to use. Using a couple low-power NPN transistors, the circuit should be able to run for hours on a 9v battery.

The Circuit

I decided to use two 2N3904 transistors (a low power NPN transistor). This design uses only 10 components but I added additional resistor to inline with the power source. It could be removed and the other resistors adjusted to lower the power.

I assembled the circuit using a low cost breadboard I picked up at Fry’s Electronics. Using a breadboard allowed me to play around with different components, especially the capacitors and resistors to tweak the flash rate and brightness.

Single LED Flasher

The simplest single LED Flasher circuit I have found uses a single transistor (NPN), 2 resistors and 1 capacitor. This circuit uses the transistor as a Negistor using the NDR (negative differential resistance) effect. The transitor will block current until the voltage threshold charging on C1 reach something close to 9v, at which point the voltage will become large enough to get the emitter-base junction to avelanche and drain the current through the LED.