ATmega32U4 deep sleep current too high?

Hello.

I have been bashing my head against how to put ATmega32U4 into deep sleep, to achieve the advertised ~6uA deep sleep current @3V, room temperature.

I went through the datasheet I have a bare minimum board (actually a PRO MICRO board with removed regulator, LED resistors). I have set all pins to either input-pull-up or output LOW, I have disabled ALL and everything, stopped all clocks, disabled BOD in fuses and still the damn thing sits at 28.7uA, MOCKING ME!!!!

Is there a known good code that actually achieves the advertised ~6uA deep sleep current for the ATmega32U4?

  USBDevice.detach();
  // Disable USB clock 
  USBCON |= _BV(FRZCLK);
  // Disable USB PLL
  PLLCSR &= ~_BV(PLLE); 
  // Disable USB
  USBCON &= ~_BV(USBE);
  
  UHWCON = 0;
  UDCON = 0x01; //detach usb
  USBCON = 0x20;  //disable usb related irqs
  USBINT = 0x00;  //disable usb related irqs
  UDIEN = 0x00;  //disable usb related irqs
  TWCR = 0x00;  //disable TWI and its irq
  ADCSRA = 0x00;  //disable ADC and its irqs
  ACSR = 0x00;  //disable comparator and its irqs
  PRR1 = 0x99;
  PRR0 = 0xAD;

  cli();

  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);

is it genuine or a Chinese clone, a recovered reject, ......?

I really do not know. Board looks better quality, surface finish looks to be gold. This is why I am searching for known good code, I have no other means to figure this out.

No code can overcome defective, or poor, hardware. Try and buy the circuit from a reputated seller selling genuine circuits.

The manufacturer's data sheet is a legal document, so you can rely on the specifications. However, if you have a counterfeit ATmega32U4, you probably will not be able to match those specs.

Even if you have a genuine ATmega32U4, it takes a fair bit of sleuthing and code to turn off all the peripherals, so do your research. Various people have posted on this topic.

Re:

 LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);

Last time I looked at the LowPower library code, I noticed that the BOD_OFF parameter is ignored for the 32U4. The library is not very useful.

Hello,

I searched and did not find a post where anyone came close to the expected 6uA (deep sleep + WDT wake-up).

Noticed that the LowPower library ignored BOD turn-off as 32U4 does not support it, so I disabled it in fuses.

I did however a memory dump as described in case of counterfeit 328P, just to have it documented for doing the data dump on ATmega32U4, here is the result for my particular unit:

boot sig dump
1E      67      95      65      87      66      FF      FF
0       FF      FF      F7      FF      FF      58      31
37      31      38      30      15      4       1C      1C
17      D       12      8       13      8       FF      FF

The code used is bellow, I copied it from HERE.

//found this code here
//https://gist.github.com/speters/f889faec42b510052a6ab4be437d38ca

//Purpose is to simply run a memory check on ATMEGA238P to test for counterfeit parts

#include <avr/boot.h>
#define SIGRD 5
void setup() {
  // put your setup code here, to run once:

  uint8_t timeout = 10;

  Serial.begin(115200);
  
  while ((!Serial) && (timeout != 0)){
    delay(1000);
    if(timeout != 0) timeout--;
    Serial.print("\r\nWaiting for serial: ");
    Serial.print(timeout);
    Serial.print("s");    
  }

  Serial.println("");
  Serial.println("boot sig dump");
  int newLineIndex = 0;
  for (uint8_t i = 0; i <= 0x1F; i += 1) {
    Serial.print(boot_signature_byte_get(i), HEX);
    Serial.print("\t");
    newLineIndex++;
    if (newLineIndex == 8) {
      Serial.println("");
      newLineIndex = 0;
    }
  }
  Serial.println();
}

void loop() {

}

Here is a readout from a genuine Arduino Micro:

Waiting for serial: 8s
boot sig dump
1E      65      95      63      87      63      FF      FF
0       FF      FF      F7      FF      FF      55      38
31      32      38      38      15      19      16      10
17      D       12      8       13      8       FF      FF

If your project requires a truly low power MCU, the ATmega series is far from the best choice.

Do you have a compelling reason for pursuing this elusive goal?

I mean this is off-topic, but I am always open to suggestions for future projects.

Actually it seems the mcu is genuine?

I have no opinion about that. It was a long shot. There have been companies selling parts rejected by the industry. One in US, 50 years ago, was Poly Pacs. Now there's China that sell almost any stuff, sometimes containing circuits unsoldered from different equipment.

The two memory dumps are different. Anything You can find out from that?

Hello, no, sadly no. The memory dump is not identical, but very similar, and comparing visuals for the two chips, it looks like the device is genuine in both cases. Doubt Arduino board would be counterfeit, came from Farnell as official Arduino Micro. And the other chip looks the same, but for, what I assume, is a date code. This one is different, but still looks genuine.

Did not figure out how to get the chip revision.

I still think it is user error, which is why I am looking for known good code.

Sry, did you say you had read

Nick Gammon on low power

It may be a bit of a slog, but give it a try. He breaks it down and covers the topic very well.

You may have yet to find things that are drawing power what you don't need or even realize.


Poly Paks. Old enough to have forgotten all about them!

a7

I started with Nick Gammon post. I am hitting 0.8uA average sleep current for whole device, which includes ATmega168P a supercapacitor and various other devices.

But not for the ATmega32U4.

You still haven't explained why you care, or what you have done, in sufficient detail.

Since vanishingly few other people seem to be interested in this particular issue (with good reason, since there are far better low power processors), you are probably on your own.

Go over the data sheet with a magnifying glass and turn off every internal peripheral that is mentioned.

Yeah I already did that, you see? So explaining trees with trees will not do it, apparently.

Now on the topic of "far better controllers", this is a topic for a flame war and we do not care about that, thanks.

So fine, if folks do not know or care, but if someone gets into the same issue, for the record I got to 28.7uA sleep current.

If and when anyone gets a better result, he may post his code when putting the mcu into deep sleep, but up until then, the posted code is probably the one to do it best.

I think the chip is genuine, at least based on that test sketch. In the case of the fake 328P, almost all of those values were FF in the fakes.

I don't have a Pro Micro to play with, so can't offer any suggestions. But you are powering through an external supply at the Vcc pin, not through USB?

Edit: Here's another thread on this subject. I don't think they ever found a solution.

https://forum.arduino.cc/t/power-consumption-of-atmega32u4-during-sleep-power-down-higher-than-expected/685915

I also think the chip is genuine and I think I pretty much went through all threads about ATmega32U4 sleep currents. Currently one explanation may be the errata, but I can not read out the chip revision.

So right ow I am stuck and have dropped from 2 years battery life in worst case, to 9 months battery life. Still the unit features an USB charger and the battery life is not so bad, but I know I am not hitting nowhere near the achievable target and it irritates me.

I''ve never been clear on what you actually have. And if it has a charger, then it can't be just a Pro Micro. Is there a link to this unit?

I know how you feel about not being able to get the sleep current down to the datasheet spec. It was my adventures with the 328Ps in my clone Pro Minis that led to Kevin Darrah's work on this. In my case it turned out to be counterfeit chips.

Depending on your setup, there might be another alternative for getting good battery life, and that would be to switch the battery power on and off, as controlled by a DS3231 RTC powered by a coin cell. I use this method when there are other devices in the circuit that can't be put to sleep, like certain sensors, or SD cards, etc. You would need the RTC module, a P-channel mosfet, and a resistor. If your battery supply exceeds 5.5V, you would also need a little N-channel mosfet like a 2N7000. This would give you literally zero sleep current.

I have custom HW, various versions, all running from either primary or rechargeable cells. The HW can run from either a pro micro or pro mini, which has parts removed, so it becomes a minimum running system. I have wireless comm, T & RH sensors and, depending on version, a LiPo charger and a ultralow power timer that will wake my mcu externally. Depending on power source I may use a supercap. There is also a version running on the SAMD mcu, featuring a display.

The lowest consumption measured was with the 168P ~0.8uA deep sleep (mostly supercap leakage), I do not remember how much it was with 328P, but taking into account the run time (Tx current), I should land at about 3uA average current consumption.

The 32U4 runs on the rechargable batt versions, but there is no real reason, why it would not run on platforms, other than its elevated consumption, which is why I am trying to drop it to sub uA. There is also no reason why other mcus would not run this HW version, but the HW is already built and I am trying to get it to the best possible level of usability. It won't be a tragedy if I do not succed, it is only 2 units with the LiPo charger, but still, would be nice to not waste resources.

The sensors I am actually supplying via GPIOs, I used to have circuitry to turn them off etc, but the units used are very low consumption anyway, so I no longer assemble that part of the circuit. As mentioned above, most of the devices have an external wake-up mechanisms, except for the rechargeable battery versions, those are currently awaken by WDT.