ESP32

ESP32 Ubidots IoT Project, Two-way Communication

ESP32 Ubidots IoT Project:

ESP32 Ubidots IoT Project, Two-way Communication– In today’s article, we are diving into something super exciting; two-way communication between Ubidots and the ESP32! Imagine not just sending data from your ESP32 to the cloud, but also controlling your devices remotely, all in real-time.

ESP32 Ubidots iot project two way communication

It’s been 5 years since I last used the Ubidots IoT platform. I got busy with other projects, and over time, I completely forgot about Ubidots. But recently, I had to work on an IoT project that was pretty complex.

allpcb circuit

First, I tried it on Blynk, then on some other IoT platforms I remembered, but none of them worked.

So, I started checking my old IoT projects to see which platforms I had used before. Honestly, in these 5 years, I worked on so many IoT platforms that I even forgot the names of some.

While going through my projects, I came across Ubidots, and I immediately felt that the idea I wanted to implement could work 100% on it.

As an experiment, I tried one of my old projects, but I was shocked because every time I tried to compile the code, I got errors. Then I thought, “It’s been 5 years; maybe a lot has changed.” And I was right; so much had changed over the years. Anyway, I successfully completed that project. And I also decided to write this “getting started” article to help others who might be struggling to compile their old codes or run new ones.

So, without any further delay, let’s get started!!!




Amazon Links:

ESP32 WiFi + Bluetooth Module (Recommended)

Other Tools and Components:

Arduino Nano USB C type (Recommended)

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

About the Hardware:

custom ESP32 Ubidots

I am going to use this ESP32 development board. This is the same development board I used with the SIM7600G 4G LTE module. In that article, I explained the circuit diagram and its assembly, so make sure to read it. The reason I selected this development board is that it already has a relay, which I am going to use to control a 110/220Vac bulb. For the relay connections, you can follow this circuit diagram.



Relay interfacing with ESP32:

ESP32 Ubidots relay connection circuit diagram

Required Libraries for the Ubidots:

First, download these two libraries from the Ubidots official website.

ESP32 Ubidots mqqt main arduino library

Then, open the latest version of the Arduino IDE. Before installing the required libraries, you need to first install the ESP32 board in the Arduino IDE. To do this:

  1. Go to the File menu and then to Preferences.
  2. Copy the link given below and paste it into the Additional Boards Manager URLs.



Boards Manager URL:

ESP32 Ubidots board installation link

Next, click on the Boards Manager and search for “ESP32.”

arduino ide board manager ESP32 Ubidots installation in arduino ide

Make sure to install the one by Espressif Systems. As you can see, I have already installed it.

To verify that the ESP32 board is installed in the Arduino IDE:

  1. Go to the Tools menu.
  2. Navigate to Board, then ESP32, and you will see all the variants of the ESP32.

ESP32 Ubidots variants module

The one I am using is the ESP32 Dev Module. If you are using a different ESP32 board, simply select it from the list.

Finally, go ahead and install the required libraries. I am sure you know how to install the libraries, if not then you can watch the video at the end of this article.

Now, let’s move on and work with Ubidots.



Ubidots Dashboard:

While you are logged-in into your Ubidots account. Go to the Data Menu and then click on the Dashboards.

ESP32 Ubidots iot cloud platform

On the left side, you can see these 3 lines, click on those three lines next to the New Dashboard.

Click the CREATE button to add a new Dashboard.

Let’s name it Home Automation, let’s keep everything else to their default values. Once you learn the basics, then you can come back and play with all these properties. Anyway, let’s click the SAVE button.

how to create a new ESP32 Ubidots dashboard

Our Home Automation Dashboard is ready.

ESP32 Ubidots home automation dashboard

Now, go to the Devices Menu and click on Devices.

Click the + button to create a new device.

Click on Blank Device.




Now, go to the Arduino program and copy the DEVICE_LABEL “home_automation” and paste it in the two boxes. The device label should exactly match the DEVICE_LABEL set in the Arduino code. Once the Device name and Device label are set then click the NEXT button.

ESP32 Ubidots home automation

You can see a new device with the name home_automation has been created.

create a new ESP32 Ubidots device

Let’s open this device.

ESP32 Ubidots token

Right now there are 0 Variables, because I have not yet uploaded the program into the ESP32. Because I needed this Token. So, let’s copy this Token and paste it in the program next to the UBIDOTS_TOKEN.



ESP32 Ubidots Programming:

Upload the program and then go back to the Ubidots and refresh the page.

ESP32 Ubidots sensor data from esp32

Now, you can see the counter variable. Let’s also create a variable for controlling the relay. For this go back to the Arduino IDE and copy this “relay1”.

Click on the + button to add a new variable and paste the text “relay1”.

ESP32 Ubidots variables

The two variables counter and Relay1 are ready.



Now, go to the Data menu and click on the Dashboards.

While the Home Automation Dashboard is selected, click on Add new Widget to add a new widget or you can also click this + Button at the top right corner.

ESP32 Ubidots adding a widget

You will see so many widgets, for now you can add a Gauge for displaying the counter value.

Click on the + ADD VARIABLES.

Click on the home_automation.

ESP32 Ubidots gauge

You can see the two variables, since we want to display the counter value on the Gauge, so we are going to select the counter variable.

ESP32 Ubidots gauge

On the APPERANCE tab, you can name the Gauge Widget, you can change the font, and most importantly you can specify the range. For now 0 to 100 range looks just fine. Once you are done with the settings; click the SAVE button.



Now, let’s add a switch for controlling a Relay. The steps are exactly the same.

ESP32 Ubidots two way communication

Our dashboard is now ready, and it’s looking great!  You can already see the counter value displayed in real-time on the Gauge; it updates instantly, giving you live data feedback.

ESP32 Ubidots

But that’s not all! Check out this button right here; it’s not just for show. With a single click, we can control the relay, turning it on or off with ease.

ESP32 Ubidots iot project




Imagine the possibilities! Using this dashboard, you are not limited to just one application.

ESP32 Ubidots sensor monitoring

You can monitor sensor data like temperature, humidity, or motion, and at the same time, control different types of loads;

ESP32 Ubidots relay controlling

Be it lights, fans, or even appliances right from your phone or computer. And the best part? You can do all of this from anywhere in the world!

Whether you are sitting at home, traveling, or even halfway across the globe, this dashboard keeps you connected and in control. How cool is that?

So, that’s all for now.



Watch Video Tutorial:

 

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button