Project tutorial
Bluetooth Chat

Bluetooth Chat

Enable a chatting interface between two serial monitors.

  • 6,151 views
  • 1 comment
  • 11 respects

Components and supplies

Apps and online services

About this project

I have used a HC-05 Bluetooth module which can be a master or a slave depending on the mode and a HC-06 Bluetooth module which is a slave.

Steps for HC-05 module:

  • The connections are shown in the schematic diagram. The Pin 34 should be kept high (3.3v) to ensure that the module enters into AT mode.
  • In the Serial monitor type the command AT+ROLE=1. This sets the HC-05 in master role.

Steps for pairing:

  • The communication mode baud rate (9600 bauds) has to be the same on both the devices.
  • We have to ensure that the passwords of both the devices should be same. This can be checked by typing AT+PSWD in the AT mode.
  • For HC-05 in AT mode, we should send the command AT+RMAAD which clears any previously paired devices and after that, by entering AT+RESET, the HC-05 is reset. Then enter the command AT+CMODE=0 which allows the HC-05 to connect to any device. Now enter the AT+INQ command which searches for Bluetooth devices. For my HC-06, the HC-05 module returned +INQ: 7683:10:171179, 1F00,7FFF which has the address of the HC-06 module.
  • For pairing the HC-05 to the HC-06, I used the command AT+PAIR=7683, 10, 171179,10. The pairing was successful and got an acknowledgement: OK.
  • For binding, I used the command AT+BIND=7683, 10,171179 and then entered the command AT+CMODE=1 which makes the HC-05 connect to only paired devices. Entering the command AT+LINK=7683, 10,171179 in the HC-05 links the HC-05 to the HC-06.
  • Now remove the pin34 to use the HC-05 communication mode and upload the code and test the chat.

This is the video URL: https://drive.google.com/open?id=0By8j-l_LkCjDelZONmJRWjJCYUE

Code

HC-05 Arduino codeArduino
#include <SoftwareSerial.h>
SoftwareSerial BTserial(4,2); // RX, TX
 
char c=' ';
 
void setup() 
{
    // start the serial communication with the computer
    Serial.begin(9600);
    Serial.println("Arduino with HC-05 is ready");
 
    // start communication with the HC-05 using 9600
    BTserial.begin(9600);  
    Serial.println("Bluetooth serial started at 9600");
}
 
void loop()
{
 
     // Read from HC-05 and send to Arduino Serial Monitor
    if (BTserial.available())
    {  
        c = BTserial.read();
        Serial.write(c);
    }
 
    // Read from Arduino Serial Monitor and send to HC-05
    if (Serial.available())
    {
        c =  Serial.read();
        BTserial.write(c);  
    }
 
}
HC-06 Arduino CodeArduino
#include <SoftwareSerial.h>
SoftwareSerial BTserial(4,2); // RX , TX

char m=' ';
 
void setup() 
{
    Serial.begin(9600);
    Serial.println("Arduino with HC-06 is ready");
 
    // HC-06 default baud rate is 9600
    BTserial.begin(9600);  
    Serial.println("Bluetooth Serial started at 9600");
}
 
void loop()
{
 
  // Read from HC-06 and send to Arduino Serial Monitor
  if (BTserial.available())
  {
    m = BTserial.read();
    Serial.write(m);
  }
 
  // Read from Arduino Serial Monitor and send to HC-06
  if (Serial.available())
  {
    m=Serial.read();
    BTserial.write(m);
  }
  
}

Schematics

HC-05 connections
Hc05%20schematic
HC-06 connections
Hc06%20schematic

Comments

Similar projects you might like

Bluetooth Controlled Pick And Place Robot

Project tutorial by Ahmed Ibrahim Ahmed

  • 16,811 views
  • 17 comments
  • 58 respects

Control the Speed of Brushless DC Motor Using Bluetooth

Project tutorial by mohitmehlawat

  • 8,637 views
  • 3 comments
  • 17 respects

Bluetooth Controlled Car

Project tutorial by JANAK13

  • 31,375 views
  • 30 comments
  • 55 respects

Bluetooth Controlled Servo

Project tutorial by JANAK13

  • 23,354 views
  • 24 comments
  • 46 respects

View Serial Monitor Over Bluetooth

by millerman4487

  • 20,179 views
  • 11 comments
  • 34 respects

Bluetooth Control RC Car

Project tutorial by electronicprojects

  • 3,367 views
  • 2 comments
  • 15 respects
Add projectSign up / Login