Short explanation: data sent over the bluetooth serial does not arrive correctly to the Arduino.
Yesterday I connected a JY-MCU bluetooth module to my Arduino UNO R3 to test it. I connected the TXD and RXD pins to Arduino pins 10 and 11 respectively and used SoftSerial to communicate. I first tried some AT commands that I found online. After AT
returned OK
, I ran the code found here and got this output:
Starting config
OK
OKlinvorV1.6
OK57600
Done!
So the name and pin changed failed, but I (supposedly) changed the baud rate successfully. However, any further attempt to run any AT command failed (no output), even when I set the new baud rate (57600) in the soft modem. I then tried to pair it with my PC and used the following code to test:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11);
void setup() {
Serial.begin(9600);
mySerial.begin(57600);
delay(1000);
}
void waitForResponse() {
if (mySerial.available()) {
while (mySerial.available()) {
int a = mySerial.read();
Serial.println(a);
}
Serial.write("\n");
}
}
void loop() {
waitForResponse();
delay(2000);
}
In short, I wait for the module to receive something and then print the value of every byte. What's strange is that the data I send (using cutecom on the PC) is simply not correct - for example, sending the letter A (either lowercase or uppercase) outputs the number 161. However, sending two letters A outputs the numbers 161 and 176 despite the fact they are the same letter. I have very little experience with serial communication, but this looks like the baud rate is not correct. However, if this is the case, I don't know how to change the baud rate back to 9600 since I can no longer send AT commands to the module.
Any help on how to get the module to work properly or at least an explanation on what is happening here is more than appreciated.