LoRa module serial data doesn't send/receive fast enough

I have been playing with some LoRa sx1276 modules from eByte datasheet: Here

I am planning to use them to control a remote control car I built (pictures to come once complete) but my string of data that is sent over the sx1276 modules is not sending enough times per second for it to be practical. I timed it and the packet arrival happened at an average of 2 cycles/second which I was hoping for more like 5-10 hz.

The transmit function, and the receive function are below, and I can attach the whole code if needed, but it is long, and I cannot find any delay anywhere else in the code. I am 99% sure it is on the transmitter side because I have a serial to USB converter that I used as the receiver to capture the raw data but that did not speed things up at all.

ReceiverModule:

void receiverModule() {       // This module takes in the data from the LoRa module and converts it into useable values for the enableModule and actionsModule

  String str = "";
  //String str ="1233,4146,7389,1511,21213,14315,16117,1819,2021,2223,2425,23";
  
  while (Serial.available() > 0) {
    str += (char)Serial.read();
    delay(5);
  }

  if (str != "") {
    int indexArray[12];
    indexArray[0]=str.indexOf(",");
    for(int i=1;i<=10;i++){
      indexArray[i]=str.indexOf(",",(indexArray[i-1] +1));
      }
      
  
transmissionArray[1]=str.substring(0,indexArray[0]).toInt();
for(int i=2;i<=11;i++){
  transmissionArray[i]=str.substring(indexArray[i-2]+1,indexArray[i-1]).toInt();
  }
transmissionArray[12]=str.substring(indexArray[10]+1).toInt();

for(int i=1;i<=12;i++){
  //Serial.println(transmissionArray[i]);
  }
  
   // while(1);
  }
  //----------------------End of receiverModule function----------------------//
}

TransmitterModule:

void transmissionModule() {
  byte transmissionArray[] = {Rmotor, Lmotor, Rdirection, Ldirection, Ebrakeinput, Lightinput, Highbeaminput, JSAXtransmit, JSAYtransmit, JSBinput, JSABinput, 23}; // I need to send these values to the receiver many times per second. Motor control is the most important to have sent very often but ideally everything sends many times per second
  // Maybe if it can't be sent as an array, it could be sent individually and each thing have an identifier and on the receiver it can run individual functions based on type of value was received

  String dataStr = "";
  dataStr = dataStr + Rmotor + "," + Lmotor + "," +  Rdirection + "," + Ldirection + "," +  Ebrakeinput + "," + Lightinput + "," + Highbeaminput + "," +  JSAXtransmit + "," +  JSAYtransmit + "," +  JSBinput + "," +  JSABinput + "," +  "23";
  Serial.println(dataStr);
  Serial.end();
  delay(30);
  Serial.begin(9600);
  delay(70);
  
  //----------------------End of transmissionModule function----------------------//
}

If you would like to see my full code, it is on my GitHub at https://github.com/amarotica/Remote-Operated-Vehicle

Ugh, Arduino-crashing Strings!

Do you have many more of these useless statements scattered around your code? What do you suppose they do for transmission speed?

    delay(5);
...
delay(30);
...
  delay(70);

Is Lora really suitable and legal for this. Lora is designed for transmission distance rather than speed and IIRC, to use legally you can only transmit for a small percentage of time.

How far away do you need to control the car from as there are probably more suitable transmission systems you can use that will give faster speeds.

There are model remote control systems using LoRa, it can run at 37,000bps which is enough for RC systems.

However in most places you cannot use LoRa for RC control under ISM licence excempt rules due to duty cycle rectrictions.

LoRa is permitted in some countries under RC model rules but since you are not allowed (in most places) to fly RC models beyond visual sight range, then a long range RC system for model aircraft has no purpose.

For land based models conventional RC systems will allow you to control a model as far as you can see it. You could then use FPV to go further than this, but then you are very likley using illegal video transmitters.

jremington: Ugh, Arduino-crashing Strings!

Do you have many more of these useless statements scattered around your code? What do you suppose they do for transmission speed?

    delay(5);
...
delay(30);
...
  delay(70);

the delay(5) is unnecessary I suppose, but the delay(30) and delay(70) are necessary for making the LoRa module actually transmit. I figured that out from this webpage in the comments: https://quadmeup.com/e45-ttl-100-not-transmitting-when-connected-to-arduino/#comments

Riva: Is Lora really suitable and legal for this. Lora is designed for transmission distance rather than speed and IIRC, to use legally you can only transmit for a small percentage of time.

How far away do you need to control the car from as there are probably more suitable transmission systems you can use that will give faster speeds.

Maybe it isn't the best option, but I thought it would be a smart choice because if this is a land based vehicle, there will no doubt be small obstacles in the way that a affordable 2.4Ghz system might not be super reliable in that situation...

And actually upon further testing, I am sure the transmitter is transmitting many times per second (maybe 10 hz) but the reciever either isn't listening often enough or my LoRa modules need some other commands sent or something.

the delay(30) and delay(70) are necessary for making the LoRa module actually transmit.

It is very hard to imagine that those delays are actually necessary, but if so, you have made a very poor choice of LoRa module.

Regardless of the two delays in my program, it is still only receiving data at roughly 2hz. If the only limit was those two 30 and 70 ms delays, the receiver should be receiving at 10hz which is more than I am even looking for.

What LoRa settings are you using ?

LoRa can vary in speed from around 50bps (long transmission times and stupid long distance mode) to 37000bps (very short transmission times).

I currently have them at 9600bps, which is the default data rate for these particular modules. According to the datasheet, their highest setting is 19200bps so I will give that a try when I get home from work. I will also try messing around with the delay values and see if a bigger or smaller number lines up with what the LoRa module wants better. Only drawback of trying many programs is I forgot to install an ISP header on my embedded circuit and just assumed my code would work :grinning: :grinning: :grinning:

I read through the datasheet again and found something that may be...something.

The module can receive the user data via serial port, and transmit wireless data package of 58 bytes. When the data inputted by user is up to 58 byte, the module will start wireless transmission. During which the user can input data continuously for transmission. When the required transmission bytes are less than 58 bytes, the module will wait 3-byte time and treat it as data termination unless continuous data inputted by user. Then the module will transmit all the data through wireless channel. When the module receives the first data packet from user, the AUX outputs low level. After all the data are transmitted into RF chip and transmission start , AUX outputs high level. At this time, it means that the last wireless data package transmission is started, which enables the user to input another 512 bytes continuously. The data package transmitted from the module working in mode 0 can only be received by the module working in mode 0 or 1.

I think this may mean that it is waiting to transmit the next package for 512 bytes... Except maybe that doesn't have to do with anything.

amarotica: I currently have them at 9600bps, which is the default data rate for these particular modules.

Thats just the serial baud rate between the Arduino and the micro your module has in front of the actual LoRa RF device.

As I have mentioned above, you need to understand what parameters the actual LoRa device is using and these parameters are bandwidth, spreading factor and coding rate.

srnet: Thats just the serial baud rate between the Arduino and the micro your module has in front of the actual LoRa RF device.

As I have mentioned above, you need to understand what parameters the actual LoRa device is using and these parameters are bandwidth, spreading factor and coding rate.

I mean yes, the Arduino-LoRa baud rate is 9600bps, but I also set the air data rate to 9.6kb/s, which is just another way of saying 9600bps...

amarotica:
I mean yes, the Arduino-LoRa baud rate is 9600bps, but I also set the air data rate to 9.6kb/s, which is just another way of saying 9600bps…

You cannot set the LoRa device to use an arbitary on-air data rate such as 9600bps.

The data rate depends on the bandwidth, spreading factor and coding rate the LoRa device is using.

Once you know this information you can work out the real bps and how long a packet takes to send.

Oh I guess I don’t understand the datasheet right then. Could you please explain how the air data rate cannot be set even though you can change a parameter called “Air Data Rate” in the settings utility? According to the datasheet from what I can understand, the air data rate can be set. Below is a snapshot of the datasheet page detailing possible programmed data rates and serial baud rates as well.

If the image doesn’t show: Imgur: The magic of the Internet

amarotica: Oh I guess I don't understand the datasheet right then. Could you please explain how the air data rate cannot be set even though you can change a parameter called "Air Data Rate" in the settings utility? According to the datasheet from what I can understand, the air data rate can be set. Below is a snapshot of the datasheet page detailing possible programmed data rates and serial baud rates as well.

If the image doesn't show: https://imgur.com/a/gveXPNo

You need to study the data sheet for the LoRa module itself (SX1278), there is no concept of setting an "Air Data Rate".

@srnet:

The OP is using a module with a uP/firmware combination that sets the various parameters according to someone's idea of what might be appropriate for a particular "air data rate". See the link in the initial post.

The module states that the default "air data rate" is 2.4 kbps, but it can be set to other values. It is not clear whether one can set or read out the spreading factor, etc.

jremington: The module states that the default "air data rate" is 2.4 kbps, but it can be set to other values. It is not clear whether one can set or read out the spreading factor, etc.

I realise which module the user is using and it is likely that you cannot set thec LoRa parameters explicitly.

However unless you know which LoRa parameters are being used, you cannot know what the real data rate is in use, and you need to know the real data rate to know how long the packets will take to transmit.

srnet: I realise which module the user is using and it is likely that you cannot set thec LoRa parameters explicitly.

However unless you know which LoRa parameters are being used, you cannot know what the real data rate is in use, and you need to know the real data rate to know how long the packets will take to transmit.

I did read the complete data sheet for the module I am using. Many, many times. And I am using a SX1276 which unfortunately has less experimentation information available on the web than the SX1278.

As I said, poor choice of module.