Low Energy Bluetooth BLE for ESP32 Series and Bluetooth 5 & Onwards

Low Energy Bluetooth BLE:

Low Energy Bluetooth BLE for ESP32 Series and Bluetooth 5 & Onwards– I have designed my own Low Energy Bluetooth application for the ESP32 series of controllers. This application can be used with all Bluetooth modules and controller boards that support Bluetooth Low Energy (BLE) Technology.

Low Energy Bluetooth BLE

Why did I make my Low Energy Bluetooth application? And why should you also make a BLE application? Which Bluetooth versions can you use with a BLE application? And what are the benefits of making a BLE application? You will get answers to all these questions, 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)

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*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!

Low Energy Bluetooth BLE

Starting with the most popular Bluetooth Modules HC05/HC06. I have used these Bluetooth modules in many projects to control loads and monitor sensors. I have also published an article on “Android App Development” where many people have read it and made their own applications.

HC05 and HC06 Bluetooth modules are based on the Bluetooth 2.0 + EDR “Enhanced Data Rate”. Let me also tell you EDR was first introduced in Bluetooth 2.0, offering faster data transfer rates compared to the original Bluetooth 1; which was the initial version of Bluetooth with limited data transfer rates and relatively short ranges.

Anyway, HC05 and HC06 Bluetooth Modules do not support Bluetooth Low Energy BLE Technology. Because, these are based on the Bluetooth Classic standards which is different from the Bluetooth Low Energy (BLE) Technology.

So, all those applications that I made for HC-05 and HC-06 Bluetooth Modules do not work with Low Energy Bluetooth Modules like Bluetooth 4.0, Bluetooth 5.0, and newer versions.

Let me also tell you; the Bluetooth Low Energy BLE technology was introduced in Bluetooth 4.0. The aim was to significantly reduce the power consumption and to enable new types of applications like trackers, smart watches, fitness, and IoT devices. And then

Bluetooth 5 brought several improvements including higher data transfer rates, longer range, and enhanced advertising capabilities for BLE.

So, the applications that you used with Bluetooth versions 1 and 2 will not work at all with Bluetooth 4 and Bluetooth 5. So, you will need to design completely separate applications for Low Energy Bluetooth Modules. But the question is, how do we make a BLE application?

So far, everyone I have seen on YouTube is using ready-made Low Energy Bluetooth applications. In fact, in the beginning, I also downloaded the nRF Connect Application from the Play Store to test the range of the XIAO ESP32C3 onboard Bluetooth.

Low Energy Bluetooth BLE

Although I successfully controlled the loads, but what I really didn’t like was, every time I had to type the command to turn the load ON or OFF. And to be very honest, as an engineer, I didn’t feel good at all about using a ready-made application.

And furthermore, we just can’t use the same application everywhere. I want to create my own application for each device and add features according to my preference. So, I decided to design my own Low Energy Bluetooth (BLE) application. It took me almost 6 to 7 months to create a completely bug-free BLE application.

We can use this with all the ESP32 Variants. Because all the ESP32 boards support both Bluetooth Classic (BR/EDR) and Bluetooth Low Energy BLE protocols. So, to explain this point; I am going to test my designed BLE Application with these two boards.

Low Energy Bluetooth BLE

On the left side is the WEMOS Lolin32 V1.0.0 version of the ESP32 and let me tell you it doesn’t come with Bluetooth 4 or Bluetooth 5 but it still can be used with the BLE applications because it supports both Bluetooth Classic and Bluetooth Low Energy protocols.

And the one on the right side is the XIAO ESP32C3 and it comes with an onboard Low Energy Bluetooth 5.0.

First let’s start with the basic ESP32 WiFi + Bluetooth module.

Low Energy Bluetooth BLE

For the connections you can follow this circuit diagram; if you want to wire up all your components on a breadboard.

About the Hardware:

Low Energy Bluetooth BLE

For demonstration purposes, I have connected 4 Blubs but you can connect any AC or DC loads.

If you are thinking about using 110/220Vac supply, you need to consider safety.


When the 110/220Vac supply is connected, never touch the relay contacts as it can be extremely dangerous. It is important to note that when working with mains voltage, proper safety precautions should always be taken and it is advisable to consult relevant electrical codes and standards.

Don’t worry about the libraries; because all the libraries are automatically installed when you install the ESP32 board. For installing the ESP32 board, you can read my getting started article on the ESP32.

WEMOS Lolin32 ESP32 Code:

About the BLE Application:

Before, when I used older applications, I had to manually select and connect the device after opening the application. But now, when I open this BLE application, it automatically connects to the device.

Low Energy Bluetooth BLE

The communication is quite fast and responsive. I have also added a feedback feature in it, and it can also remember the status of the loads.

Let’s say I want to keep these 2 lights ON.

Now, if for some reason the power disconnects or there is a power outage, the controller will remember the previous state of the loads. So, as soon as the power connection is restored, these lights will automatically turn ON.

In the video, I also demonstrated its feedback functionality. For now, let’s imagine these loads are installed in another room. After a couple of hours, I want to switch one of these loads on or off, but I have forgotten which one I turned ON or turned OFF. To eliminate this kind of confusion, I have integrated a feedback feature in this application. As soon as I open the application on my cell phone, ESP32, through Bluetooth, provides me with feedback on which load is currently on and which one is off. This ensures seamless control and eliminates any confusion. For the practical demonstration, I highly recommend watch my video available on my YouTube Channel “Electronic Clinic”.

Now, let’s go ahead and start with the XIAO ESP32C3.

Low Energy Bluetooth BLE

This is my Hardware setup for the XIAO ESP32C3, the connections are exactly the same except the pin numbers, and don’t forget to follow the safety protocols. For the connections you can follow this circuit diagram.

Low Energy Bluetooth BLE


The code is also exactly the same except the pin numbers. And the coolest thing is, for the XIAO ESP32C3 you don’t need to do anything. When you install the ESP32 board, all its variants are installed including the XIAO ESP32C3. You can check this in the boards list.

Low Energy Bluetooth BLE

You can see the XIAO ESP32C3 is available in the boards list. If you are not able to find the XIAO ESP32C3 in the boards list then you will have to update your boards list through the board’s manager URL link. Anyway, then all you need is to select the XIAO ESP32C3, select the communication port, and click on the Upload button and that’s it. I have already uploaded this program; so, let’s go ahead and start practical demonstration.

BLE App for XIAO ESP32C3:

This is the same BLE application, but this time I have added the Bluetooth address of the XIAO ESP32C3 in the application code. All other features and functionality are exactly the same.

Low Energy Bluetooth BLE

You can download the source code of this BLE application from my Patreon Shop at a very reasonable price. Then, you can modify this BLE application according to your preference. You just need to have a little knowledge of Android Studio.

Once you learn to make BLE applications, you can launch your own products. You can control and monitor things like bikes, cars, loads, sensors, and many other things. You can sell these products on platforms like Amazon just like me. You can create amazing projects for your international clients. So, what are you waiting for? Download the BLE application source code and get started!

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

One Comment

  1. App looks great, but the biggest challenge I’ve come across with BLE on all these devices is that none of them support Bluetooth passkey/pin pairing. For me this makes it very insecure. One would like to pair a device to their phone so that no other device can connect at random.
    There seem to be some hacks on the older boards, but none for the newer boards.
    Do you perhaps know if this will be done anytime in the near future?

Leave a Reply

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

Back to top button