Created
April 18, 2020 23:30
-
-
Save binitshah/a301d9e3522130d58ed9ef20e36e25d5 to your computer and use it in GitHub Desktop.
Basic chat program between Arduino Serial Monitor & connected Bluetooth Terminal. Switch baud rate for AT mode.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
HC05 - Bluetooth Verifier | |
modified on 10 Feb 2019 | |
by Saeed Hosseini | |
https://electropeak.com/learn/guides | |
Notes: | |
- when using Serial monitor, the "Both NL & CR" newline must be set | |
- BlE does AT FIRMWARE responses at baud rate 38400, reflected in code | |
- BLE does respond via AT to most commands, but to use AT+NAME?, you must hold power/reset button on ble module while pressing enter | |
- AT+ROLE -> 0 is slave, 1 is master | |
- AT commands: | |
AT -> OK | |
AT+RESET | |
AT+VERSION | |
AT+ADDR | |
AT+NAME *press reset key here* | |
AT+NAME=yourname | |
``` captured April 17th, 2020 | |
***AT commands mode*** | |
OK | |
OK | |
+VERSION:2.0-20100601 | |
OK | |
+ADDR:98d3:31:70727e | |
OK | |
+ADDR:98d3:31:70727e | |
OK | |
OK | |
OK | |
+ADDR:98d3:31:70727e | |
OK | |
OK | |
ERROR:(1A) | |
+UART:9600,0,0 | |
OK | |
+NAME:SHAHBLE | |
OK | |
+ROLE:0 | |
OK | |
+PSWD:1234 | |
OK | |
+UART:9600,0,0 | |
OK | |
``` | |
*/ | |
#include "SoftwareSerial.h" | |
SoftwareSerial MyBlue(3, 4); // RX | TX | |
void setup() | |
{ | |
Serial.begin(9600); | |
MyBlue.begin(9600); //Baud Rate for AT-command Mode: 38400 | |
Serial.println("***AT commands mode***"); | |
} | |
void loop() | |
{ | |
//from bluetooth to Terminal. | |
if (MyBlue.available()) | |
Serial.write(MyBlue.read()); | |
//from termial to bluetooth | |
if (Serial.available()) | |
MyBlue.write(Serial.read()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment