manuargue / thingsboard-micropython

Unofficial ThingsBoard MQTT MicroPython client
Apache License 2.0
9 stars 7 forks source link

ThingsBoard MQTT MicroPython client

This project is a MicroPython library that provides an client for the Device API of ThingsBoard open-source IoT Platform.

The library consists of a thin wrapper around the MicroPython MQTT module, umqtt.robust.

Installation

To install using pip:

import upip
upip.install('thingsboard-micropython')

Getting Started

Client initialization and telemetry publishing:

from uthingsboard.client import TBDeviceMqttClient

# See examples for more authentication options
client = TBDeviceMqttClient('demo.thingsboard.io', access_token='test01')

# Connecting to ThingsBoard
client.connect()

# Sending telemetry
telemetry = {'temperature': 41.9, 'enabled': False}
client.send_telemetry(telemetry)

# Checking for incoming subscriptions or RPC call requests (non-blocking)
client.check_msg()

# Disconnecting from ThingsBoard
client.disconnect()

Examples

More examples can be found in examples directory.

Support

Acknowledgment

This library is an adapted version of the official ThingsBoard client SDK for Python, to run in MicroPython.

License

This project is released under Apache 2.0 License.