I am creating simple projects to understand how to work with the arduino uno and hm-10 module.
Currently, when I 'Read' from my hm-10, the output string is the Device Address. This has been the default since it was first used. I would like to send simple strings using this method. Is that possible?
Currently HM10.write() sends the string as a notification but i want to send the string such that when i connect in LightBlue, i can click 'read' instead of 'subscribe' to read the data.
Here is the code I am using:
#include <SoftwareSerial.h>
SoftwareSerial HM10(2, 3); // RX = 2, TX = 3
char appData;
String inData = "";
void setup() {
Serial.begin(9600);
Serial.println("HM10 serial started at 9600");
HM10.begin(9600); // set HM10 serial at 9600 baud rate
pinMode(13, OUTPUT); // onboard LED
digitalWrite(13, LOW); // switch OFF LED
}
void loop() {
HM10.listen(); // listen the HM10 port
while (HM10.available() > 0) { // if HM10 sends something then read
appData = HM10.read();
inData = String(appData); // save the data in string format
Serial.write(appData);
}
if (Serial.available()) { // Read user input if available.
delay(10);
//HM10.write(Serial.read());
}
if ( inData == "F") {
Serial.println("LED OFF");
digitalWrite(13, LOW); // switch OFF LED
HM10.write("Testing...");
}
if ( inData == "N") {
Serial.println("LED ON");
digitalWrite(13, HIGH); // switch OFF LED
HM10.write("Testing...");
}
}
allow me to clarify:). LightBlue works as expected. I’m hoping to learn how to send vs transmit the string. I’m building an app in Thunkable that can send/receive strings using the Arduino and ble module.
At the moment, I can send single character commands as strings but can’t get a string back.
Instead the string is sent back as garbled text (in my app) But in light blue, when I “read” from the device, the message is always the devices connectionId. Only when I subscribe in LightBlue do I see the string I am trying to send.