If you don't want to have your own broker, but you want a secure MQTT connection you can use a cloud MQTT instance, such as http://iotcentral.eu.
First create an account on
iotcentral.eu and confirm your email address. After that you can log in to
iotcental.eu and get your private assigned topic. It is an eight character code, such as
c5c05211, and this code needs to precede all of your topics as follows:
No matter if you publish or subscribe. The following code connects to the Wi-Fi and then establishes a secure connection to the
iotcentral.eu cloud MQTT over port
8883. Every message sent to the
iotcentral.eu broker is received back like a loopback.
Included header files are the
ESP8266WiFi and the
PubSubClient MQTT class:
#include <ESP8266WiFi.h> #include <PubSubClient.h>
12 will be used later to blink a LED every time a message is received and GPIO
13 will be changed to
HIGH every time a...