Code Example

A warning note icon.This section is currently being reworked. We apologize for the inconvenience. If you need immediate assistance, please contact Tibbo Support.


To illustrate the use of the MQTT library, we have created two simple Tibbo BASIC applications called "mqtt_publisher" and "mqtt_subscriber".

You can download them here: tibbo.com/programmable/applications.html (scroll to or search for the "MQTT Library Demo" and download mqtt_demo.zip).

In our MQTT demo, the publisher device is monitoring three buttons (Tibbits #38). This is done through the keypad (kp.) object.

The three buttons on the publisher device correspond to the red, yellow, and green LEDs (Tibbits #39) on the subscriber device.

As buttons are pushed and released, the publisher device calls mqtt_publish() with topics "LED/Red", "LED/Green", and "LED/Red". Each topic's data is either 0 for "button released" or 1 for "button pressed". The related code is in the on_kp() event handler.

The subscriber device subscribes to all three topics with a single call to mqtt_sub() and the line "LED/#". This is done once, inside callback_mqtt_connect_ok().

With every notification message received from the server, the subscriber device gets callback_mqtt_notif() invoked. The LEDs are turned on and off inside this functions's body.

Testing the MQTT demo

The demo was designed to run on our TPS3 boards, but you can easily modify it for other devices. The easiest way to get the test hardware is to order "MQTTPublisher" and "MQTTSubscriber" TPS configurations from our website: tibbo.com/store/tps/custom.html.

You can also order all the parts separately:


MQTT Publisher, based on the TPP3 board, shown without the TPB3 enclosure


MQTT Subscriber, based on the TPP3 board, shown without the TPB3 enclosure


Test steps

Code Example

Testing the MQTT demo

Test steps