Skip to content

Files

Latest commit

 

History

History
 
 

mqtt-client-Micropython

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

MicroPython MQTT client examples

In this example, we provide sample codes for connecting TCP and Websocket protocols to MQTT Broker. For more documentation on using the MicroPython MQTT client, please refer to MicroPython Documentation

Prerequisites

  • In this example, the OS is Raspberry Pi OS with desktop (Debian version: 10, 64-bit)

Install MicroPython

# When the operating system used by the Raspberry Pi is based on Debian version: 10, you can directly use the following command to install MicroPython sudo apt-get update
 sudo apt-get -y install micropython

 # Install using snap (recommended)
 sudo apt update
 sudo apt install snapd
 sudo reboot
 sudo snap install core
 sudo snap install micropython

# Install by source code compilation
https://docs.micropython.org/en/latest/develop/gettingstarted.html

Install dependent libraries

In order to connect to the MQTT server conveniently, we need to install the umqtt.simple library.

micropython -m upip install umqtt.simple

Run

micropython sub.py
micropython pub.py

Other

MicroPython MQTT Tutorial Based on Raspberry Pi