Hey guys,
Im just trying to read a small text called "*sync#", sent from an android app to the arduino via BLE module HM-10
Whenever i press a button, the app converts the string "*sync#" to bytes and transmits it.
But while receiving it in arduino, I am getting each character separately.
I want to read all the bytes at one go, and store it in a single String.
I have attached a screenshot of output in serial window.
Here is the arduino code:
#include <AltSoftSerial.h>
AltSoftSerial bt; //8,9 RX/TX
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
bt.begin(9600);
boolean flag;
String str;
}
void loop() {
if(bt.available())
{
String str="";
while(bt.available()>0)
{
char temp = bt.read();
str+=temp;
}
str+='\n';
Serial.print("Received string: ");
Serial.println(str);
}
}
I dont understand this behavior. Please help me out. Thanks in advance