Git Product home page Git Product logo

garage-indicator's Introduction

Garage Indicator Project

This project uses Raspberry Pi Pico W microcontrollers to read the state of a door sensor (such as a reed relay, hall effect switch, snap action switch) and wirelessly send the state of the door to an indicator node using an MQTT broker.

Click the thumbnail below to see a quick video overview of the project:

A circuit board inside an enclosure inside a garage

Parts

  1. 2x Raspberry Pi Pico W microcontrollers, one for the sensors and one for the indicator.
  2. 1x Raspberry Pi computer (or other system) with an MQTT broker installed. See this guide for installing Mosquitto. You could also use a cloud-based MQTT broker.
  3. WiFi network coverage at both sensor and indicator nodes.
  4. 2x door sensors. These could be hall effect sensors, reed relays, or snap action switches, anything that will be able to close the connection between GND and the GPIO pin on the Pico W. I used these hall effect sensors and they worked perfectly. I 3D-printed brackets to attach these sensors to my garage.
  5. 3x LEDs, green each for open, red for closed, and yellow for changing. This is the LED assortment that I have.
  6. Hookup wire. I used this 22 AWG hookup wire for the perfboard and this 3-conductor hookup wire between the sensors and the project enclosure.
  7. Solderless breadboard or perfboard. This is the perfboard that I used, but basically anything will do.
  8. Enclosure for the project. This is the one that I used for the project. Of course, even Tupperware could work, depending on the environment.

Disclosure: The Amazon links above are affiliate links. I'll make a small commission if you buy from Amazon using that link.

Setting up the code

The file indicator.py is for the Pico with the LED output. The file sensor.py is for the Pico with the door sensors. The best way to do this is to upload all files to all the Picos and then add a main.py file with one line: either import indicator or import sensor. Each Pico will also need a config.py file which defines the following:

network = "Wi-Fi network name here"
network_password = "Wi-Fi password here"
mqtt_server_address = "URL or IP address to MQTT broker here"

You'll need to install umqtt.simple. Do so in the REPL like this:

import network
import config
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(config.network, config.network_password)
import mip
mip.install("umqtt.simple")

NOTE: Older versions of the MicroPython firmware use upip instead of mip for package management. If mip does not work, try updating your firmware or use upip.

If you want to add MQTT authentication to your set up, you'll need to update this line:

client = MQTTClient(client_id, mqtt_server, keepalive=0)

to this:

client = MQTTClient(client_id, mqtt_server, keepalive=0, user="USERNAMEHERE", password="PASSWORDHERE")

in each file. Consider including these fields in your config.py file.

Installation

This section is in progress.

MQTT broker

As mentioned above, I used this guide for installing Mosquitto. I used the same Raspberry Pi on my network that is also running my VPN server.

Most home networks use DHCP to assign IP addresses to devices. I'd recommend going into your router settings to give your MQTT broker system a DHCP reservation so that you can be sure that it always gets the same IP. This process will depend on what router you have.

I haven't tried a cloud-based MQTT broker yet.

Sensor node

Refer to the official Raspberry Pi Pico W pinout documentation for help with the wiring.

  1. I soldered the Pico W to the perfboard so that the Wi-Fi antenna on the end is "hanging off" the edge of the perfboard. I don't want the copper in the perfboard to interfere in any way with the Wi-Fi reception.
  2. I soldered two sets of 3 pin terminal blocks to the perfboard.
  3. Each terminal block gets a connection to VSYS and GND to power the sensors. I soldered hookup wire for that.
  4. Each terminal block gets a connection to its own GPIO pin. As you'll see in the code, I'm using pins GP21 and GP22.
  5. You can use the USB port on the Pico W for powering the project. Or solder another power connector to VSYS.
  6. Mount the perfboard inside the enclosure.
  7. Drill holes in the enclosure for the power and sensor cables. I used cable glands like these for the wires that are going out of the enclosure.
  8. Connect the sensors to the screw terminal blocks. On my sensors, the brown wire goes to VSYS, the blue wire goes to ground, and the black wire goes to GPIO. Your sensor may be different; check its data sheet or labeling.

Indicator node

For now, the indicator node is just a Raspberry Pi Pico W with headers inserted into a breadboard with LEDs on GP16, GP17, and GP18. I intend to create a proper enclosure for this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.