i bought the HM 10 Bluetooth controller (CC2541), i got connect on this device through Serial Bluetooth Terminal (Android App) with Serial BLE menu this method not requires any pass and "Connected" state is showed and the led on CC2541 is always HIGH now, but... any command sended from terminal or sended from serial arduino is not show and "AT+NAME" or "AT+NAME?" returns null everytimes, this is my code to run Bluetooth on Arduino Mega2560:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(26, 27); // RX, TX
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("Goodnight moon!");
delay(500);
// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
mySerial.print("Wake up wake up wake up wake up wake up! Wake up wake up wake up wake up wake up!");
}
void loop() // run over and over
{
if (mySerial.available()) {
String s = "";
char c;
while((c = mySerial.read()) != -1) {
s += c;
delay(10);
}
Serial.println("Received: " + s);
}
if (Serial.available()) {
String s = "";
char c;
while((c = Serial.read()) != -1) {
s += c;
delay(10);
}
delay(10);
Serial.println("Sent: " + s);
mySerial.print(s);
}
}
Example of output serial monitor:
Sent: AT+DEFAULT
Sent: AT+BAUD9600
Sent: AT+HELP
I never receive "Received" status...
mySerial
instead ofSerial1
(and of course the initialization stuff of SoftwareSerial). Also: Are you sure, that the HM-10 module listens for AT commands at 9600 baud? Have you tried other baudrates? – chrisl Sep 10 '20 at 19:30SoftwareSerial
has problems with the high baudrates (for example 115200), so you can stop there – chrisl Sep 10 '20 at 19:35