Skip to content

Instantly share code, notes, and snippets.

@GreenMoonArt
Last active September 15, 2016 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GreenMoonArt/4a073058e4edfbb193946736e7b2b334 to your computer and use it in GitHub Desktop.
Save GreenMoonArt/4a073058e4edfbb193946736e7b2b334 to your computer and use it in GitHub Desktop.
Modify The HC-05 Bluetooth Module Defaults
// thanks to http://www.instructables.com/id/Modify-The-HC-05-Bluetooth-Module-Defaults-Using-A/
// wiring diagram: https://cdn.instructables.com/FM8/W4A2/HKZAVRT9/FM8W4A2HKZAVRT9.LARGE.jpg
/*
AUTHOR: Hazim Bitar (techbitar)
DATE: Aug 29, 2013
LICENSE: Public domain (use at your own risk)
CONTACT: techbitar at gmail dot com (techbitar.com)
Procedure to ensure AT Command Mode (identified by slow-blinking LED on HC-05) has been entered:
0. Unplug power from HC-05
1. Upload sketch from above Instructable
2. Hold in HC-05 button (above EN/Key pin)
3. Reconnect power to HC-05
4. Wait until LED blinks slowly
5. Release HC-05 button
6. Press Arduino reset button
7. Open Serial Monitor - baud rate = 9600
8. Make sure "Both NL & CR" is selected
9. Type AT commands - examples:
• AT (should get response "OK")
• get current firmware version: AT+VERSION?
• get current name : AT+NAME?
• change name to "Joe" : AT+NAME=Joe
• get device name : AT+RNAME?
• change default security code from 1234 to 2987 : AT+PSWD=2987
• get module's address : AT+ADDR?
• restore factory defaults : AT+ORGL
To return to Bluetooth communications mode, disconnect power from HC-05, then reconnect.
To reduce power consumption, explore the SNIFF and IPSCAN commands
http://www.edaboard.com/thread267303.html
*/
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11); // RX | TX
void setup()
{
pinMode(9, OUTPUT); // pull HC-05 pin 34 (key pin) HIGH to switch module to AT mode
digitalWrite(9, 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