Tuesday, July 23, 2019

MQTT in CircuitPython

So, you have a CircuitPython project and want to connect it to the internet? You may want to consider adding MQTT to your project. MQTT is an extremely popular and lightweight protocol which can connect your project to the internet and quickly process network events.

MQTT is a small, lightweight protocol which is incredibly easy to use in scenarios where bandwidth is at a premium, your project is sending a small amount of data every so often, or if you'd like to process network events incredibly quickly (clicking a button would cause your project to do something).

We've built a robust MQTT module for CircuitPython called CircuitPython MiniMQTT to quickly get you started connecting your projects to the internet and sending data around.

In this guide, you will set up your CircuitPython board with the necessary libraries, connect to the internet and connect your CircuitPython board to either a MQTT broker of your choice or the free Adafruit IO MQTT broker. We've included code-walkthrough and advanced usage sections to this guide so you can roll your own MiniMQTT project!

Note: MiniMQTT currently only supports CircuitPython devices connected using WiFi. It does not yet support other modes of network transports - such as Ethernet.

You'll need a CircuitPython board which either has network connectivity built-in or external network hardware .

All-in-One CircuitPython WiFi Boards

Don't want to add extra hardware to your project? Consider grabbing a board which has an ESP32 WiFi co-processor built-in!

Externally Connected CircuitPython Network Hardware

If you already have a project which uses a CircuitPython board without internet connectivity, you can easily add WiFi connectivity with an externally connected AirLift module.

If you're using an Adafruit Feather, adding WiFi connectivity to your project is as easily as snapping the the AirLift FeatherWing on top.

If you're using a CircuitPython board with an Arduino form-factor, you'll want to pick up an AirLift Shield.

If none of the form factors above work for your project - we also have a breakout board which can connect to any microcontroller over SPI.

No comments:

Post a Comment