Wio Terminal Update: How to use MQTT over TLS on the Wio Terminal by Benjamin Cabé

MQTT (Message Queue Telemetry Transmission) is an IoT Communication protocol built on the TCP/IP protocol of the Internet. There is no doubt that MQTT protocol has become a standard for IoT communications because it really has a lot of advantages.

We also posted an article that introduced the basic understanding of MQTT and will have a comparison between other internet protocols and MQTT.

Thanks to Benjamin Cabé’s project: use MQTT over TLS on Wio Terminal. We are looking forward to more projects from the community! Please also don’t be hesitate to let us know what update for Wio Terminal you want to see. We will carefully listen to the community and take action!

The following content firstly appeared on the GitHub kartben/wioterminal-mqtts-sample

Welcome to wioterminal-mqtt-sample ?

Image: kartben/wioterminal-mqtts-sample

This sample application shows you how to use MQTT over TLS on the Wio Terminal from Seeed Studio.

As PlatformIO supports the Wio Terminal, the sample comes in the form a PlatformIO project. This means that you don’t have to worry about installing the multiple Arduino libraries the Wio Terminal requires for Wi-Fi & TLS, and you don’t need to manually install the PubSubClient MQTT library either. All dependencies are automatically fetched from Github by the PlatformIO Library Manager.

In order to run the sample, just update the ssid and password variables in main.cpp with your Wi-Fi SSID and password.

const char *ssid = "<your-ssid>";      // your network SSID
const char *password = "<your-password>"; // your network password

Use the PlatformIO IDE (VS Code extension) or the PlatformIO command-line interface to deploy the application to your Wio Terminal.

Once running, the sample will connect to the public MQTT server running at mqtt.eclipse.org over TLS, publish “Hello from Wio Terminal” on the outTopic topic, and print on the serial output the contents of any message received on inTopic.

If you’d like to use a different MQTT broker, you will need to update the test_root_ca variable accordingly (it should be set to the root CA for the server you want to connect to).

IMPORTANT: A mistake that is often done when using the PubSubClient for real-world project, is to not pay attention to the fact that, by default, it’s defining a maximum MQTT message size of 256 bytes. Make sure to call PubSubClient::setBufferSize(size) with the desired message size if 256 bytes is not enough for your application.

Author

Benjamin Cabé

Contributing

Contributions, issues and feature requests are welcome!

Feel free to check issues page.

License

Copyright © 2020 Benjamin Cabé.

This project is MIT licensed.

About Author

Calendar

August 2020
M T W T F S S
 12
3456789
10111213141516
17181920212223
24252627282930
31