Problems receiving (all) LoRa Packets

At the moment I try to send packets between one Heltec WIFI LoRa V2 and another by reading the serial-line and sending the input via LoRa.

Small packtes (like 30 bytes) work everytime, but as bigger the packet gets the packet won’r be received everytime or even never.

So I write a little sendig loop, where my sender sends at every iteration a packet, which gets everytime 10 byte bigger and surprisingly every packet was received by the sender (I tried that until 500 bytes).

After that I wanted to send a 80 byte serial input message and this did not work. Do you know whats the problem with that?

// reader
void setup() {
  // ... LoRa.begin(); ....
    // ... LoRa.receive(); ...

void onReceive(int packetSize) { // uses the interrupt pin on the dio0
  String packet = "";
  packSize = String(packetSize,DEC);
  for (int i = 0; i < packetSize; i++) { 
    packet += (char);

// writer
boolean sendPacket (String packet) {
  Serial.println("Send begin");

  LoRa.beginPacket(false); // true: optional implicit mode (--> Set everything on both sides?!)
  LoRa.print(packet); // also LoRa.write(byte(, length));
  LoRa.endPacket(false); // true: async mode: doas not wair until transmission is completed
  // put the radio into receive mode
  LoRa.receive(); // set redio back in receive mode
  Serial.println("Send end");
  return true;  // will be changed

void loop(){
  while(Serial.available() > 0 ){
      delay(2);  //delay to allow byte to arrive in input buffer
      String text = Serial.readString();
      digitalWrite(LED, HIGH);   // turn the LED on (HIGH is the voltage level)
      boolean packetSent = false;

      while (!packetSent) {
        packetSent = sendPacket(text);
        if (packetSent) {
          Serial.print("Packet has been sent: ");
        } else {
          Serial.print("Retry sending packet: ");
      digitalWrite(LED, LOW);   // turn the LED off (HIGH is the voltage level)


we have updated the new version pingpong code, please try it. The default length is 128 bytes.

1 Like

Thank you very much. This library is very useful.

If I adapt the pingpong.ino for my purpose, that I send on e.g. serial interrupt and otherwise be ready to receive it just works if I never go to sleep (I created an IDLE State after STATE_RX). How do I manage to wake up the LoRa on packet receive or interrupt it or something link that?

Thanks in advance


I can’t understand your meaning well. Do you mean that: How to wake up a node when it is sleeping?
After the development board sleeps, only the internal clock and flash of the development board are using power. If you need to achieve the above functions, you need to turn on the interrupt.

Or I’m misunderstanding? can you explain more?

Yes, I meant something like that.

Let me rephrase.
I want my node to be able to receive packets everytime (except I send a packet at the moment).
To save battery I would like to use STATUS_LOWPOWER (sorry this was the missspelling in last message) (LoRaWAN.sleep(CLASS_C,0); ) to reduce the th epower consuption.

In fact CLASS_C should be permanently able to receive packets, am I right?

My problem is that if my node onca activate LoRaWAN.sleep(CLASS_C,0); it doas not receive packets anymore? So how do i manage to wake up my node if there is a packet to receive? Or is this not possible?



"In fact CLASS_C should be permanently able to receive packets, am I right?"

YES. In fact, the hibernation of class C is very different from the hibernation of class a. When class C is in sleep, the MCU will sleep, but the LORA chip will not sleep. But for ESP32, It’s a bit difficult to do the above process.ESP32 can do normal sleep, But it is actually a reset process when it is awakened. After ESP32 is awakened, there is a high probability that there will be logical confusion.

I suggest you use this code:

BTW, CLASS C is the concept of LORAWAN, not the concept of lora pingpong.

So is there a possibilty to set MCU in sleep and wake it up again if LoRa receives a (“pingpong”)-packet (a packet which was sent from another node of mine)? Without the concept of LORAWAN