Bluetooth puzzle

I have a Bluetooth LE connected to the board. It sends constantly a >70 bytes message to an Android application, at an interval of 5 seconds. The maximum packet of data is 20 bytes. There is a button connected to the Arduino board which when pushed sends some other data to the Android application.

The problem is that the time based data overlaps sometimes with the data sent by the push button.

Any strategy to obtain consistent data on the Android application?

Sure, don't send the two data packets at the same time. Wait until one is sent before sending the other. If I could see your code I might have better help with how exactly to do that.

Thanks Delta.

I know that I should send the data alternatively, but how do I know when is some data in process of being transmitted?

This is the most important part of the code from the sketch:

// ble
Adafruit_BluefruitLE_UART ble(Serial1, -1);
void setup(void){  
   
  // the button
  pinMode(buttonPin1, INPUT);

  // Pulse Sensor
  interruptSetup();  
  
  Serial.print(F("Initialising Bluetooth LE module: "));
  if(!ble.begin()){
    Serial.println("Could not find a Bluetooth, check wiring!");
    while (1);
  }
  
}

int buttonState1 = 0;         
int oldState1 = 0;


void loop(void){  
      
  // Get current button state.
  buttonState1 = digitalRead(buttonPin1); 
  if (buttonState1 == HIGH) {    
    oldState1 ++;    
  } else {    
    oldState1 = 0;    
  }
  if(oldState1 == 1){    
    // Send to BLE    
    ble.print("AT+BLEUARTTX=");            
    ble.println("{'apiCall':'check'}|");            
  }  
  
  
  checkStats(); 

  
  // Check for incoming characters from Bluetooth
  ble.println("AT+BLEUARTRX");
  ble.readline();
  if (strcmp(ble.buffer, "OK") == 0) {
    // no data
    return;
  }else{
    int apiCode = atoi(ble.buffer);   
    if(apiCode == 0){                  
      getStats();
    }    
  }  
  ble.waitForOK();
}
int getStats(){  
    d_stats = "{'d_stats':[{'t':'" + tas + "','h':'"+has+"','p':'"+pas+"','a':'"+aas+"','hrm':'"+ias+"'}]}|";    
    ble.print("AT+BLEUARTTX=");  
    ble.println(d_stats);
    
}
int checkStats(){      
      if (QS == true){            
        heartRate = BPM;                                         
        QS = false;
      }
      tas = 1; has = 2; pas = 3; aas = 4; ias = 5;    
    return 0;  
}

You wrote the code, you tell it when to send what. It's not going to send anything on its own. The sending happens in the places in your code where you tell it to send something. When you tell it to send one thing, don't start sending the next thing until you're done.