/wioterminal-mqtts-sample

This repository contains a sample application showing how to connect the Wio Terminal to an MQTT broker over TLS (a.k.a. MQTTS).

Primary LanguageC++

Welcome to wioterminal-mqtt-sample 👋

License: MIT Twitter: kartben PlatformIO CI 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.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2020 Benjamin Cabé.

This project is MIT licensed.


This README was generated with ❤️ by readme-md-generator