#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
void setup() {
// put your setup code here, to run once:
mySerial.begin(9600);
Serial.begin(9600);
Serial.println("debug1");
mySerial.write("AT");
Serial.println("debug2");
while (mySerial.available() > 0) {
Serial.println("debug3");
Serial.write(mySerial.read());
}
}
void loop() {
}
I have this code here, slightly edited from something found in a github repository, It sends an command to a AT-09 BLE module, and is supposed to wait for a response. As you can see, there are 3 debug notes, of which 2 appear. Debug 3 which is found in the while loop does not appear in serial monitor. According to official Arduino documentation, the .available checks how many bytes are available to read, and here I check if it is above 0, which it should be if the BLE module responds with OK, so what is the issue? is there a problem with the module where it is not responding to the command?
Edit: Some unmentioned details: I am using an Arduino nano (old bootloader), and when i remove the while loop, there is something that responds, but it is not the "OK" expected. Instead it provides a � character