matthijskooijman / arduino-lmic

:warning: This library is deprecated, see the README for alternatives.
710 stars 651 forks source link

Sleeping in os_runloop() #76

Open Roberto6969 opened 7 years ago

Roberto6969 commented 7 years ago

Is it possible to put Arduino to sleep in TX_INTERVAL? I would like to put Arduino to sleep between sending messages but i have no idea how to combine linrary sleep function (i.e. LowPower) with LMIC run-time scheduler function.

Oliv4945 commented 7 years ago

An easy way is to sleep the required amount of time you need instead of scheduling the next TX in TX_COMPLETE event. So you can replace this line by

      for (int i=0; i<37; i++) {
        // Use library from https://github.com/rocketscream/Low-Power
        LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
      }
      do_send(&sendjob);
Roberto6969 commented 7 years ago

That was good idea until i change Activation method from ABP to OTAA. Now it sends 4 times than i always receive following error: FAILURE C:\Users\Robert\Documents\Arduino\libraries\arduino-lmic-master\src\lmic\radio.c:523

Do you have any idea how to resolve this error?