A collection of scripts for setting up Raspberry Pi Pico W as smart home devices and sensors.
Feel free to contribute to this. If you've made something IoT with Rpi Pico make a PR with your code. Try and make it fit the style which I've created, including settings.toml
, mqtt.yaml
, instructions.md
, lib
, and main.py
.
Each directory is for each kind of device. main.py
is the main Python file that the microcontroller runs. lib
contains any libraries that that specific device needs. settings.toml
contains any configuration that each device needs. mqtt.yaml
indicates the entity setup for each device in Home Assistant. instructions.md
talks about the parts needed, what I used and how to solder everything together.
This is a brief overview. Look up a tutorial if you'd like more details
Note: I used a Raspberry Pi for my server, so I'm explaining the setup for Raspberry Pi. If you're using a different platform, the steps should still apply after step 3
- Download the Raspberry Pi Imager. Install it on your system. Flash the latest version of Home Assistant to a Micro SD card using the Imager. Pop it in your Pi and plug it in. (Raspberry Pi 4 is recommended. You can use Rpi 3B+ and other 3's but you may have poor performance.)
- Connect your pi to Ethernet and go to
homeassistant.local
in your browser. (If this is not working, check the IP address in your router and go to<ip_address>:8123
) - Wait for the initial setup to run.
- Head to
Settings > Add-Ons > Add-On Store
and search or find the Mosquito Broker. Install it and enableStart on Boot
andWatch Dog
. Start the add-on. While you're here, also install the File Editor add-on. You'll need it later. - Head to
Settings > Devices & Services
. Check the discovered section forMQTT
. Click Configure. Change the username and password and click Next. Just click Next again unless you want to customize anything on the next screen. - Now update your
settings.toml
on your Pico with the username, password and ip address of your broker. - Open the File Editor add-on from the sidebar and click the folder icon. Locate
configuration.yaml
. Paste the contents ofmqtt.yaml
for the Pico device you're setting up at the bottom ofconfiguration.yaml
. Customize thename
,object_id
, and the_topic
values. Ensure they match the_topic
values you've setup in each device'ssettings.toml
. - Repeat steps 6-7 for each Pico you're setting up.
- Smart Switch
- Occupancy Sensor (With PIR sensor?)
- Water Sensor (I have the parts, code coming soon!)