Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #6938
    peak
    Participant

    I can successfully put my Adafruit feather 32u4 FONA to sleep by using your Low-Power library with the function: LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF)
    With an external interrupt the FONA wakes up again and is functional EXCEPT that it cannot write to the Serial Monitor again. Nothing is output but I can have the FONA blink leds and do whatever else.
    Note that I call Serial.begin(9600 (or whatever)) to no avail.
    Do you have any clue why this is happening?

    • This topic was modified 6 years, 6 months ago by peak. Reason: Spelling
    #6945
    LIM PHANG MOH
    Keymaster

    The 32U4 USB needs to be detach before entering a power down mode and attach back once awake.
    So, it supposed to look like this:

    USBDevice.detach();
    // Add your wake up source here, example attachInterrupt()
    LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
    USBDevice.attach(); 
    delay(1000); // In order for PC to have enough time to show the connected COM port

    But, unfortunately, if you look at the core code and search for USBDevice.detach(), you’ll see that it’s an empty function (not implemented). So, you need to add the detaching the USB portion before sleep:

    // Disable USB clock 
    USBCON |= _BV(FRZCLK);
    // Disable USB PLL
    PLLCSR &= ~_BV(PLLE); 
    // Disable USB
    USBCON &= ~_BV(USBE); 
    // Add your wake up source here, example attachInterrupt()
    LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
    USBDevice.attach(); 
    // In order for PC to have enough time to show the connected COM port
    delay(1000); // In order for PC to have enough time to show the connected COM port

    Also add some delay in the setup code portion so you have enough time for code uploading.

    • This reply was modified 6 years, 6 months ago by LIM PHANG MOH.
    #6949
    peak
    Participant

    LIM PHANG MOH, thank you for an excellent explanation and a working solution.
    Regards
    Peter

    #7598
    vtomanov
    Participant

    OK,

    Kind of a working, BUT then the USB generally do not work most of the time – and no serial logging is possible and to upload a new code is a bit tricky – I need to press reset about 1 sec before the upload to be able to actually upload the new code …

    any suggestion how to use the low power lib and in the same time to be able to upload new code and log in the serial while not sleeping ?

    e.g. I want to sleep 10 msec , do some measurements, sleep again 10msec etc.

    also dies the millis(); function will return the correct value or need to be adjusted with the sleep interval ?

    device is Feather 32u4 with LoRa

    #7600
    peak
    Participant

    “kind of working”? Nope. Working Excellently! Start a new thread

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.