Use Adafruit IO with a Raspberry Pi Pico W to create IoT dashboards using MQTT

I decided recently to set up a string of temperature sensors around our house to work out the temperature profile of different rooms.

With the recent release of the Pico W, I realised that I could do this quite simply, as long as I could find a way to “nicely” display the data.

You’ll have read my exploits with Anvil last week, I expect, and saw that I didn’t have much luck. However, I knew that Adafruit had their very own IoT platform – Adafruit IO – and that it had been around awhile, so I thought I’d give that a try and document it.

Set-up your Adafruit account

Go to and register an account if you don’t have one. You’ll be creating Feeds and Dashboards in a bit.

Assemble your hardware

For this project, I’m using:

  • A Raspberry Pi PicoW
  • An Adafruit AHT20 I2C temperature and humidity sensor

As you can see, I’ve soldered them together. I’ll put a 3D printed case together at some point, I’m sure.

Assemble your software

For this project, I’ve used Micropython for the PicoW and then loaded the Pico up with an MQTT client and an AHT library as follows:

The code

The code is in several files and can be found on my GitHub repository.

  • – the main code that holds it all together
  • – defines the “name of the device” by way of a “feed prefix” which is used to tie the Adafruit IO feeds together with the device.
  • – credentials etc. There’s a sample secrets file in the repository so you know what to put in it.
  • The two libraries as mentioned above.

Adafruit IO set-up

Set-up your with a feed prefix – this can be anything by mine’s called temp_sensor_1.

Then, create two feeds in Adafruit IO: <prefix>_temperature and <prefix>_humidity. For example, temp_sensor_1_temperature etc.

Create a dashboard by adding Graph boxes that bring in those feeds.


In theory, running the script through Thonny should show you the sensor readings as well as connection success/failure for wifi and notification of when the readings are published via MQTT to Adafruit IO.

You should end up with something like this on Adafruit:


If you’re trying to do this, you probably have questions – leave a comment and I’ll try and get back to you! 🙂

5 comments for “Use Adafruit IO with a Raspberry Pi Pico W to create IoT dashboards using MQTT

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.