LoRaWan_APP Transmitt Time

I am using the CubeCell Dev Board (V1) for LoRa transmission.

I have 1 board setup as a transmitter, and 1 board setup as a receiver.

The code is based on the CubCell LoRa Examples

The aim is to have the receiver turn on a relay while the transmitter is transmitting, and as soon as the receiver doesn’t receive a valid code from the transmitter, it switches off the relay.
I would like to have the delay between switching off the transmitter, and the relay switching off, to be no more than 500ms

I have setup the sender to transmit at a random time, anywhere up to 250ms. This all appears to be working, however, the receiver is only receiving about 1 packet per second, so misses anywhere from 6 to 9 packets each time.

Is there a way I can get the receiver to receive more packets, or is this a limitation of the LoRaWan_APP library?

I have previously setup something similar using a Dragino Lora Shield, and LoRa.h, which worked well, but LoRa.h doesn’t seem to be compatible with the CubeCell

I am fairly new to LoRa and arduino, so stumbling my way through everything

Transmitter Code:


#include "LoRaWan_APP.h"
#include "Arduino.h"

/*
 * set LoraWan_RGB to 1,the RGB active in loraWan
 * RGB red means sending;
 * RGB green means received done;
 */
#ifndef LoraWan_RGB
#define LoraWan_RGB 0
#endif

#define RF_FREQUENCY                                433000000 // Hz

#define TX_OUTPUT_POWER                             21        // dBm

#define LORA_BANDWIDTH                              0         // [0: 125 kHz,
                                                              //  1: 250 kHz,
                                                              //  2: 500 kHz,
                                                              //  3: Reserved]
#define LORA_SPREADING_FACTOR                       LoRaSF         // [SF7..SF12]
#define LORA_CODINGRATE                             1         // [1: 4/5,
                                                              //  2: 4/6,
                                                              //  3: 4/7,
                                                              //  4: 4/8]
#define LORA_PREAMBLE_LENGTH                        8         // Same for Tx and Rx
#define LORA_SYMBOL_TIMEOUT                         0         // Symbols
#define LORA_FIX_LENGTH_PAYLOAD_ON                  false
#define LORA_IQ_INVERSION_ON                        false


#define RX_TIMEOUT_VALUE                            1000
#define BUFFER_SIZE                                 16 // Define the payload size here

char txpacket[BUFFER_SIZE];
char rxpacket[BUFFER_SIZE];

static RadioEvents_t RadioEvents;

float txNumber;
bool lora_idle=true;
int LoRaSF = 8;
int Transmitter_ID = 100; // Set to 100 so if something is wrong with jumpers, nothing will happen.

void setup() {
    Serial.begin(115200);

    txNumber=0;



#define J1 GPIO1  // Jumper 1 for remote coding
#define J2 GPIO2  // Jumper 2 for remote coding
#define J3 GPIO3  // Jumper 3 for LoRa Spreading Factor

#define J4 GPIO4  // Jumper 4 for Remote Function
#define J5 GPIO5  // Jumper 5 for Remote Function

#define RB GPIO0  // Input for remote button - may not be needed
#define LED 0 // Output for LED

  int counter = 0;
  int delay_time = 0;


  pinMode(J1, INPUT);
  pinMode(J2, INPUT);
  pinMode(J3, INPUT);
  pinMode(J4, INPUT);
  pinMode(J5, INPUT);
  pinMode(RB, INPUT);
  pinMode(LED, OUTPUT);  // Not doing anything with this yet, but should turn on when button pressed, and flash if voltage low.




  // calculate Transmitter number based on J1, J2, J3
  Trans_ID(); // Call the Trans_ID function - calculates the transmitter ID based on jumpers

// Set LoRa Spreading Factor
  if (digitalRead(J3) == HIGH) {
   LoRaSF =  11;           // ranges from 6-12,default 7 see API docs
  }
  if (digitalRead(J3) == LOW) {
   LoRaSF = 12;           // ranges from 6-12,default 7 see API docs
  }


    RadioEvents.TxDone = OnTxDone;
    RadioEvents.TxTimeout = OnTxTimeout;
    Radio.Init( &RadioEvents );
    Radio.SetChannel( RF_FREQUENCY );
    Radio.SetTxConfig( MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH,
                                   LORA_SPREADING_FACTOR, LORA_CODINGRATE,
                                   LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
                                   true, 0, 0, LORA_IQ_INVERSION_ON, 3000 ); 
}




void loop() {
  Transmitter_ID ++;
  Serial.print("Sending packet: ");
  Serial.println(Transmitter_ID);
  Serial.print("SF");
  Serial.println(LORA_SPREADING_FACTOR);

 
sprintf(txpacket,"%u",Transmitter_ID);  //start a package
Radio.Send( (uint8_t *)txpacket, strlen(txpacket) ); //send the package out 
  int  delay_time = random(250); // set random delay to prevent interferring with other transmitters
  delay(delay_time);
}





void Trans_ID() { // Calculates the transmitter number based on State of jumpers J1, J2, J4 & J5. (J3 is used for spreading factor not ID)

  int Sum = 0;
  if (digitalRead(J1) == HIGH) {
    Sum += 1;
  }
  if (digitalRead(J2) == HIGH) {
    Sum += 2;
  }
  if (digitalRead(J4) == HIGH) {
    Sum += 4;
  }
  if (digitalRead(J5) == HIGH) {
    Sum += 8;
  }
  Transmitter_ID = Sum;
}

void OnTxDone( void )
{
  turnOffRGB();
  Serial.println("TX done......");
  lora_idle = true;
}

void OnTxTimeout( void )
{
  turnOffRGB();
  Radio.Sleep( );
  Serial.println("TX Timeout......");
  lora_idle = true;
}

Receiver Code

/* Heltec Automation Receive communication test example
 *
 * Function:
 * 1. Receive the same frequency band lora signal program
 * 
 * 
 * this project also realess in GitHub:
 * https://github.com/HelTecAutomation/ASR650x-Arduino
 * */

#include "LoRaWan_APP.h"
#include "Arduino.h"

/*
 * set LoraWan_RGB to 1,the RGB active in loraWan
 * RGB red means sending;
 * RGB green means received done;
 */
#ifndef LoraWan_RGB
#define LoraWan_RGB 0
#endif

#define RF_FREQUENCY                                433000000 // Hz

#define TX_OUTPUT_POWER                             21        // dBm

#define LORA_BANDWIDTH                              0         // [0: 125 kHz,
                                                              //  1: 250 kHz,
                                                              //  2: 500 kHz,
                                                              //  3: Reserved]
#define LORA_SPREADING_FACTOR                       12         // [SF7..SF12]
#define LORA_CODINGRATE                             1         // [1: 4/5,
                                                              //  2: 4/6,
                                                              //  3: 4/7,
                                                              //  4: 4/8]
#define LORA_PREAMBLE_LENGTH                        8         // Same for Tx and Rx
#define LORA_SYMBOL_TIMEOUT                         0         // Symbols
#define LORA_FIX_LENGTH_PAYLOAD_ON                  false
#define LORA_IQ_INVERSION_ON                        false


#define RX_TIMEOUT_VALUE                            100
#define BUFFER_SIZE                                 16 // Define the payload size here

char txpacket[BUFFER_SIZE];
char rxpacket[BUFFER_SIZE];

static RadioEvents_t RadioEvents;

int16_t txNumber;

int16_t rssi,rxSize;

bool lora_idle = true;

void setup() {
    Serial.begin(115200);

    txNumber=0;
    rssi=0;
  
    RadioEvents.RxDone = OnRxDone;
    Radio.Init( &RadioEvents );
    Radio.SetChannel( RF_FREQUENCY );
  
    Radio.SetRxConfig( MODEM_LORA, LORA_BANDWIDTH, LORA_SPREADING_FACTOR,
                                   LORA_CODINGRATE, 0, LORA_PREAMBLE_LENGTH,
                                   LORA_SYMBOL_TIMEOUT, LORA_FIX_LENGTH_PAYLOAD_ON,
                                   0, true, 0, 0, LORA_IQ_INVERSION_ON, true );

   }



void loop()
{
  if(lora_idle)
  {
    turnOffRGB();
    lora_idle = false;
    Serial.println("into RX mode");
    Radio.Rx(0);
  }
}

void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr )
{
    rssi=rssi;
    rxSize=size;
    memcpy(rxpacket, payload, size );
    rxpacket[size]='\0';
    turnOnRGB(COLOR_RECEIVED,0);
    Radio.Sleep( );
    Serial.printf("\r\nreceived packet \"%s\" with rssi %d , length %d\r\n",rxpacket,rssi,rxSize);
    lora_idle = true;
}

Open the serial port and see the actual time interval of sending.

Sender Serial Port

08:24:16.657 -> Sending packet: 419984

08:24:16.657 -> SF12

08:24:16.890 -> Sending packet: 419985

08:24:16.890 -> SF12

08:24:16.890 -> Sending packet: 419986

08:24:16.890 -> SF12

08:24:17.030 -> Sending packet: 419987

08:24:17.030 -> SF12

08:24:17.076 -> TX done…

08:24:17.216 -> Sending packet: 419988

08:24:17.216 -> SF12

08:24:17.451 -> Sending packet: 419989

08:24:17.451 -> SF12

08:24:17.591 -> Sending packet: 419990

08:24:17.591 -> SF12

08:24:17.685 -> Sending packet: 419991

08:24:17.685 -> SF12

08:24:17.825 -> Sending packet: 419992

08:24:17.825 -> SF12

08:24:17.871 -> Sending packet: 419993

08:24:17.871 -> SF12

08:24:18.010 -> Sending packet: 419994

08:24:18.010 -> SF12

08:24:18.105 -> Sending packet: 419995

08:24:18.105 -> SF12

08:24:18.197 -> TX done…

Receiver Serial Port
08:23:46.944 -> received packet “419755” with rssi 0 , length 6
08:23:46.944 -> into RX mode
08:23:47.922 ->
08:23:47.922 -> received packet “419763” with rssi 0 , length 6
08:23:47.922 -> into RX mode
08:23:49.081 ->
08:23:49.081 -> received packet “419773” with rssi 0 , length 6
08:23:49.081 -> into RX mode
08:23:50.064 ->
08:23:50.064 -> received packet “419784” with rssi 0 , length 6
08:23:50.064 -> into RX mode
08:23:51.278 ->
08:23:51.278 -> received packet “419792” with rssi 0 , length 6
08:23:51.278 -> into RX mode
08:23:52.302 ->
08:23:52.302 -> received packet “419800” with rssi 0 , length 6
08:23:52.302 -> into RX mode
08:23:53.467 ->
08:23:53.467 -> received packet “419809” with rssi 0 , length 6
08:23:53.467 -> into RX mode
08:23:54.443 ->
08:23:54.443 -> received packet “419822” with rssi 0 , length 6
08:23:54.443 -> into RX mode
08:23:55.700 ->
08:23:55.700 -> received packet “419833” with rssi 0 , length 6
08:23:55.700 -> into RX mode
08:23:56.865 ->
08:23:56.865 -> received packet “419844” with rssi 0 , length 6
08:23:56.865 -> into RX mode
08:23:57.888 ->
08:23:57.888 -> received packet “419849” with rssi 0 , length 6
08:23:57.888 -> into RX mode
08:23:58.869 ->
08:23:58.869 -> received packet “419857” with rssi 0 , length 6
08:23:58.869 -> into RX mode
08:23:59.990 ->
08:23:59.990 -> received packet “419862” with rssi 0 , length 6
08:23:59.990 -> into RX mode
08:24:01.103 ->
08:24:01.103 -> received packet “419870” with rssi 0 , length 6
08:24:01.103 -> into RX mode
08:24:02.223 ->
08:24:02.223 -> received packet “419879” with rssi 0 , length 6
08:24:02.223 -> into RX mode
08:24:03.200 ->
08:24:03.200 -> received packet “419885” with rssi 0 , length 6
08:24:03.200 -> into RX mode
08:24:04.322 ->
08:24:04.322 -> received packet “419892” with rssi -1 , length 6
08:24:04.322 -> into RX mode
08:24:05.438 ->
08:24:05.438 -> received packet “419898” with rssi 0 , length 6
08:24:05.438 -> into RX mode
08:24:06.413 ->
08:24:06.413 -> received packet “419904” with rssi 0 , length 6
08:24:06.413 -> into RX mode
08:24:07.624 ->
08:24:07.624 -> received packet “419915” with rssi 0 , length 6
08:24:07.624 -> into RX mode
08:24:08.693 ->
08:24:08.693 -> received packet “419920” with rssi 0 , length 6
08:24:08.693 -> into RX mode
08:24:09.717 ->
08:24:09.717 -> received packet “419928” with rssi 0 , length 6
08:24:09.717 -> into RX mode
08:24:10.876 ->
08:24:10.876 -> received packet “419934” with rssi 0 , length 6
08:24:10.876 -> into RX mode
08:24:11.943 ->
08:24:11.943 -> received packet “419944” with rssi 0 , length 6
08:24:11.943 -> into RX mode
08:24:12.965 ->
08:24:12.965 -> received packet “419949” with rssi 0 , length 6
08:24:12.965 -> into RX mode
08:24:13.993 ->
08:24:13.993 -> received packet “419957” with rssi 0 , length 6
08:24:13.993 -> into RX mode
08:24:14.968 ->
08:24:14.968 -> received packet “419966” with rssi -1 , length 6
08:24:14.968 -> into RX mode
08:24:16.040 ->
08:24:16.040 -> received packet “419975” with rssi 0 , length 6
08:24:16.040 -> into RX mode
08:24:17.107 ->
08:24:17.107 -> received packet “419984” with rssi -1 , length 6
08:24:17.107 -> into RX mode

The transmitter says it is sending a lot of packets, but I only get the TX done signal about once a second, which roughly corresponds to how often the receiver is actually receiving a packet.
My initial code just sent the number 15 as a message, but I modified so I could see which message was actually being received.

Is there a delay setting somewhere in the LoRaWan_APP Library that can be modified so it sends more often?

Lora’s reception processing takes time. Try increasing the time.

I have reduced spreading factor and increased bandwidth, which has sped up the transmission.

Is there any other settings I can change to increase transmission speed without having to change SF and BW?

Thanks

Error correction coding rate