- How to Adjust X and Y Axis Scale in Arduino Serial Plotter (No Extra Software Needed)Posted 3 months ago
- Elettronici Entusiasti: Inspiring Makers at Maker Faire Rome 2024Posted 3 months ago
- makeITcircular 2024 content launched – Part of Maker Faire Rome 2024Posted 5 months ago
- Application For Maker Faire Rome 2024: Deadline June 20thPosted 7 months ago
- Building a 3D Digital Clock with ArduinoPosted 12 months ago
- Creating a controller for Minecraft with realistic body movements using ArduinoPosted 12 months ago
- Snowflake with ArduinoPosted 1 year ago
- Holographic Christmas TreePosted 1 year ago
- Segstick: Build Your Own Self-Balancing Vehicle in Just 2 Days with ArduinoPosted 1 year ago
- ZSWatch: An Open-Source Smartwatch Project Based on the Zephyr Operating SystemPosted 1 year ago
MQTT Library Demo
Web site:
http://tibbo.com/programmable/applications/mqtt_library_demo.htmlProject Summary:
This is the demo project for Tibbo's MQTT library. The project demonstrates how easy it is to create sophisticated network-enabled applications in Tibbo BASIC and Tibbo C. The code is extremely simple and easy to understand. Take this app and modify it for your MQTT needs.
Full Project:
To illustrate the use of the MQTT library, we have created two simple Tibbo BASIC applications called “mqtt_publisher” and “mqtt_subscriber”.
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 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.
You can also order all the parts separately:
- On the publisher side:
- TPP3 board in the TPB3 enclosure.
- Your will need Tibbits #00-3 in sockets S1, S3, S5; and
- Tibbits #38 in sockets S2, S4, S6;
- You will also need some form of power, i.e. Tibbit #10 and #18, plus a suitable 12V power adaptor.
- On the subscriber side:
- TPP3 board in the TPB3 enclosure.
- Your will need Tibbits #00-3 in sockets S1, S3, S5;
- Tibbit #39-2 (red) in S2;
- Tibbit #39-3 (yellow) in S4;
- Tibbit #39-1 (green) in S6;
- You will also need some form of power, i.e. Tibbit #10 and #18, plus a suitable 12V power adaptor.
Test steps
- Install a suitable MQTT server. We suggest HiveMQ (www.hivemq.com):
- Download the software here: www.hivemq.com/downloads/ (you will be asked to register).
- Unzip the downloaded file.
- Go to the “windows-service” folder and execute “installService.bat”.
- Go to the “bin” folder and launch “run.bat”.
- You do not need to configure any user names or passwords.
- Open mqtt_publisher and mqtt_subscriber projects in two separate instances of TIDE, then correct the following in the projects’ global.tbh files:
- OWN_IP – assign a suitable unoccupied IP to the publisher and to the subscriber (you know that they will use two different IPs, right?);
- MQTT_SERVER_HOST – set this to the address of the PC on which your run HiveMQ.
- Select your subscriber and publisher devices as debug targets, and run corresponding demo apps on them.
- Press buttons on the publisher to see the LEDs light up on the subscriber.
- If you are running in debug mode you will see a lot of useful debug info printed in the output panes of both TIDE instances.
- You can switch into the release mode to see how fast this works without the debug printing.
Firmware:
Source Code:
http://tibbo.com/downloads/open/mqtt_demo.zip
Documentation:
http://docs.tibbo.com/taiko/mqtt_library.htm
Minimum TiOS version: | 3.60 |
http://tibbo.com/support/downloads/tios.html
Platform: | TPS3W |
Try it on: | Custom TPS configurations “MQTTPublisher” and “MQTTSubscriber” |
Software & Code Snippets:
Minimum TIDE version: | 5.00.00 |
http://tibbo.com/support/downloads/tide.html