[SOLVED]Lora sx1278 e32 working very slow

Hello everyone i have this problem where i need to transmit very small amount of data but fast,
im using the Lora sx1278 e32 to do this. i need to transmit 10 bytes which need to take around 10.4ms at 9600 baud rate which means sending almost 100 times per second but in practice its only sending like once a second.
when i shorted the modules (RX to TX make it wired connection) it worked as it should.
so IMO the problem is with the modules but i dont know how to check it/solve it
these are my codes

thanks in advance

for the transmitter:

#include <SoftwareSerial.h>

#define TX  3
#define RX  2
#define M0  13
#define M1  12
#define AUX  11
#define communicationLed 8

unsigned long time;
byte myData[10];

SoftwareSerial ESerial(TX, RX);

void setup(){
  Serial.begin(9600);
  ESerial.begin(9600);
  Serial.println("Starting Sender");
  pinMode(4, INPUT_PULLUP); //button pull-up resistor
  pinMode(5, INPUT_PULLUP); //button pull-up resistor
  pinMode(6, INPUT_PULLUP); //button pull-up resistor
  pinMode(7, INPUT_PULLUP); //button pull-up resistor
  pinMode(communicationLed, OUTPUT); //communication Led config
  pinMode(M0, OUTPUT); //lora module config
  pinMode(M1, OUTPUT); //lora module config
  digitalWrite(M0, LOW); //lora module config
  digitalWrite(M1, LOW); //lora module config

 //sync bytes
  myData[9] = 0xff; // end byte
  myData[0] = 0xfe; //start byte
}

void loop(){ //taking about 11.3ms for a loop
    // Read all analog inputs and map them to one Byte value
    // Convert the analog read value from 0 to 1023
  //getTime(); // print loop duration
  myData[1] = map(analogRead(A1), 0, 1023, 0, 180);  //j1posX
  myData[2] = map(analogRead(A0), 0, 1023, 0, 180);  //j1posY
  myData[3] = map(analogRead(A3), 0, 1023, 0, 180);  //j2posY
  myData[4] = map(analogRead(A2), 0, 1023, 0, 180);  //j2posX
  if (digitalRead(4)) myData[5] = 0; else myData[5]= 1;
  if (digitalRead(5)) myData[6] = 0; else myData[6] = 1;
  if (digitalRead(6)) myData[7] = 0; else myData[7] = 1;
  if (digitalRead(7)) myData[8] = 0; else myData[8] = 1;
  ESerial.write(myData, 10);
}

void getTime(){
  Serial.print("Time: ");
  time = millis();
  Serial.println(time);
}

for the receiver:

boolean newData = false;
byte dataReceived[8];
int i=0;
unsigned long lastReceiveTime;
byte startByte = 0xfe, endByte = 0xff;
static boolean recvInProgress = false;

#define led1 12
#define debugLed 13
#include <Servo.h>

Servo servo1;  // create servo object to control a servo
Servo servo2;  // create servo object to control a servo
Servo servo3;  // create servo object to control a servo
Servo servo4;  // create servo object to control a servo
Servo esc;  // create servo object to control a servo

//============

void setup() {
    Serial.begin(9600);
    pinMode(4, OUTPUT);
    pinMode(5, OUTPUT);
    digitalWrite(4, LOW); //lora module config
    digitalWrite(5, LOW); //lora module config
    pinMode(6, INPUT);
    pinMode(led1, OUTPUT);
    pinMode(debugLed, OUTPUT);
    servo1.attach(7);  // attaches the servo on pin 4 to the servo object
    servo2.attach(8);  // attaches the servo on pin 5 to the servo object
    servo3.attach(9);  // attaches the servo on pin 6 to the servo object
    servo4.attach(10);  // attaches the servo on pin 7 to the servo object
    esc.attach(11);  // attaches the servo on pin 7 to the servo object
    resetData();
}

//============

void loop() {
  /*
   * The function is reading incoming bytes from the serial, working as long as we dont have new data,
   * its start to read when its reading 0xfe as we declared its our start byte (for sync reasons)
   * and every byte afterwards its placing into an array of data until it read the endByte and stops
   * then updating newData => true and moving to run the motors
   */
   recvData();
       if(newData){runMotors();}
}

void resetData() {
  // Reset the values when there is no radio connection - Set initial default values
  dataReceived[1] = 90; //j1posX
  dataReceived[2] = 0; //esc
  dataReceived[3] = 90; //j2posY
  dataReceived[4] = 90; //j2posX
  dataReceived[5] = 0;
  dataReceived[6] = 0;
  dataReceived[7] = 0;
  dataReceived[8] = 0; 
}

void recvData(){
    while (Serial.available() > 0 && newData == false){ //read data into array
        byte currentByte = Serial.read();
        if (recvInProgress == true) {
            if (currentByte != endByte) {
                dataReceived[i] = currentByte;
                i++;
                }
            else {
                recvInProgress = false;
                i = 0;
                newData = true;
            }
        }
        else if (currentByte == startByte) {
            recvInProgress = true;
        }
       }
}
void runMotors(){
               servo1.write(dataReceived[1]);
              //servo2.write(j1potX); 
              //servo3.write(j2potY);
              //Serial.println(j2potX);
              //servo4.write(j2potX);
               esc.writeMicroseconds(map(dataReceived[0], 0, 180, 0, 2000));
               if(dataReceived[4]) digitalWrite(led1,HIGH); else digitalWrite(led1,LOW);
               //delay(3);
               newData = false;    
}

xstr3me:
so IMO the problem is with the modules but i dont know how to check it/solve it

So for the transmitter to somehow cause your program to slow down, there would need to be some form of feedback from the transmitter, telling the Arduino the transmitter is busy for instance.

I can only see that you are sending serial data to the E32.

So how can the E32 be telling the Arduino to slow down ?

Have you changed the radios default over the air rate from 2.4kbps to something higher, otherwise all you are doing is sending data to the radio too fast, and most likley overflowing its transmit buffer.
Either put a delay in your transmit loop to give the radio time to send your 10 bytes, or change the radios over the air rate to something like 19200 bps or higher.

srnet:
So for the transmitter to somehow cause your program to slow down, there would need to be some form of feedback from the transmitter, telling the Arduino the transmitter is busy for instance.

I can only see that you are sending serial data to the E32.

So how can the E32 be telling the Arduino to slow down ?

The write function continue only when the 10 bytes are sent, do you mean that the Arduino sent it to the module and the module need more time to operate? And if so, how's to configure it? Add a delay?

mauried:
Have you changed the radios default over the air rate from 2.4kbps to something higher, otherwise all you are doing is sending data to the radio too fast, and most likley overflowing its transmit buffer.
Either put a delay in your transmit loop to give the radio time to send your 10 bytes, or change the radios over the air rate to something like 19200 bps or higher.

I did change it to 19200 but it didn't help, adding a delay after the write function could help, 3 bytes of delay means 1.4ms for each byte, so 4ms of delay?

I'll try to add an if that say only continue when the aux pin is high.

I think i might solve it, its not completely as smooth as i thought but what i did is actually took both of your suggestion, changed the kbps to 19200 and also added

while(digitalRead(AUX) == 0 ){};

to my code to let the module fnish sending the data

thank you very much!