Skip to content

Instantly share code, notes, and snippets.

@jnsdbr
Created January 7, 2017 19:13
Show Gist options
  • Save jnsdbr/d8468f86edb0d113c903099fc8981ff7 to your computer and use it in GitHub Desktop.
Save jnsdbr/d8468f86edb0d113c903099fc8981ff7 to your computer and use it in GitHub Desktop.
ATCommands for the HC05 Bluetooth breakouts
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11); // RX | TX
/**
* TX -> 10
* RX -> 11
* KEY -> 6
*
* Set baudrate in Serial monitor to 38400!!!
* Connect Module after arduino is started!
*
* Commands:
* AT
* AT+VERSION
* AT+NAME=NAME
* AT+PSWD=1234
* AT+UART=115200,1,0 // Baudrate, stopbit, parity
*/
void setup()
{
pinMode(6, OUTPUT); // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
digitalWrite(6, HIGH);
Serial.begin(9600);
Serial.println("Enter AT commands:");
BTSerial.begin(38400); // HC-05 default speed in AT command more
}
void loop()
{
// Keep reading from HC-05 and send to Arduino Serial Monitor
if (BTSerial.available())
Serial.write(BTSerial.read());
// Keep reading from Arduino Serial Monitor and send to HC-05
if (Serial.available())
BTSerial.write(Serial.read());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment