0

I'm trying to use the power down state for a battery application, but I'm having issues with the serial communication.

I'm using the lowpower.h library to put the Arduino Micro into power down mode.

When it wakes I flash an LED, which is working, so I know it's is waking up. And I also re-establish serial communication and send a message. This is not working. I receive nothing on the serial monitor, however the TX LED does flash.

I think the Arduino may be working correctly, but for some reason the serial monitor can't handle it. Perhaps there is a better serial monitor application?

#include "LowPower.h"

void setup()
{
    //20sec delay added to make uploading easier (cant upload in power down state)
    Serial.begin(115200);
    Serial.println("20");
    delay(5000);
    Serial.println("15");
    delay(5000);
    Serial.println("10");
    delay(5000);
    Serial.println("5");
    delay(5000);
    Serial.println("START");
    pinMode(LED_BUILTIN, OUTPUT);
    delay(1000);
    Serial.end();
}

void loop() 
{
    // Enter power down state for 8 s with ADC and BOD module disabled
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);  

    Serial.begin(115200);
    delay(100);
    Serial.println("BLINK");
    digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(5000);                       // wait for a second
    Serial.println("BLINK_stop");
    digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
    delay(5000);                       // wait for a second

    Serial.end();

}

Serial monitor output:

20
15
10
5
START

and then nothing...

  • There may not be a lot of point to the operation behind this question: if the device is connected via USB, what do you gain by putting it into a low power mode? Theoretically, with a lot of care to fully implement all specifications you could have the host computer and the device both enter low power mode, but it isn't really apparent that you are doing that here. Perhaps it only makes sense for your device to enter a lower power mode when not connected via USB. If you need brief debug messages between intermittent sleep, consider an external USB UART that remains powered. – Chris Stratton Jun 11 '18 at 15:27
1

I found the answer on this related question: Starting usb on pro micro after deep sleep (ATmega32u4)

Which itself was a link to a sparkfun forum

Note: it requires you to close and open the serial monitor at proper timings.

// disable the USB prior going to sleep
USBCON |= _BV(FRZCLK);  //freeze USB clock
PLLCSR &= ~_BV(PLLE);   // turn off USB PLL
USBCON &= ~_BV(USBE);   // disable USB

// and wake it up after
//routine to properly wake up
sleep_disable();
delay(100);
USBDevice.attach(); // keep this
delay(100);
Serial.begin(9600);
delay(100);
  • Can you accept your own answer please, so that the system here recognizes that the question has a valid answer? – Nick Gammon Jun 11 '18 at 6:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.