ESP8266 Bluetooth: HC05 Bluetooth interfacing with Nodemcu ESP8266

Bluetooth with ESP8266 NodeMCU, Description:


ESP8266 Bluetooth– You are already familiar with Nodemcu ESP8266 and ESP32 WiFi modules developed by the Espressif systems. ESP32 has the built-in low energy Bluetooth module which can be used with a custom designed android cell phone application for monitoring and controlling different types of electrical loads “Home automation using Bluetooth and Iot”.

On the other hand, the NodeMCU ESP8266 WiFi module is not provided with any Bluetooth device. It really doesn’t matter if it has no built-in Bluetooth module. We can still externally connect a Bluetooth module. So, before I am going to explain how to use a Bluetooth module like HC05 or HC06 with NodeMCU ESP8266, first a few words about the sponsor of this video.

 About the Sponsor, ALLPCB:

ESP8266 Bluetooth





24-Hours Lead Time

ALLPCB is the World’s Fastest PCB Manufacturing Company. Feel free to visit their website to not only find out what awesome PCB and assembly services they offer but also to easily upload your Gerber files and thus order affordable and High-quality PCBs quickly. Besides this, you will also get a 30 Dollars Coupon balance, which you can use to get your first prototype order for free.

In this tutorial, you will learn how to externally connect a Bluetooth module with the NodeMCU ESP8266 and display the Potentiometer or variable resistor value on the Oled display module and also send the potentiometer value to the android cell phone application designed in android studio.

ESP8266 Bluetooth

If you want to learn how to design your own android cell phone application then read my article on ”How to Create Android App for Arduino Sensor Monitoring over Bluetooth”. For the demonstration purposes I am using a potentiometer as the sensor connected with the analog pin of the ESP8266. This project can be easily modified by connecting other sensors as per your requirement.

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

Amazon Purchase Links:

Nodemcu ESP8266 WiFi Module:

LM7805 Voltage Regulator:

470uf capacitor:

DC Female Power Jack:

Female Headers:

Male Headers:

SSD1306 128×64 Oled i2c display Module

Bluetooth Module: Hc-05:

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!

SSD1306 Oled Display Module:

ESP8266 Bluetooth

If you look at both the Oled display modules it’s really hard to tell which one is the SH1106 and which one is the SSD1306 types. Each one uses a different Arduino Library. There are so many other types of the Oled display modules. The ones you can see in the image are the 128×64 I2C supported Oled Display modules. I have a complete tutorial on the Oled Display modules, which explains the basics and how to fix the most common issues including,

How to find the I2C address of the Oled display Module, how to install the correct Oled display Library etc. So, I highly recommend read my article on Oled Display Module. Previously I used the SH1106 Oled display Module, so this time I will use the SSD1306 Oled display, as this version of the Oled display module is quite popular.

128×64 Oled Pinout and Technical Specs:

ESP8266 Bluetooth

The SSD1306 Oled display Module has a total of 4 pins labeled as GND, VCC, SCL, and SDA. This Oled display Module can be easily powered up using 3.3V to 5V. This is a low power display module and can be easily used with the Arduino boards using 5 volts, and can also be used with 3.3V controller boards like ESP8266 and ESP32, etc.

HC05 Bluetooth Module Pinout and Specifications:

ESP8266 Bluetooth

This is the HC05 Bluetooth module. It has a total of 6 male headers clearly labeled as EN, VCC, GND, TXD, RXD, and STATE. Out of these 6 pins I will only use 4 pins VCC, GND, TXD, and RXD. This Bluetooth module can be easily powered up using 3.6 to 6V. Due to this wide range of input voltages it can be used with 3.3V and 5V supported controller boards without any problem. If you have never used this Bluetooth module then I highly recommend watch my getting started tutorial on the HC05 or HC06 Bluetooth modules in which I have explained how to use the AT commands and how to change the name of the Bluetooth module. I will provide a link in the description. I will also add links of the projects in which I have used the same Bluetooth module.

Nodemcu ESP8266 I2C Pins and Serial Communication Pins:

ESP8266 Bluetooth

Just like the Arduino Uno, Arduino Nano, and Arduino Mega, Nodemcu ESP8266 is also provided with the I2C bus. D1 is the SCL which is the GPIO5 and D2 is the SDA which is the GPIO4. Using D1 and D2 pins of the Nodemcu ESP8266 multiple I2C supported devices can be connected without any problem, as every I2C supported device has a unique address, which can be found by using the I2C scanner code given below. The Nodemcu ESP8266 is also provided with two serial ports which can be used with devices that support serial communication. So I will connect the HC05 Bluetooth module with the TXD0 and RXD0 available on GPIO pins 1 and 3.

HC05 or HC06 and Oled display SSD1306 interfacing with Nodemcu ESP8266:

ESP8266 Bluetooth

The HC05 Bluetooth module and Oled display SSD1306 interfacing with the Nodemcu ESP8266 Wifi Module is really simple. As you can see in the circuit diagram, there are no complicated connections. A potentiometer or variable resistor is connected with the analog pin A0 of the Nodemcu ESP8266. I am using this as the sensor, you can use any other analog sensor. So the middle wire of the Potentiometer should be connected with the A0 while the rightmost and leftmost legs should be connected with the 3.3v and gnd. You can interchange these two wires. Make sure the middle leg of the potentiometer is connected with the A0.

The Oled display Module I am using is an I2C supported display, means we can use I2C bus. Unlike the Arduino board, Nodemcu also has the I2C bus. D1 is the SCL and D2 is the SDA, while in Arduino the I2C bus is available on A4 and A5 pins. The SCL and SDA pins of the SSD1306 Oled display module are connected with the D1 and D2 pins of the Nodemcu ESP8266. The VCC pin of the Oled display is connected with the 3.3v pin of the Nodemcu ESP8266 while the GND pin is connected with the GND pin of the Nodemcu module.

The +5V or VCC pin of the HC05 Bluetooth module is connected with 3.3V. GND pin of the Bluetooth module is connected with the ground pin of the Nodemcu ESP8266. While the TX and RX pins of the Bluetooth module are connected with the RX and TX pins of the Nodemcu ESP8266.

As a beginner you can use your laptop to power up the Nodemcu module, and check your coding etc. For a permanent solution, you will need a power supply to power up all the electronics. For this you can make your own 5V regulated power supply. You can use the LM7805 Voltage regulator. The regulated 5 volts from the power supply are connected with the VIN pin of the Nodemcu ESP8266 WiFi Module. Make sure you connect the GND of the power supply with the GND pin of the Nodemcu Module. You can also see two capacitors each one is 470uF connected at the input and output sides of the voltage regulator. These are the Decoupling Capacitors.

For the easy connections I designed my own PCB board for the NodeMCU ESP8266 and added female headers for the Oled display module. Next, I started by adding the variable resistor and female headers for the Bluetooth module and carefully completed the soldering job. Finally, I started by interfacing the variable resistor and Bluetooth module with the Nodemcu ESP8266. This is how everything look after the final connections. Now, let’s take a look at the programming.

ESP8266 Bluetooth

First of all, I started by finding the I2C Address of the Oled Display Module. For this, I used the I2C Address Scanner code. You will need the Wire.h library to compile and upload the following code.

Download I2C library:

I2C address Scanner Code:

After uploading the code, Open your serial monitor to check the I2C address. Mine was 0x3C. You can use the above code for all the I2C supported devices. Now, I know exactly what is the I2C address, and I also know which type of the Oled display module I am using. So, now I will have no problem in writing the final code.

Before you start the programming, first of all, make sure you download the Wire.h, Adafruit_GFX.h, Adafruit_SSD1306.h, and SimpleTimer.h libraries. This is the basic programming for reading a Potentiometer connected with the Analog Pin A0 of the Nodemcu ESP8266 and then display the value on the Oled display module and also to send the Potentiometer values to the android cell phone application.

Download Libraries:

ESP8266 Bluetooth and Oled Display Programming:

ESP8266 Bluetooth and Oled Display Code Explanation:

You will need to add the final libraries, otherwise you won’t be able to compile and upload the code. The libraries download link is already given above.

#include <Wire.h>

#include <Adafruit_GFX.h>

#include <Adafruit_SSD1306.h>

#include <SimpleTimer.h>

Then I defined period, this defines how often you update the values on the Oled display module. you can increase or decrease the period as per your requirement. Currently, its 1 second.

#define REPORTING_PERIOD_MS     1000

SimpleTimer timer;

uint32_t tsLastReport = 0;

// for the OLED display

#define SCREEN_WIDTH 128 // OLED display width, in pixels

#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)

#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)


The Potentiometer is connected with the Analog pin A0. As I said earlier, you can use any other type of the analog sensor if you have. For the easy understanding I am using a potentiometer, which you can easily arrange.

int Potentiometer = A0;

A variable PotVal of the type integer. This will be used for storing the Potentiometer value.

int PotVal = 0;

void setup()




display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

timer.setInterval(2000L, getSendData);




void loop()

{; // Initiates SimpleTimer

if (millis() – tsLastReport > REPORTING_PERIOD_MS) {

Read the potentiometer and store the value in variable PotVal.

PotVal = analogRead(Potentiometer);

tsLastReport = millis();



getSendData() is a user defined function, it has no return type and does not take any argument as the input. This function is executed after every 2 seconds. The purpose of this function is to send the potentiometer value to the android cell phone application and also to display the values on the Oled Display Module.

void getSendData()


// To android cell phone application

Serial.print(“Pot Vale:”);


// Oled display


// display R G B Values


display.setCursor(0,0); // column row









I successfully uploaded the code.

Android Bluetooth application: 

Download the APK file:

After, you download and install the apk file. Turn ON the Bluetooth and pair the HC05 Bluetooth Module.  Now, open the android cell phone application.

ESP8266 Bluetooth

While the circuit is powered up. Click on the Search for paired devices. A list of the paired Bluetooth devices will be displayed. Select your Bluetooth device, in my case ELECTRONIC CLINIC. I changed the name of the Bluetooth module using AT commands. Anyhow, select the desired Bluetooth module and then click on the connect button.

I was able to monitor the Potentiometer value on the Oled display Module and also on the android cell phone application using the Bluetooth wireless communication.


ESP8266 Bluetooth

This was the most basic tutorial to help you get started with the Nodemcu ESP8266 and the HC05 Bluetooth module. If you have any questions regarding this article, let me know in a comment.

For video tutorials visit my YouTube Channel “Electronic Clinic”.

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

Leave a Reply

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

Back to top button