Connect Arduino with Computer using HC05 Bluetooth Module

At some point in time, you may want to connect and send some data to your computer from Arduino. In this article, I am going to tell you how to connect your Arduino with your computer using over Bluetooth using an HC05 Bluetooth module. For this little project, we will need an HC-05 and an Arduino board.

The Project

In this project, we are going to read the value from the temperature sensor, convert that into degree Celsius, and send the data to the computer. But, I don’t want to send the same value again and again, and that is why it only sends the temperature data when it receives a character from the computer. Here the character is (‘s’).

connect hc-05 with computer
Circuit Diagram

Connect the HC-05 with Arduino like it’s shown in the upper circuit diagram. Make sure that Rx of the Module should connect with the Tx of the Arduino and Tx of Arduino connects with the Rx of Module.

Once the circuit is made, you need to program the Arduino to make it capable to send and receive the data. The code for that is written down below.

The following code is taking the data from the temperature sensor and throw that data over to Serial. The Bluetooth module receives that data and sends it over to Bluetooth. On the computer side, you need a terminal software like “Putty” to receive and send data to Arduino via Bluetooth.

#include <math.h>
 #include <string.h> 
# define sensorPin A0
 const int B = 4275; // B value of the thermistor const int R0 = 100000; // R0 = 100k const int pinTempSensor = A0;
int ledPin = 13; 
void setup() { // declare the ledPin as an OUTPUT: 
    pinMode(ledPin, OUTPUT); 
    pinMode(sensorPin, INPUT); 
void loop() { 
    int val = analogRead(sensorPin); 
    float R = 1023.0/val-1.0; 
    R = R0*R;
    float temperature = 1.0/(log(R/R0)/B+1/298.15)-273.15; // convert to temperature via datasheet 
    int j=Serial.available(); if (Serial.available() > 0) { 
        char cmd;; if(cmd=='s'){ 
        Serial.println(temperature); delay(100);

The above code constantly waits for a character from the computer (or any connected device). As soon as it receives the character, it sends the temperature information to the device. The temperature sensor I am using is Grove temperature sensor and its conversion formula is given here.

Steps to connect to the Laptop

Open the Bluetooth manager of your OS and search for nearby Bluetooth devices. Below are the screenshots of the Windows.

Type 1234 or 0000 as a passcode

Once you find the HC-05 named module, pair it with your computer. Enter the passcode -1234 or 0000.

Once the pairing is complete, go to the Control Panel–> Device and Printers –> Unspecified Devices –> properties and note down the “comport” of the device.

Open up the serial terminal software like Putty, select the Com Port that you have noted down. Select the baud rate as 9600 and open up the port. Now you can communicate with the Arduino. As long as the port is opened, the communication will be established.

Additional Notes

You are able to send the data to the computer but you don’t know how to process it yet. For this, I have written a python program that sends or receives data from the COM Port that is created. The “serial” module of python gives us the capability to do this. The following code is able to send and receive the data to and from the Com Port. In the code, since you were able to capture the data in a variable, you should be able to process it according to your needs.

import serial
import time
import sys
import signal
def signal_handler(signal, frame):
	print("closing program")

COM=input("Enter the COM Port\n")
BAUD=input("Enter the Baudrate\n")
SerialPort = serial.Serial(COM,BAUD,timeout=1)
while (1):
		OutgoingData=input('> ')
	except KeyboardInterrupt:
		print("Closing and exiting the program")

If you want to change the baud rate of HC-05, refer to the footnote given below. The final execution of the above project looks like this.

python code for serial sending and recieving data serial port

Foot Notes

AT Commands of HC-05


1 thought on “Connect Arduino with Computer using HC05 Bluetooth Module”

Leave a Comment

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

Share This