Connecting Pico W to Home Assistant

Hi guys

I’m very new to home automation stuff, and also very very new to any kind of raspberry pi stuff (this will be my first time even looking at them), so I just had a question about some things to make sure I’ve got my head around things before I go off buying stuff!

I’ve just started with getting home assistant up and running, and was curious about what automations I could incorporate about my place when I came across this guide and thought it could be super handy for some automations I want to do.

My main question with this guide (and all other guides I guess) is if there’s a way to get the Pico W connected up to home assistant and getting the distance as a sensor in HA I can use to read distances? I’ve seen a lot of stuff about ESP home and I think would be the way to go, but there’s a lot of talk about ESP32 boards and all sorts of stuff I have no idea about either :stuck_out_tongue:. While I’m still learning about HA and what it can do, I’ve never touched hardware stuff before, so there’s a lot I definitely don’t know about it!

Assuming it does work, my next question is if it’ll work with any of the Piicodev guides I’ve seen? There’s a guide for a motion sensor that looks perfect for another project, but I have no idea if it’s something that would even work, so I’ll need to do some thinking about that to figure out the details, both on the hardware and software side of things!

Thanks in advanced, and I look forward to hopefully being able to get into the raspberry pi ecosystem and get some projects underway!

2 Likes

Yes! It’s totally possible - I do it with some Piicodev modules and a Pico W myself.

The way I do it is to run a Mosquitto (MQTT) broker on the same computer my Home Assistant instance is running on. Then, I use the umqtt.simple module to communicate with Home Assistant (with the Home Assistant MQTT integration installed).

For example, you can set up an MQTT sensor manually in Home Assistant’s configuration.yaml file to listen to incoming messages from your Pico W - an easy one might be to have your Pico W read the temperature from a Piicodev atmospheric sensor every second, and publish this value to MQTT. You can then see the temperature in real time as a sensor in Home Assistant.

4 Likes

Hey!

To add to Stevens excellent response - there’s a discussion over on this topic where @Liam120347 shared some example code for a different PiicoDev module: PiicoDev BME280 with Pi Pico W - mqtt

We’re really keen to see what you create!

Liam

2 Likes

Also you’re not limited to simply reading sensors in Home Assistant. I use the Piicodev modules to run automations:

  • Piicodev distance sensor to turn on the LED strip inside my bookshelf on when I stick my hand in :joy:
  • Piicodev ambient light sensor to automatically dim or brighten my smart bulbs.
  • Piicodev LED modules to create your own smart lamp controlled from Home Assistant (I repurposed an old kid’s night light).

If something’s not possible or too difficult to program on the Pi Pico, what I do is to just use the Pico W to communicate with the Piicodev modules (via MQTT), and then program your computer to listen to incoming messages and do the “heavy lifting” for you. For home automation I use Node-RED because you don’t have to know any code - it’s flow-chart based programming and there’s a plugin to control Home Assistant, as well as supporting MQTT out of the box.

For anything more complicated, there’s Python.

I was wondering whether anyone else was using Piicodev with Home Assistant!

4 Likes

Thanks guys, this sounds amazing! I’m still very new to everything HA, so was hoping that I could just use HA and find an integration, and have the Pico W automatically turn up and work, but if not, at least there’s still a way with the MQTT stuff. That said, I’ll have to look into how exactly MQTT stuff works, but at least there’s ways to do it, which is awesome!

Also Steven, these automations are so cool - especially the bookshelf one! I love hearing about everyone’s HA automations and how they’re using it, so thanks for that!

1 Like

Hey @Opaquer and guys,

I have setup a full Pico W / PiicoDev BME280 integration using mqtt, NodeRed, Influx and Grafana.

Here is an overview

Kern Automation2

Cheers

Phil

1 Like

Opaquer,
there is direct support for Pico-W in ESPHome in HomeAssisant. All you need then is to add the distance sensor (e.g the Piico-dev VL53l1X).

Although the example in the guide is MicroPython, I’d try that to get to know the hardware. Actually if you have the cash get a piicodev Kit to try a few sensors.

Then try the HA/ESPHome integration, which uses yaml for the configurations and hides most of the programming and compiling etc.

BTW, if you end up with a lot of sensors, ESP8266’s probably work out cheaper, but getting started is the main thing.

Dave

2 Likes

That sounds like it could be good then if there’s direct support! I’ll check it out! Thanks for the heads up