Skip to content
Snippets Groups Projects

Pico W Garage Door Sensor

Get notified when your garage door's been left open. This sensor uses the Raspberry Pi Pico W and CircuitPython and requires Home Assistant with MQTT set up.

Hardware

The Raspberry Pi Pico W is powered by a standard 5V USB Micro B power supply.

GPIO 22 is pulled up to 3.3V with a 10K ohm resistor. This external pull-up resistor is stronger than the Pico's internal pull-up resistors that can be configured on the GPIO pins and helps reduce the effects of ESD on the long wires from the Pico to the reed switch. GPIO 22 also has an optional 1K ohm current-limiting resistor (even a lower value like 100 ohms is fine) to protect it from shorting to ground in case it is misconfigured as an output pin.

Why GPIO 22? It doesn't have any alternative function like SPI, I2C, or ADC. This leaves all the other GPIO pins free if you want to attach a screen or other peripherals to your Pico.

You could add a small capacitor to debounce the reed switch in hardware but this project debounces the GPIO pin in software.

Schematic

Schematic

BOM

Reference Part description Example part #
R1 1K ohm current-limiting resistor (optional) CF14JT1K00
R2 1K ohm pull-up resistor CF14JT10K0
SW1 SPST NC reed switch 59140-4-S-02-F and 57140-000
U1 Raspberry Pi Pico W 04025C104KAT2A
USB Micro B power supply (5V@1A is plenty)
Stranded copper wire, 22-24 AWG (long enough to reach your garage door from the Pico and back)

Software

Install CircuitPython 8 on your Pico W using a .uf2 file from the CircuitPython website.

Create settings.toml under src or directly in your CIRCUITPY drive and define the following environment variables:

CIRCUITPY_WIFI_SSID = "your Wi-Fi access point's name"
CIRCUITPY_WIFI_PASSWORD = "your Wi-Fi password"

MQTT_HOSTNAME = "your MQTT broker's hostname"
MQTT_USERNAME = "the username to use with your MQTT broker"
MQTT_PASSWORD = "the password to use with your MQTT broker"

WIFI_HOSTNAME = "garagesensor"

There are convenient scripts under the scripts directory for deploying software to your Pico W and connecting to its REPL. Only macOS is supported.