I've been cracking my head over this for a long while.
Like many before me, I'm trying to send and receive data from a HM-10 bluetooth module, arduino mega adk and the app called BLE Scanner. I've figured out receiving alright. Whatever I write into the serial monitor, shows up on the app. Whatever I write into the software serial, shows up. However, I haven't figured out how to read from the software serial. The available function never gets triggered, and always printing out the software serial read is always -1
The app supports sending data over bluetooth as well. However, using:
#include <SoftwareSerial.h>
SoftwareSerial blueSerial(14, 15); //RX, TX
blueSerial.begin(9600);
Serial.begin(9600);
while (1)
{
blueSerial.listen();
if (Serial.available()) {
Serial.println("Writing");
blueSerial.write(Serial.read());
Serial.println(Serial.read());
Serial.println(blueSerial.available());
}
if (blueSerial.available()) {
Serial.println("Blueserial writing");
Serial.write(blueSerial.read());
}
}
The listen function is used out of pure desperation.
How do I fix this? This should be working right? Since I want to be sending AT commands to the bluetooth modules at some time and read their output, getting this to work is really important.