fbpx

MQTT on ESP32 | Controlling appliances & Monitoring Sensor data over Internet using Ubidots MQTT server

ESP32 is a most advanced board till now in the field on IOT. It has great features, great performance and ofcourse a it’s easily available at a very reasonable price. Till now I have made several tutorial videos on this ESP32 board using Arduino IDE. If you are not familiar with using ESP32 board, kindly watch my ESP32 Series in which I have covered all major topics related to using ESP32 board.

In this article I’ll be talking about a step ahead then that tutorial series. In this article, I’ll let you know how you can make a practical working project using this board and some other components through which you’ll be able to control appliances and also be able to monitor sensor’s data over internet by using free MQTT service provided by Ubidots.

Components Required
  • ESP32 Devkit V1 board
  • 5V single relay module
  • General Purpose PCB
Circuit Diagram
Working of the Project

This project uses Ubidots platform for sending and receiving data over internet via MQTT protocol. Configuring Ubidots server for MQTT is quite simple and you can do it in just 2 mins.

So in the code, we are subscribed to one MQTT topic and and we are publishing data to another MQTT topic. In the subscription part, we are monitoring the data which is coming from the server. If the data received is 1 then we are turning on the relay which is attached to the ESP32 board,and if we are receiving 0 from the server then we are turning the relay off.

While in the publish part, we are first of all collecting the data of inbuilt Hall effect sensor on our ESP32 baord and then publishing the data to the server. We can monitor the data and we can control the relay from a web browser using the Ubidots dashboard. Hence we can control the ESP32 board both from our mobile phone as well as laptop.

To know how to configure Ubidots server and how the code for this project works, kindly watch out my full tutorial video on this project.

Code 

You can download the code used in this project form my GitHub account.

Tutorial Video