Reader small image

You're reading from  Hands-on ESP32 with Arduino IDE

Product typeBook
Published inJan 2024
PublisherPackt
ISBN-139781837638031
Edition1st Edition
Right arrow
Author (1)
Asim Zulfiqar
Asim Zulfiqar
author image
Asim Zulfiqar

Asim Zulfiqar is a blogger and tech content creator who has been writing tutorials on embedded systems and IoT on his blog and YouTube channel, High Voltages. Currently, he is working as a scientific programmer for IoT research projects. He completed his bachelor's degree in electronic engineering at Sir Syed University of Engineering and Technology, Pakistan. After that, he completed his Erasmus Mundus joint master's degree program in Photonics Integrated Circuits, Sensors, and Networks at Scuola Superiore Sant'Anna (Italy), Aston University (U.K), and Osaka University (Japan).
Read more about Asim Zulfiqar

Right arrow

Controlling the main entrance gate using the MQTT protocol

In this section, we will learn how we can control the appliances in IoT projects using the MQTT protocol. We will use the HiveMQ public MQTT broker, whose credentials are available at https://www.hivemq.com/mqtt/public-mqtt-broker/.

For the living room ESP32 microcontroller, we will upload the following code so that we can send the data to InfluxDB as well as receive the MQTT message to control the door lock. The connection diagram for the living room is provided in Figure 8.4. The code is available on GitHub at https://github.com/PacktPublishing/Programming-ESP32-with-Arduino-IDE/blob/main/chapter%208/livingroom/livingroom.ino:

#include <Adafruit_Sensor.h>
#include <DHT_U.h>
#include <WiFiMulti.h>
#include <InfluxDbClient.h> //https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino.git
#include <InfluxDbCloud.h>
#include <PubSubClient.h>
#include <ESP32Servo.h>
// WiFi configuration...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Hands-on ESP32 with Arduino IDE
Published in: Jan 2024Publisher: PacktISBN-13: 9781837638031

Author (1)

author image
Asim Zulfiqar

Asim Zulfiqar is a blogger and tech content creator who has been writing tutorials on embedded systems and IoT on his blog and YouTube channel, High Voltages. Currently, he is working as a scientific programmer for IoT research projects. He completed his bachelor's degree in electronic engineering at Sir Syed University of Engineering and Technology, Pakistan. After that, he completed his Erasmus Mundus joint master's degree program in Photonics Integrated Circuits, Sensors, and Networks at Scuola Superiore Sant'Anna (Italy), Aston University (U.K), and Osaka University (Japan).
Read more about Asim Zulfiqar