Skip to content

wezm/garage-door-monitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Garage Door Monitor

Build Status

A small application that monitors the state of my garage door and sends an alert to Mattermost if it gets left open. The application is deployed to a minimal custom Linux installation running on a Raspberry Pi Zero W.

The binary that monitors the garage door is in the app directory. It is implemented in Rust. The buildroot directory contains the Buildroot configuration for building the Raspberry Pi image. The hardware directory contains a wiring diagram and 3D model for a spacer I 3D printed to mount the reed switch to.

The system image, which includes the kernel, busybox, openntp, rsdate, wpa_supplicant, and the monitoring application itself is about 13Mb. It is stored on a 256Mb micro SD card, which is the smallest I could get my hands on. The system boots and is interactive in less than 5 seconds and runs entirely from RAM (the microSD card is not even mounted).

Building

Note: These instructions assume a Linux host.

To build the Linux image you will need to download and extract Buildroot as well as install its system requirements. I used the stable 2021.08 release.

Clone the repo then populate two configuration files:

  • buildroot/overlay/etc/default/garage-door-monitor — Web-hook URL. E.g.

    GARAGE_WEBHOOK="https://example.com/"
    
  • buildroot/overlay/etc/wpa_supplicant.conf — Wi-Fi configuration. E.g.

    network={
        ssid="NetworkName"
        psk="password"
    }
    

In the directory of the extracted Buildroot (E.g. buildroot-2021.08) load the configuration:

make defconfig BR2_DEFCONFIG=../path/to/garage-door-monitor/buildroot/configs/garage_defconfig

Now point Buildroot at the external tree in this repository and kick off the build. This will build the toolchain, kernel, and root file system. Note that for subsequent rebuilds you can use make without needing to specify BR2_EXTERNAL as this is remembered:

make BR2_EXTERNAL=../path/to/garage-door-monitor/buildroot

The SD card image is output to: output/images/sdcard.img. Write it to an SD card with dd or similar. Be sure to double check the path to the SD card device (/dev/sdd in this case):

sudo dd if=output/images/sdcard.img of=/dev/sdd bs=128k

Wiring

  • A reed switch is connected between 3.3V and header pin 38 via a 10kΩ resistor. Internal pull-downs are enabled on the pin.
  • The anode of a 3mm LED is connected to header pin 40 via a 220Ω resistor.
  • The Pi is powered through header pins 4 (5V) and 6 (GND).

See also the Fritzing wiring diagram in hardware.

Licence

This project is dual licenced under either of:

at your option.