iotacademy / marvin

Essentials for Marvin LoRa Development
GNU General Public License v3.0
27 stars 188 forks source link

Low power mode #11

Open ehtick opened 6 years ago

ehtick commented 6 years ago

Can't get the low power mode from the atmega in combination with the RN2483 to work.

I want to create a sampling application which samples at a frequency of 15 minutes. For this we put the atmega to sleep which works but combined with the RN2483 sys sleep ...... gives hangup's.

What is the correct way to use as little of power possible (SLEEP_MODE_IDLE) in combination with the RN2482 sys sleep command. Now i created a watchdog timer to wakeup again.

ISR(WDT_vect) { sleep_count ++; // keep track of how many sleep cycles // have been completed. if (sleep_count == sleep_total) Wakeup();
}

in loop i test that Wakeup has set the volatile int to do action and then sample the data send it and got to sleep again. Any help is welcome 👍

OlegZv commented 6 years ago

Hello @ehtick ,

Is that is what you're looking for? powerDown turns off everything is possible:

void loop() {
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);

    // Executing some code sending a message.
}
ehtick commented 6 years ago

We use the Lowpower but this does not sleep the RN2483 chip. So after using the LowPower library it still uses about 5-7 mA and this is tho much.

OlegZv commented 6 years ago

I just tried to add mac sleep command, and got as low as 1.5-2 mA.. Device is transmitting frames as it supposed to.

void loop() {
    send_LoRa_Command("sys sleep 13000");
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);

    // Executing some code sending a message.
}

Is your device stops transmitting?

ehtick commented 6 years ago

Yes it stops, engineer at microchip give the advise to set a delay of 150ms after sending 'sys sleep xxxx'

OlegZv commented 6 years ago

Hmm.. even without delay I have module working and transmitting constantly combining powerDown and "sys sleep xxxxx". Couple of questions for you:

  1. How do you check the transmissions?(if device transmitted or not)
  2. Where is device connected to, when you running a code with sleep and powerdown?
  3. Do you have any prints to USB serial?
ehtick commented 6 years ago

1 we always expect a result from the RN2483 so sometimes 'ok', 'accepted' when sending payload wait for mac_tx_ok. Problem with the sys sleep command is that it sends ok when it wakes up again. 2 We do not run code on powerdown or sleep 3 usb is deactivated and no serial print is used (when debugging yes :))

Updated the firmware for the RN2483 to the latest one, microchip advise, but this does not help.

OlegZv commented 6 years ago
  1. After the powerDown most of the board peripherals shut down, so you not going to see anything in the debugging port, so when you use powerDown, to check transmission please check the Network Server side.

What is the value you put in "sys sleep ..."?

ehtick commented 6 years ago

20 minutes so 20 60 1000 (long)