LoRa module sometimes takes too long to transmit

Hi,
I am using a couple of AI-Thinker RA-02 modules for a point to point wireless link.
A packet of about 10-15 bytes normally takes about 45mS to send with the following function.


void sendLora(byte *packet){

 if (LORAPresent==false) return ;

 
  int timeStart=millis();
  LoRa.beginPacket();
  LoRa.write(0xAA);
  LoRa.write(0xAA); 
  LoRa.write (packet,packet[0]);  // packet[0] holds the length of the packet
  LoRa.endPacket();
  int timeEnd=millis(); 
  
  printPacket("Lora Out",packet);
  PORT_S.print(F("Tx Time:"));PORT_S.println(timeEnd-timeStart);PORT_S.print(F("Pkt#:" )); 
  PORT_S.println( msgCount); 
  msgCount++;
  
}

The transmit duration is measured in the function above and printed to the serial port for monitoring.
For some reason however, in some cases transmission times have been recorded in excess of 500mS! When this happens I often have to switch the power off and back on for the system to operate normally again. Note that the LoRa module is powered by a dedicated 3.3V linear regulator located next to the module to avoid any power supply issues.

Has anyone come across anything similar before? Any ideas why this is happening?

No idea, but you can do more investigating be moving the timeEnd up after the first LoRa call and test, then move it to after the second LoRa call, and then after the next call. Testing for a long wait, each time.
That way you can narrow the problem down to one specific call.

If you are using an acknowledge/response mode of communication, that probably means communications are unreliable and that many tries were necessary to send the packet and have it acknowledged.

Yes, I know. Thats why I need to find out why this is happening

Radio is inherently unreliable. Successful transmission is impossible in many circumstances.

You haven't provided any information about your particular circumstances.

Thats also correct but here I am not investigating how reliable the transmission link is. Its just the time it takes for he module to finish transmission...

That is absolutely required, in order to understand the problem. You need to determine what factors reduce the success rate, and change them.

I am sorry, but i dont understand what you mean...
How reliable the RF link is, is a totally different manner.
I am just puzzled by the different times it takes to transmit a certain packet irrespective of whether the packet reaches its destination or not .

The radio takes a fixed amount of time to transmit a packet, determined by the parameters you set.

Your program is not measuring that time. It is measuring the time taken by a much more complex process that involves communication between the MCU and the radio.

Yes that's correct.
But the time i am actually measuring is proportional to the time the radio takes to transmit the packet, probably incremented by the relatively small amount of time it takes by the CPU to execute the necessary cycles.
Do you agree?

No, I do not agree.

For example, function calls like .beginPacket() and .endPacket() require the participation of the radio, which may be busy doing other things and therefore ignoring or postponing responses.

OK. I have ensured that the radio is not doing anything else while i do the test.
However, what do you propose I should proceed?

I have no suggestions, given the lack of information in your posts. Good luck with the project!

ok, thank you

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