Hi, I wanna get some help on my HC-05 which is reading wrong data from a source. This module is working fine recently and communicating good with android phone and my ESP32. But earlier, when I tried to play again with my bluetooth car it didn't work. So I troubleshoot the project and found out that my HC-05 is reading the data in an odd way rather than it was supposed to.
For example, when I send a character "1" to my HC-05 it will read this as 49 13 10.
For troubleshooting I used Serial Bluetooth Terminal app.
And this is the code I used
No matter what else you are messing about with, using software serial on the hardware serial pins is a recipe for certain disaster, so you need to fix that first by putting software serial somewhere else.
just noticed you are using an ESP32 - which version? many have builtin Bluetooth Classic and BLE
also as @Nick_Pyner mentions why use SoftwareSerial on a device with Hardware serial ports
here is a ESP32 example using pins 15 and 16 as Serial1 hardware port
// ESP32 Serial1 test - for loopback test connect pins 16 and 15
#define RXD1 16
#define TXD1 15
void setup() {
// initialize both serial ports:
Serial.begin(115200);
Serial1.begin(115200, SERIAL_8N1, RXD1, TXD1);
Serial.println();
Serial.println("\n\nESP32 serial1 test Rx pin 16 Tx pin 15");
}
void loop() {
// read from port 1, send to port 0:
if (Serial1.available()) {
int inByte = Serial1.read();
Serial.write(inByte);
}
// read from port 0, send to port 1:
if (Serial.available()) {
int inByte = Serial.read();
//Serial.write(inByte);
Serial1.write(inByte);
}
}