If you do not want to host your own MQTT broker, using Adafruit IO's MQTT broker is a great way to get started connecting your CircuitPython project to the internet. Best of all - it's free to use!

You're going to build an Adafruit IO Dashboard which can visualize incoming data from your CircuitPython board, and send data to it.

Obtain Adafruit IO Username and Key

If you have not already, sign up for an Adafruit IO account by clicking this link

Next, you're going to need your Adafruit IO username and secret API key.

Navigate to your profile and click the View AIO Key button to retrieve them. Write them down in a safe place, you'll need them later.

Create Adafruit IO Feeds

Adafruit IO uses a special type of MQTT Topic named a Feed to store data along with metadata (information about the data). You'll be publishing data to one feed, and subscribing to another.

Create two new Adafruit IO Feeds named onoff and photocell.

  • photocell - This feed will store light data published from your device to Adafruit IO
  • onoff - This feed will act as an on/off switch, publishing data to your device from Adafruit IO

If you have not created an Adafruit IO Feed before, follow this page and come back once you've the created two feeds above.

Create an Adafruit IO Dashboard

Adafruit IO Dashboards are a way to interact with feeds. You can link blocks on dashboards to your feeds. The blocks can either display information about the feed (such as the current temperature) or allow you to interact with a feed by setting it to different values.

Start by creating a new dashboard. Name it whatever you'd like!

Create a Gauge Block

After creating a dashboard, create a Gauge Block to display the value of the Photocell feed.

  • Choose the photocell feed
  • Change the block title to Photocell
  • Set the Gauge Minimum Value to 0
  • Set the Gauge Maximum Value to 1024

If you do not know how to add blocks to a dashboard, head to over this page and come back when you've added a gauge block to your dashboard.

Create a Toggle Switch Block

To send values to the onoff feed you created - create a toggle switch block.

  • Choose the onoff feed
  • Set the block title to On/Off
  • Set the Button On Text to ON
  • Set the Button Off Text to OFF

Your dashboard should look like the following:

This guide was first published on Jul 23, 2019. It was last updated on May 20, 2024.

This page (Connecting to the Adafruit IO MQTT Broker) was last updated on Mar 08, 2024.

Text editor powered by tinymce.