What is the most correct form of combining sending and receiving packets by LoRa modules?

In my case, two WiFi LoRa 32 (V2) modules work. One measures the milling spindle speed (tachometer). The second one, based on this data (sent via LoRa) controls the milling machine remotely.

However, once in a while (every several dozen minutes) communication between modules must occur in the opposite direction. The speed measuring module must receive a packet with the parameters needed to calculate the speed.

I want the information about the current speed of the spindle to reach the milling module as often as possible.

Pulses (tics) from the HALL sensor are counted through interrupts. Sending the package takes about 0.5 seconds. I set the program so that once every 0.6 seconds the speed is sent.

As a result, the time during which the module listens for transmission to it is very short compared to the time when the packet was sent and the transmission to the spindle speed measuring module must be repeated many times to be received.

How should the best send and receive LoR packets be connected correctly?

This is the maximally simplified version of loop () (Arduino IDE):

void loop () {
         int packetSize = LoRa.parsePacket ();

         if (packetSize) {
           detachInterrupt (digitalPinToInterrupt (HALL_sensor_Pin));
           cbk (packetSize); 
           attachInterrupt (digitalPinToInterrupt (HALL_sensor_Pin), pickrpm, FALLING);
         };

        if (Sending_Timer.onRestart ()) {
           detachInterrupt (digitalPinToInterrupt (HALL_sensor_Pin));
           Actual_Speed = ticks * Speed_multiplier;
              LoRa.beginPacket ();
              LoRa.print (Actual_Speed);
              LoRa.endPacket ();
           Sending_Timer.restart ();
           ticks = 0;
           attachInterrupt (digitalPinToInterrupt (HALL_sensor_Pin), pickrpm, FALLING);
        }
}

Tomasz

Hi~
I think there are several ways you can try and see if these solutions can solve the problem of repeated sending.

  1. Add antennas to both modules to increase gain.
  2. Increase the transmit power of LoRa.

TX Power

Change the TX power of the radio.

LoRa.setTxPower(txPower);

LoRa.setTxPower(txPower, outputPin);
  • txPower - TX power in dB, defaults to 14
  • outputPin - (optional) PA output pin, supported values are PA_OUTPUT_RFO_PIN and PA_OUTPUT_PA_BOOST_PIN , defaults to PA_OUTPUT_PA_BOOST_PIN .

Supported values are between 2 and 17 for PA_OUTPUT_PA_BOOST_PIN , 0 and 14 for PA_OUTPUT_RFO_PIN .

Most modules have the PA output pin connected to PA BOOST,

  1. Reduce the spreading factor of LoRa.

Spreading Factor

Change the spreading factor of the radio.

LoRa.setSpreadingFactor(spreadingFactor);
  • spreadingFactor - spreading factor, defaults to 7

Supported values are between 6 and 12 . If a spreading factor of 6 is set, implicit header mode must be used to transmit and receive packets.

1 Like

The factory test for the LoRa part is a simple Ping-Pang communication example, the number didn’t increase because the node didn’t received any package.

Make sure you have two board working in a same band.

Many thanks for the hints.

I am not sure if we understood each other correctly. The problem is not in communication. Both modules are now lying side by side on the table and are communicating perfectly.

I will describe it in detail and how I understand the reason for the problem.

There are two modules β€œA” and β€œB” in the system:

Module β€œA” measures the spindle speed and sends packets with this information to module β€œB”.

The β€œB” module receives packets all the time and analyzes them on an ongoing basis.

However, sometimes the β€œB” module must send a packet to the β€œA” module. And (this is a problem) these packets are not received by module β€œA”.

I have to repeat sending the packet from β€œB” to β€œA” many times until it is finally received.

Module β€œA” should send packets to module β€œB” as often as possible. Sending the packet by the β€œA” module takes about 0.5 sec. So I set the packet sending timer to 0.6 seconds.

Therefore, 0.1 seconds remain for listening for incoming packets. I think it is too short and too rare a time to pick up every packet.

Sending (about 0.5 sec):

if (Sending_Timer.onRestart ()) {
           detachInterrupt (digitalPinToInterrupt (HALL_sensor_Pin));
           Actual_Speed ​​= ticks * Speed_multiplier;
              LoRa.beginPacket ();
              LoRa.print (Actual_Speed);
              LoRa.endPacket ();
           Sending_Timer.restart ();
           ticks = 0;
           attachInterrupt (digitalPinToInterrupt (HALL_sensor_Pin), pickrpm, FALLING);
 }

And listening:

int packetSize = LoRa.parsePacket ();
if (packetSize) {
       detachInterrupt (digitalPinToInterrupt (HALL_sensor_Pin));
       cbk (packetSize); 
       attachInterrupt (digitalPinToInterrupt (HALL_sensor_Pin), pickrpm, FALLING);
     };

is repeated in loop() only for about 0.1 sec.

The packet sent once every several minutes from the β€œB” module to the β€œA” module constantly goes to the time when the module β€œA” is busy sending, not listening.

0.1 sec - listening if the packet from β€œB” to β€œA” is coming,
0.5 sec - sending the packet from β€œA” to β€œB”.

If I set the packet sending timer - for example - 5 seconds, almost every packet from module β€œB” to module β€œA” is received by β€œA”. However, 5 sec interval of sending the packets by module β€œA” to β€œB” is tooooo big.

What should I do (without reducing the frequency of sending packets by β€œA” to β€œB”) so that the module β€œA” receives every packet sent by β€œB”? Is it possible?

Or is it possible to shorten the time of sending the packet by the β€œA” module? 0.5 seconds is a very long time.

Sorry for my poor English:joy:

I think the time is too short is the main problem. Keep the period time more than 1 sec.

Also, make the two boards have a distance (1m or longer).

Thanks for the answer.

I understand that the only solution is to find the best ratio between the frequency of sending packets by the β€œA” module, and the ability to read packets sent by the β€œB” module.

Of course, the β€œA” module has the option of confirming that it has received a packet from β€œB”. When a minimum of 5 packets is sent by the β€œB” module, the probability of reading one by the β€œA” module is already high.

I am thinking about adding β€œA2” module, which will deal only with receiving packages from β€œB”. LoRa full duplex would be created ;-).

Uhhh… I don’t think so.

As I know, full-duplex LoRa is just an illusion of delay. In the true sense, full-duplex is impossible because the RF signal received and transmitted is switched by a single-pole double-throw switch. There is only one state in the switch (received or transmit).

Of course. One pair of modules cannot do simultaneous two-way transmission.

But if I use four modules - two pairs of them. Each pair of modules will handle transmission in one direction. Data exchange locally between two modules will be done by wire, so very quickly.

Thanks

Tomasz

1 Like