ESP32IOT Projects

ESP32 Bluetooth & Wifi together for Smart House / Home Technology


ESP32 Bluetooth & Wifi together- ESP32 Bluetooth + Wifi Module by the Espressif systems come with the built-in Low Energy Bluetooth Module which can be used just like the standard HC-05 or HC-06 Bluetooth Modules. The ESP32 Bluetooth module can be paired with all types of cell phones, and special android cell phone applications can be designed for monitoring and controlling different types of sensors and electrical loads.

I will start with the very basics explaining how to make a simple wireless text messaging system using the ESP32 Bluetooth module and the android cell phone application. After explaining the basic programming and circuit diagram then I will explain how to make a Smart House and control electrical loads using the ESP32 Bluetooth and an android cell phone application designed in Android Studio.

Later, in the end, I will explain how to use the ESP32 Bluetooth and Wifi together to make a Smart House/Home automation system. You will be able to control the electrical loads using the android cell phone application without using the internet and moreover it’s best for short-range communication. For the worldwide control system, we will make an application using the Blynk IoT platform. With the help of this application, the electrical loads can be controlled from anywhere around the world. Any load which is turned ON using the Blynk application can be turned OFF using the Android cell phone application and vice versa.

ESP32 Bluetooth

For every load to control strong passwords are used which can be manually entered using my designed android cell phone application, or you can make your own application, add some buttons and you don’t need to write the passwords.

ESP32 Bluetooth

Download Android Apps

Both the application can be downloaded by clicking on the download links given below.

Download Cell phone App1:Blueserial app

Download Cell phone App2:esp32 bluetooth

If you want to design your own android cell phone application then read my article “Android app development to control Arduino over Bluetooth using Android Studio” which explains step by step how to make your own android cell phone application using the Android Studio.

In this tutorial, we will cover,

  1. Circuit diagram explanation
  2. Basic, intermediate, and advanced code explanation
  3. Blynk application designing, and finally
  4. Testing

Without any further delay, let’s get started!!!

Note: For the step-by-step explanation and practical demonstration watch video tutorial given at the end of this article.

The components and tools used in this project can be purchased from Amazon and Banggood, the components Purchase links are given below:

Purchase from Amazon:

ESP32 WiFi + Bluetooth Module(Recommended)

LM7805 Voltage Regulator:

470uf capacitor:

DC Female Power Jack:

Female Headers:

Male Headers:

12v SPDT type 4-channel relay Module:

Other Tools and Components:

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!

ESP32 Bluetooth and Wifi Module Power Supply:

ESP32 Bluetooth

Let’s first start with the 5V regulated power supply based on the LM7805 voltage regulator. This is the same 5v regulated power supply I have been using for the Nodemcu ESP8266 Wifi module.

J1 is the female power jack and this is where we connect a 12v adaptor, battery, or a solar panel. Two 470uf capacitors are connected at the input and output sides of the voltage regulator. A 330-ohm resistor is connected in series with a 2.5v led. This is a current limiting resistor. The output of the voltage regulator is connected with the 5v pin of the ESP32 module and the ground of the power supply is connected with the ground of ESP32 module.

ESP32 Power Supply and Development Board:

For the easy interfacing, I designed my own ESP32 based development board as per the circuit diagram already explained. After I was done with the designing, I generated the Gerber files using the PCBWay online Gerber files generator tool, which hardly takes 2 to 3 minutes, and finally uploaded my Gerber files.

ESP32 Bluetooth
ESP32 Power Supply PCB board, ESPRESSIF ESP32 Devkit WROOM

This is the ESP32 power supply board after completing the Soldering Job, As you can see The PCB quality is really great. The silkscreen is quite clear and the Black Solder mask looks amazing, I am 100% satisfied with their work.

The PCB board used in this project is sponsored by the PCBWay Company. PCBWay is quite professional in the field of PCB manufacturing; you can try their services at extremely low prices, Only 5 dollars for 10 PCBs and 30 dollars in total for 20 PCBs assembly, besides this the new members also get a 5 Dollars bonus. The Gerber files of the ESP32 Wifi + Bluetooth Module can be downloaded by clicking on the link below.

Download: ESP32 Power Supply Gerber files

High quality & Only 24 Hours Build time:

Connect the ESP32 Bluetooth + Wifi Module with the laptop.

ESP32 Bluetooth

Before you start the programming, first of all, make sure you download the BluetoothSerial.h Library by clicking on the download libraries link given below, the library is available at 29 number.

Download Libraries:

ESP32 Bluetooth Example code:

Upload this simple sketch developed by Evandro Copercini, which I will modify in a minute but first the basics. So, at this point I changed the name of the Bluetooth device to ESP32 Electronic Clinic. The only purpose of this code is to send a text message from the computer serial monitor to the Android cell phone Bluetooth Application or from the android cell phone Bluetooth App to the computer serial monitor. After you upload the above program and While the ESP32 Bluetooth + Wifi Module is connected with the laptop, open the serial monitor, then open the android application1, the download link is already given above. Search for the paired devices, click on the  ESP32 Electronic Clinic, and click on the connect button. At this point, you should be able to send and receive messages.

ESP32 Bluetooth

This was a very basic example, which is perfect for testing the ESP32 Bluetooth module.

Now I will modify the circuit diagram and programming to control 220Vac light bulbs using only the ESP32 Bluetooth and an android cell phone application. Which I will further modify to make a Smart House/Home automation system using ESP32 Bluetooth & Wifi together.

ESP32 Bluetooth Smart House Circuit Diagram:

ESP32 Bluetooth

This is the final modified circuit diagram. It’s totally up to you if you want to control these relays using only the Bluetooth or using only the Wifi, or using Bluetooth and Wifi together.

Currently, I have connected a 4-channel relay module. You can use a readymade relay module or you can follow the same exact connections and build a one by yourself. All the relays used in this project are of the type SPDT “Single Pole and double throw”. As you can see the connections of all the relays are exactly the same. This relay has a total of 5 pins, two relay coil pins, common, Normally Closed, and Normally Open.

These are 12v relays and cannot be directly controlled using the ESP32 Module, So, that’s why we need a driver to control these relays. You can use a relay driver IC or you can use a 2n2222 NPN transistor and a 10k resistor. One pin of the relay coil is connected with the collector of the 2n2222 NPN transistor while the other pin of the relay coil is connected with the 12 volts. The emitter of the transistor is connected with the ground while the base is connected with the 10k ohm resistor.

Now to control these relays you simply need to connect these 10k resistors with the ESP32 I/O pins. In this project, I am using the GPIO pins 13, 12, 14, and 27. I will be using the same pins in the programming.

A Neutral wire from the 110/220Vac is connected directly with the neutral point of the Light Bulbs while the Live wire is connected with the Bulbs through the relays.

About the 4-Channel Relay Module:

ESP32 Bluetooth

This is a 4-channel relay module which I will use for controlling the light bulbs.

ESP32 Bluetooth

Finally, I connected everything as per the circuit diagram already explained. Now let’s have a look at the modified ESP32 Bluetooth programming.

ESP32 Bluetooth Smart House/Home Automation programming:

ESP32 Bluetooth Smart House/Home Automation Code explanation:

As you can see this is the same exact program, which I modified for controlling Home appliances. I defined pins for the relays and selected strong passwords so that nobody else can control the appliances. One password is used to turn ON the relay while the other password is used to turn OFF the relay. This is the same basic programming I used in the Car automation and anti-theft system which was based on the HC-05 or HC-06 Bluetooth Module. So for the detailed explanation read my article on the Car automation and anti-theft system. Finally, I uploaded the code into the ESP32 Wifi + Bluetooth Module.


While everything is powered Up, never touch the relays as 220Vac can be really dangerous, make sure you wear the protective gloves. Make this project at your own risk.

ESP32 Bluetooth

You can use this simple android application for controlling electrical loads, if you can remember passwords, you can also use short passwords, these are basically the commands which are used to control the relays, I know this is not user friendly, it wastes a lot of time, that’s why we designed another cell phone application using android studio.

ESP32 Bluetooth

This app is actually developed by my brother Fawad who is currently running another website So if you have any questions regarding the android application development you can visit his website.

Now, let’s modify the ESP32 programming so that the relays can be controlled using the Android Bluetooth cell phone application and also the Wifi technology. So for the worldwide control system, we will make an application using the Blynk application. So let’s start with the Blynk application. Follow the same exact steps.

Note: this old version of the Blynk app is no more functional. For the blynk mobile App setup and dashboard setup ready my article on the New Blynk V2.0. In this article I have explained how to migrate your projects from Blynk 1.0 to the new Blynk V2.0. You can also watch the video.

ESP32 Wifi Smart House/home automation Blynk Application:

  • First of all, open the Blynk application.
  • Click on the new project and enter the project name as “Home Automation”.
  • Click on the choose device and select ESP32 Dev Board.
  • Make sure the connection type is set to WIFI.
  • Finally, click on the create button, an authentication token will be sent on your email id, which later will be used in the ESP32 Home Automation
  • Click anywhere on the screen and add 4 buttons. Drag and drop, if you want to adjust the size.
  • Click on the first button, Set the name as Device1, select GP13, Set mode to SWITCH, and change the font size if you want.
  • Click on the second button, Set the name as Device2, select GP12, Set mode to SWITCH, and change the font size if you want.
  • Click on the third button, Set the name as Device3, select GP14, Set mode to SWITCH, and change the font size if you want.
  • Click on the fourth button, Set the name as Device4, select GP27, Set mode to SWITCH, and change the font size if you want.

That’s it our Home Automation Blynk application is ready.

ESP32 Bluetooth

ESP32 Bluetooth and Wifi Based Smart House Programming:

This is the final ESP32 Bluetooth and wifi Based Smart House programming. As you can see this time I added the library for the Blynk while the pins and passwords remain the same. I added the authentication code and the Wifi credentials.

In the void setup function, I added the blynk.begin() function and finally, in the void loop() function I added the function. The rest of the programming remains the same. So that’s all about the programming.

ESP32 Bluetooth

I successfully controlled the 110/220Vac light Bulbs using the Blynk application and also the Android cell phone Bluetooth application. If you have any questions regarding this project or any other project, let me know in a comment. Subscribe to my website and YouTube channel if you want to be notified each time I upload a new article or a new video on my YouTube channel “Electronic Clinic”.

Watch Video Tutorial:


Related Projects:

Download ESP32 Board Manager URL link, Programming, ESP32 Eagle library, ESP32 Datasheet:

ESP32 IoT based Home Automation Project “Previous Project”

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

Leave a Reply

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

Back to top button