Cannot transfer more data bytes using Lora Wifi V3

I am using the latest Lora WiFi V3 board. I have modified the EXAMPLE “LoRaSender” per attached and successfully send out MQTT JSON data via Lora. However, when I try to increase the number of data bytes, it fails.
I have tried to increase BUFFER_SIZE to 100. Still fails. Any ideas?

Henry Chan

  1. If it fails, report any error.
  2. Gradually increase to see how much can be reached.

Hi,
I locate the root cause:

  • The problem is I have put the chip to SLEEP mode after the code “Radio.IrqProcess( );”. Now I have added delay(3000) after sending my packet (size 90bytes). Then everything is fine.
  • I’ve tried to do it more intelligently by using “while (lora_idle == false);” instead of delay(3000); however, the chip hangs up. Do you have any idea to know when the packet is sent and ready to sleep?

Thanks,
Henry

Did you figure it out?

Now I just use delay to solve the problem and this delay needs to be changed with different packet size. So it will be the best to know when the transmission of packets is finished and then I will go to sleep. Do you have any idea?

Did you attach a file? i don’t see one. Did you try something like the following, a modification of LoraSender.ino? This code tells the ESP32 to go into deep sleep after the onTXDone() ISR is called. onTXDone() shouldn’t be called until the packet has been fully sent. i have not tested this code. Let me know if it works for you.

volatile bool lora_idle = true;
volatile bool enterDeepSleep = false;
RTC_DATA_ATTR double txNumber = 0;  // so it survives sleep

void setup() {
  
  // LoRa setup...
  ...
  RadioEvents.TxDone = OnTxDone;
  ...
  
}

void loop()
{
  // how many times will this loop be executed? once per wake?
  
  if (enterDeepSleep) deepSleep();

  if(lora_idle == true) // leaving this in place because it's not clear what Radio.IrqProcess does.
  {
    delay(1000);
    txNumber += 0.01;
    sprintf(txpacket,"Hello world number %0.2f",txNumber);  //start a package

    Serial.printf("\r\nsending packet \"%s\" , length %d\r\n",txpacket, strlen(txpacket));

    Radio.Send( (uint8_t *)txpacket, strlen(txpacket) ); //send the package out  
    lora_idle = false;
  }
  Radio.IrqProcess( );  // is this blocking or non-blocking?
}


void OnTxDone( void )
{
  Serial.print("TX done...... ");
  Serial.println(txNumber);
  lora_idle = true;
  
  // GO SLEEP!!!
  enterDeepSleep = true;
}

// sleep 10 seconds
void deepSleep() {
  enterDeepSleep = false; // not necessary because it'll be reset anyway after sleep
  Serial.println("Going into deep sleep.");
  VextOFF();
  Radio.Sleep();
  SPI.end();
  pinMode(RADIO_DIO_1,ANALOG);
  pinMode(RADIO_NSS,ANALOG);
  pinMode(RADIO_RESET,ANALOG);
  pinMode(RADIO_BUSY,ANALOG);
  pinMode(LORA_CLK,ANALOG);
  pinMode(LORA_MISO,ANALOG);
  pinMode(LORA_MOSI,ANALOG);
  #define sleepTime 1 // in minutes
  // esp_sleep_enable_timer_wakeup(sleepTime * 60 * 1000* (uint64_t) 1000); // 60 secs * 1000 ms * 1000 us
  esp_sleep_enable_timer_wakeup(10 * 1000* (uint64_t) 1000); // 10 secs * 1000 ms * 1000 us
  esp_deep_sleep_start();
}

I’ve tried and it works perfectly. The average current consumption is even better than my previous delay method. Thank a lot!! Issue closed.

1 Like