I am creating an app that sends Slider and Accelerometer data over bluetooth to an Adruino using HC05 Bluetooth Module.
I am using a timer so that app doesn't crash due to accelerometer sending data too frequently. I am also using variable "timer" that prevents values to be written to global variables t, xA, yA, zA, while they are being read. I have set the timer to 500ms.
I am able to setup a bluetooth connection and receieve values for a while untill the app freezes and then crashes.
Kindly Help
Feel free to ask to share any code or setup details
Thank You
Thank You for replying. I tried this but didn't help. I noticed that the app stops sending data at around 1 min 40 sec mark at every run. The connection stays live, then the app freezes and closes automatically after sometime.
@ABG I am not quite sure if I follow. I have set up so that the app sends data, and sketch recieves it. I think the sketch is listening but the app isn't talking. Apologies if that's not what you mean.
Yes, I am using serial to recieve data as well as print it on the Serial Monitor. Is it the incorrect method? Are there any known issues with this approach?
Update: I have been testing individual components and realized that is issue is with sending/recieving of the sent string.
If I send a single letter it keeps recieveing for quite long. However as soon as I switch to sending larger strings, it will jam up after certain time period and stop.
Update2: I changed the timer to send data at every 15ms and I am only sending letter A at each clock firing. I count the number of As recieved before it froze and it came out to be 631.
I realised what I was doing wrong. I didn't understand the working of Serial properly. I assumed that Serial.print just prints it on the Serial Monitor, but then I realised that it also sends printed lines.
The recieve buffer on the app/phone was filling up which caused the app to crash.
I created a Software serial to recieve data and used Serial to print data.
Dear all (@nex7-7 and @ABG ),
sorry not having responded earlier but I was travelling (I'm out for a historical car rally-race).
I see that you have already solved, and that's fine.
Have a great WE.
Cheers.