Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

A-Star problem using low power library

#1

I am using an A-Star 32U4 Micro in a battery powered project which, among other operations, reads a sensor every 15 minutes. To keep the power usage as low as possible I am using the LowPower library written by Rocket Screan Electronics. The A-Star goes into low power mode OK but never comes out of it. Also, I can’t upload another program after this happens without activating the bootloader via the reset line. If I don’t activate a low power mode the board works fine.

What is strange is that the same code I’m works fine on other 32U4 boards such as an Aruino Leonardo.
I’ve tried this on two different A-Star 32U4 Micro boards with the same result.
I suspect the bootloader may be the problem but I’m not sure how to verify my suspicions.

#2

Hello.

Can you post your full code? Can you also send pictures that clearly show your current setup and connections?

-Tony

#3

The basic code which displays the problem is:

#include “LowPower.h”

void setup()
{
delay(20000); //allow time to display Serial Monitor
}

void loop()
{
Serial.println(“Start power down”);
delay(500); //allow time for serial buffer to clear
// Enter power down state for 8 s with ADC and BOD module enabled
LowPower.powerDown(SLEEP_8S, ADC_ON, BOD_ON);
delay(1000);
Serial.println(“End power down”);

}

The code is a modified version of the example code supplied with the LowPower library and is supposed to power down the board for 8 seconds.
Having ADC_ and BOD_ either ON or OFF mahes no difference.
“Start power down” is displayed OK but “End power down” never does.
Code works OK on a Leonardo and a sparkfun Pro Micro but not on the three A-Star Micros I’ve tried.

The problem shows up on a previously unused board which only had a USB cable connected.

#4

I was mistaken in my previous post.

The only command in the LowPower library which works with a 32U4 seems to be:

LowPower.idle(SLEEP_8S, ADC_OFF, TIMER4_OFF, TIMER3_OFF, TIMER1_OFF,
TIMER0_OFF, SPI_OFF, USART1_OFF, TWI_OFF, USB_OFF);

This works on the A-Star 32U4 Micro as well as all other 32U4 based boards I’ve tried.

I had got confused between the LowPower.idle command, which works, and LowPower.powerSave and LowPower.powerDown command, which don’t seem to work on any 32U4 boards.
I will have to investigate the LowPower library further. In the meantime has anyone any ideas how to put the A-Star into a very low power mode?

.

#5

Hello.

Thanks for the code. Do you still have any code that works on the Arduino Leonardo but does not work on the A-Star 32U4 Micro? We have not investigated low-power code on the ATmega32U4 but I recommend reading the ATmega32U4 datasheet. I also recommend trying to write your code so that the AVR wakes up when USB power is present, so that the A-Star can be easily reprogrammed over USB. This StackOverflow thread has some general advice that might be useful in reducing power consumption.

-Tony

#6

Hi

Thanks for the useful link.

For the record I have not found any programs that behave differently on the A-Star 32U4 Micro to those run on a Leonardo.

I have found on further research that the LowPower library commands do not turn on the USB port of 32U4 boards after they complete. The link: https://www.rocketscream.com/blog/forums/topic/adafruit-feather-32u4-fona-wakeup-no-serial-print/ gives a possible solution but I can’t get it to work for some reason. It may be due to how Windows connects/reconnects to USB ports (I use Windows 7) but I really don’t know. I need to study (and understand!) the ATmega32U4 datasheet better particularly with respect to USB usage.

However, for my purposes, I have found a workaround. I only need the low power mode when connected to a battery and all data output is then sent by wireless. The USB port is only used for program updating and testing. So I test whether USB power is present using:

bool USBConnected = false;
void setup() {
USBConnected = USBSTA >> VBUS & 1;
}

void loop() {

if(!USBConnected)
{
//low power code here
}

if(USBConnected)
{
//Serial print statements
}
}

Idea taken from: Detecting USB connection on A-Star 32U4

One of the advantages of using the A-Star for my project is that there is no power LED making it more useful for low power usage. Unsoldering a power LED can be fraught!

1 Like