Here is the code I'm using from Martyn Currey for my HM10 module:
#include <AltSoftSerial.h>
AltSoftSerial BTserial;
// AltSoftSerial Library, for an extra serial port
char c=' ';
boolean NL = true;
void setup()
{
Serial.begin(9600);
Serial.print("Sketch: "); Serial.println(FILE);
Serial.print("Uploaded: "); Serial.println(DATE);
Serial.println(" ");
BTserial.begin(9600);
Serial.println("BTserial started at 9600");
}
void loop()
{
// Read from the Bluetooth module and send to the Arduino Serial Monitor
if (BTserial.available())
{
c = BTserial.read();
Serial.write(c);
}
// Read from the Serial Monitor and send to the Bluetooth module
if (Serial.available())
{
c = Serial.read();
// do not send line end characters to the HM-10
if (c!=10 & c!=13 )
{
BTserial.write(c);
}
// Echo the user input to the main window.
// If there is a new line print the ">" character.
if (NL) { Serial.print("\r\n>"); NL = false; }
Serial.write(c);
if (c==10) { NL = true; }
}
}
I am able to successfully type something in the serial monitor and receive it on my iPhone using the BLExAR app. But when I send anything from that app to the HM-10 the serial monitor doesn't display anything. I think it is because the BTSerial.available always returns 0, though I'm not sure why that is. To try to get more information, I used the iPhone BLE Scanner app's Custom Service to write to the module. Upon doing that, I noticed that it will not actually read the value until I then manually read the value from the app. Even after reading the value though it only displays "No value. Value - String at .
Looking for any suggestions since googling isn't helping much and I am very new to the BLE stuff.