D. K.
Published

HC-05 Bluetooth - setup and troubleshooting

Setup and troubleshooting HC-05 Bluetooth module, especially the annoying reverse question mark problem.

BeginnerProtip1 hour250
HC-05 Bluetooth - setup and troubleshooting

Things used in this project

Hardware components

HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1

Software apps and online services

Serial Bluetooth Terminal

Story

Read more

Schematics

HC-05 Bluetooth module

Code

HC-05 Bluetooth module

C/C++
Setup HC-05 module and tun on and off a LED
int LED  = 13;
#include <SoftwareSerial.h>
#define BTTX 9 
#define BTRX 10
SoftwareSerial SerialBT(BTTX, BTRX); 

void setup()
{
SerialBT.begin(57600);                                
SerialBT.println("Bluetooth connection established"); 
}

void loop()
{
delay(300);
if (SerialBT.available())
  {
  String msg = SerialBT.readString();
  if(msg == "on\r\n")
    {
    digitalWrite(13, HIGH);
    SerialBT.println("LED is ON");
    }
    else
    if(msg == "off\r\n")
    {
    digitalWrite(13, HIGH);
    SerialBT.println("LED is OFF");
    }
  }
}

Credits

D. K.

D. K.

0 projects • 2 followers

Comments