HC-05 delay

Hi!

I am trying to have two arduinos communicate over bluetooth, for now one-way is sufficient. Everything is working fine untill the transmitter powers off and on. Suddenly there is a few second delay in the communication. Resetting the receiver solves the delay. I have no idea how this could happen, I do not care about losing some data when the devices aren't connected, quick data transmissions when they are connected is much more important.

The receiver does not use softwareserial as this does not work with servo libraries.

Furthermore I am not an experienced programmer so any other tips are welcome as well, thanks!

Transmitter:

#include <SoftwareSerial.h>
SoftwareSerial BTserial(2, 3); // RX | TX

int pot=A0;
int val=0;

 
void setup() 
{
    Serial.begin(9600);
    BTserial.begin(115200);  
}
 
void loop()
{
 val=map(analogRead(pot),0,1048,0,255);
    
 Serial.println(val);
 BTserial.write(val);  
 delay(80);
}

Receiver:

#include <ServoTimer2.h>
 
int val=0;
ServoTimer2 esc;
int throttle =0;
int i =0;
void setup() 
{

   Serial.begin(115200);
   esc.attach(10);
}
 
void loop()
{
     if (Serial.available())
    {  
     
      i=0;
      val = Serial.read();
      throttle = map(val, 210, 133, 1000, 2000);
    }
    else{
      i+=1;
      
    }
    if (i>3){
      throttle=1000;
    }
    if (throttle < 1000){
      throttle = 1000;
    }
      if (throttle > 2000){
      throttle = 2000;
    }
     
  esc.write(throttle);
  delay(80);
   
}
#include <SoftwareSerial.h>
SoftwareSerial BTserial(2, 3); // RX | TX
 
void setup()
{
    Serial.begin(9600);
    BTserial.begin(115200); 
}

With software serial at that speed, I'm surprised you get anything at all, and you may find that you are not, you just think you are. If you slow it down to 9600, it might sort itself out.

9600 is the standard baud rate for the hc-05 which showed the same problem. Changing them to 115200 through AT was the last thing I tried and I did not notice any performance changes...