Home Automation using Bluetooth of ESP32 with Videos (Hindi & English)




In this project, we will be dealing with the inbuilt Bluetooth feature in ESP32 Development board and try to build an application around it.

kunal verma

The Bluetooth system can be divided into two different categories: Classic Bluetooth and Bluetooth Low Energy (BLE). ESP32 supports dual-mode Bluetooth, meaning that both Classic Bluetooth and BLE are supported by ESP32. Here, we will control General Purpose Input Output (GPIO) pins of the ESP32 board using Bluetooth in classic mode and a customized Android application.

For more documentation, you can refer to Espressif IoT Development Framework here.  So, let’s get started.

Material required for the Bluetooth project

1. ESP32 NodeMCU (Check the datasheet, if you are using a different version.)

ESP32

ESP32

2. USB Type C cable to program ESP32 from a laptop or PC (most Android phones use this type of cable).

USB Cable

USB Cable




3. LED with Resistor(1K) – To test the Bluetooth

LED with a resistor

LED with a resistor

4. Breadboard – To place the components

Breadboard

Breadboard

Steps for the ESP32 support in Arduino IDE:

(Ignore this step if you already have the setup of ESP boards in Arduino IDE)

ESP32 support in Arduino IDE

ESP32 support in Arduino IDE

Here, to program the ESP32 we need an Integrated Development Environment and we will use Arduino IDE software. Arduino IDE is a cross-platform application. It is written in Java and coded in C/C++ with some special rules. To download the latest Arduino IDE from here.

Arduino IDE does not contain support of ESP32 family so to install the ESP-32 Board in Arduino IDE, you can refer here.

READ  Combo Blocks using an Arduino

The Code for Bluetooth in ESP32

Download the Code from the link below and Open it in Arduino IDE. Let’s understand the code.

Code declarations

Code declarations

Firstly, we will declare the Bluetooth libraries in the code. All the declaration like Led pin, states and UUIDs are declared here. To have more details on UUID refer here.

Classes

Classes

Then, we will create two classes. MyServerCallbacks is created to check the server connection and MyCallbacks to perform the various functions.

Hence, this function contains the LED controlling part of the Bluetooth and prints the value received. One may also include some inputs to fetch data like temperature or humidity. The android application will give commands like “A” and “B” which will be received by the ESP-32 BLE and will generate the same results. These classes are created to call in the Void Setup() and most of the part of the code is set up here only.

Void Setup()

Void Setup()

All the characteristics of Bluetooth and device name will be declared here including the start of various services like UART and BLE Server.

The baud rate is by default set to 115200  and pin 5 declared as LED will be set to OUTPUT.

Circuit Connections:

There is only one Output (LED) in the circuit you can add many more outputs or set inputs.

ESP32 Pin 5 -> Resistor

Resistor -> LED +ve

LED -ve -> Ground

Connections

Connections

Using the Android Application:

You can download the android application from here(.apk download link) and use it or edit this using Thunkable.

READ  Arduino Bluetooth Serial Connections

Thunkable

Thunkable

We have created this app for the ESP Bluetooth and you may use it to control the LED or Light.

 

Read More Detail :Home Automation using Bluetooth of ESP32 with Videos (Hindi & English)




Leave a Comment

*
= 4 + 1

(Spamcheck Enabled)

Read previous post:
thingerok_RFTdvh6YTN
Arduino MKR1000 & Thinger

A simple Internet of Things experiment, using an Arduino MKR1000 board to control two LEDs and monitor a potentiometer, via...

Close
Scroll to top