Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
ESP8266 Home Automation Projects

You're reading from   ESP8266 Home Automation Projects Leverage the power of this tiny WiFi chip to build exciting smart home projects

Arrow left icon
Product type Paperback
Published in Nov 2017
Publisher Packt
ISBN-13 9781787282629
Length 196 pages
Edition 1st Edition
Tools
Arrow right icon
Authors (2):
Arrow left icon
Constantin Tambrea Constantin Tambrea
Author Profile Icon Constantin Tambrea
Constantin Tambrea
Catalin Batrinu Catalin Batrinu
Author Profile Icon Catalin Batrinu
Catalin Batrinu
Arrow right icon
View More author details
Toc

Securing a connection between ESP8266 and an MQTT broker


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:

c5c05211/living/temperature

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> 

GPIO 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...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image