Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ide/pico-door-sensor
Get notified when your door's been left open. Made with the Raspberry Pi Pico W and CircuitPython.
https://github.com/ide/pico-door-sensor
circuitpython mqtt raspberry-pi-pico-w rp2040
Last synced: 7 days ago
JSON representation
Get notified when your door's been left open. Made with the Raspberry Pi Pico W and CircuitPython.
- Host: GitHub
- URL: https://github.com/ide/pico-door-sensor
- Owner: ide
- License: mit
- Created: 2022-10-12T03:58:40.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-22T21:34:29.000Z (11 months ago)
- Last Synced: 2024-06-08T10:43:21.938Z (5 months ago)
- Topics: circuitpython, mqtt, raspberry-pi-pico-w, rp2040
- Language: Python
- Homepage:
- Size: 109 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](schematic/schematic.png)
### BOM
| Reference | Part description | Example part # |
|-----------|------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| R1 | 1K ohm current-limiting resistor (optional) | [CF14JT1K00](https://www.digikey.com/en/products/detail/stackpole-electronics-inc/CF14JT1K00/1741314) |
| R2 | 1K ohm pull-up resistor | [CF14JT10K0](https://www.digikey.com/en/products/detail/stackpole-electronics-inc/CF14JT10K0/1741265) |
| SW1 | SPST NC reed switch | [59140-4-S-02-F](https://www.digikey.com/en/products/detail/littelfuse-inc/59140-4-S-02-F/4780045) and [57140-000](https://www.digikey.com/en/products/detail/littelfuse-inc/57140-000/43978) |
| U1 | Raspberry Pi Pico W | [04025C104KAT2A](https://www.digikey.com/en/products/detail/kyocera-avx/04025C104KAT2A/6564238) |
| | 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) | |
## SoftwareInstall CircuitPython 8 on your Pico W using [a .uf2 file](https://circuitpython.org/board/raspberry_pi_pico_w/) from the CircuitPython website.
Create settings.toml under src or directly in your CIRCUITPY drive and define the following environment variables:
```toml
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.