Bluetooth app crashes after certain time period

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

Maybe this handshake approach will help:


1 Like

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.

Dear @nex7-7,
to avoid that the app goes to sleep you can use an extension made by @taifun ( :muscle: !!!)
that features the following block:
You can invoke this block into the screen1 initialization. In such a way the app remains active "forever" until you close it :

@uskiara Thank you for replying
I tried this fix, but no avail.

The following is the arduino sketch that I am running to recieve data. I shared incase I am doing something incorrectly.

const int LED = 13;
char switchstate;
void setup()  {
  pinMode(LED,  OUTPUT);
void loop() {
    switchstate =;

So the sketch talks but the app doesn't listen?

Is this a buffer filling up?

1 Like

@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.

Serial is both the incoming Bluetooth stream and the output Bluetooth stream?

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?

I am stumped.

Better call in a hardware guy like @uskiara

@ABG Thank you for helping out.
Just wanted to share that HC05 is connected to arduino like following:

HC05 Arduino
+5V +5V

Shared incase that helps the discussion

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.

Thank You @ABG

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.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.