Trying to get power, consumption down on Nano

I have a project where I want to use a nano in a door lock keypad application and have it run on 3 AA batteries and I would like to have it get at least a year between changes. I watched a YouTube video where they were able to get the sleep mode power consumption down to 0.3Ma, I'm not having that much luck. I have disconnected all LEDs, removed the voltage regulator and lifted the 5v leg on the CB340 USB chip, slowed the clock to 4Mhz and running at 4.5 V my nano is drawing about 2.6 mA while sleeping which I think is too much. (If I drop supply voltage down to 2.0 V it then draws about 0.5Ma, but I don't have that option)
Here is you to video: https://www.youtube.com/watch?v=usKaGRzwIMI

After looking at my code below does anyone have any suggestions as to why this might be, Or what else I could do?

#include "LowPower.h"
 
// Use pin 2 as wake up pin
const int wakeUpPin = 2;
const int wakeUpPin2 = 3;
int but3=0;
 
void wakeUp()
{
    // Just a handler for the pin interrupt.
}
 
void setup()
{
    // Configure wake up pin as input.
    // This will consumes few uA of current.
    pinMode(2, INPUT);  
     pinMode(3, INPUT); 
     pinMode(13, OUTPUT);
      pinMode(5, OUTPUT);
    CLKPR = 0x80;
    CLKPR = 0x02;
}
 
void loop()
{
    // Allow wake up pin to trigger interrupt on HIGH.
    attachInterrupt(0, wakeUp, HIGH);
   
    // Enter power down state with ADC and BOD module disabled.
    // Wake up when wake up pin is HIGH.
    LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
   
    // Disable external pin interrupt on wake up pin.
    detachInterrupt(0);
   
    // Do something here
    but3=digitalRead (3);
    
    if (but3 == HIGH){
    digitalWrite(5,HIGH);
  delay(2000);
  digitalWrite(5,LOW);
}
}

I have 10K pulldown resistors on the switches, but even removing those does not change the power consumption in sleep.

If you have classic Nano clone, the processor is probably not a genuine ATmega328p. The counterfeits don't meet the original specifications for current draw in sleep modes (which is one way to tell that they are counterfeit).

It is counterfeit, you think a genuine 328P would get down to 0.3Ma? With this coding?

A genuine 328P performs according to the specifications in the data sheet. From the limited information you have provided, it is not possible to guess whether your code and/or board modifications would meet that goal, given a genuine MCU.

See this excellent tutorial for verification of the specs, and a DIY approach to low-power operation.

Thanks will get genuine 328P nano and tests with my and Neil's code

I meant Nick's

Which is not the best board for low power.
Try the 8Mhz ProMini.
Leo..

1 Like

Thanks Wawa,

That looks good!
I am new to the Arduino world (and programming) so a little confused by all the versions..
Looking in the Arduino documentation, says Pro Mini is discontinued..
But available on Amazon from Spark Fun, are they a high quality clone maker?

Would I be able to use a Nano to program a pro mini? Or would you recommend a dedicated USB interface device? And if so which one?
James

Sparkfun designed the original Arduino Pro Mini, and uses genuine ATmega328p chips. It can be programmed either with an ISP programmer (this is the best one) or a USB serial adapter.

OK thanks ordered all above mentioned.

You might try the code below as a test. On a genuine 328P, current during sleep will be something less than 1uA. That's with no LEDs, no regulator, etc.

#include <avr/sleep.h>
#include <avr/wdt.h>
int i;

void setup(){

  ADCSRA = 0;                         // disable ADC for power saving
  wdt_disable();                      // disable WDT for power saving
  set_sleep_mode (SLEEP_MODE_PWR_DOWN); // Deep sleep
  sleep_enable();
  sleep_bod_disable();                // disable brownout detector during sleep
  sleep_cpu();                        // now go to sleep

}

void loop(){
}

Edit: I ran your code on my Pro Mini with a known genuine 328P, and I get about 280uA sleep current. With my code, it's about 0.5uA. That's with the regulator and power indicator LED removed, and nothing connected to the Pro Mini except power. So your code isn't producing as low current as it could. I'm not familiar with the library you used, so I don't know what's wrong. But maybe you could just use my code.

1 Like

Indeed. My multimeter could not measure the current, it was that little. I've achieved that on cheap clone Pro Minis as well.

I did remove the regulator and the power LED from the board - in principle the same can be done with a Nano but it defeats the whole purpose of using a Nano (built-in USB, mainly) rather than a Pro Mini to begin with.

Honestly I don't think there exist counterfeit ATmega328p chips out there. It's not a simple thing to clone. There could be reject batches out there, but if that's the case Atmel themselves are to blame.

Surely you are joking. Google the topic before making a fool of yourself.

Counterfeits are a serious problem with just about all popular chips, and many different counterfeit ATmega328s have been identified, starting decades ago. Start here

Specific to high current draw in sleep.

It's not a simple thing to clone.

The basic ATmega design was done by a couple of college kids, over 3 decades ago. Do you think it represents a significant challenge to any reasonably competent professional today?

1 Like

Signature block dump used to check for genuine ATmega and ATtiny described here:
https://microchip.my.site.com/s/article/Serial-number-in-AVR---Mega-Tiny-devices

//Code posted here
//https://gist.github.com/speters/f889faec42b510052a6ab4be437d38ca
//Purpose is to simply run a memory check on ATMEGA238P to test for counterfeit parts
// see https://microchip.my.site.com/s/article/Serial-number-in-AVR---Mega-Tiny-devices
#include <avr/boot.h>
#define SIGRD 5
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  while(!Serial);
  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() {}

Example from known good ATmega328P

boot sig dump
1E	96	95	FF	F	CB	0	26	
FF	8	FF	17	FF	FF	59	35	
36	31	39	39	FF	D	19	2	
17	2	12	6	13	6	FF	FF	

No guarantee that the counterfeiters won't put reasonable-looking values here, though.

Yes indeed. I was personally involved a while back with fake 328Ps on Pro Minis. Sent them to Microchip, and they confirmed. I also sent them to Kevin Darrah, who did a great three-part video on them, including a decapping report.

https://www.youtube.com/watch?v=PlGycKwnsSw

The decapping was done by Sensible Micro Corporation, a company whose business model is to validate genuine chips and distinguish them from the many counterfeits.

See this video followup to Kevin Darrah's work: https://youtu.be/o0rEzcKYzGw

Thanks for the lively discussion everyone, quite informative.

ShermanP,
I ran your code and I still get about 3ma of current draw so that's no good.

jremingon,
I watched the YouTube videos posted, quite well done.
I ran your code and got results below, looks quite fake.
I will get my genuine 328P (spark fun version) in a couple of days and will rerun the tests,

I had one question, I assume that the <avr/boot.h>, <sleep.h>, <avr/wdt.h> libraries are included in the IDE, is that correct? I figured this because it compiles without an error and if they were needed to be downloaded I would get an error, is this also correct?

�
boot sig dump
1E	C1	95	FF	F	FF	FF	26	
FF	FF	FF	FF	FF	FF	58	FF	
DF	FF	DF	FF	FF	FF	FF	FF	
FF	FF	FF	FF	FF	FF	FF	FF	


Have the regulator and LEDs removed

And this is with nothing connected to the Nano except power and ground? No I2C, no SPI, no anything.

If you've already removed the regulator and the power LED, looking at the schematic for the Nano clone, the only thing I can see that might possibly draw current is the TX and RX lines going to the CH340. You lifted its Vcc pin, but not its gorund pin. You might try adding lines ahead of my code that sets D0 and D1 to pinMode INPUT, and see if that makes any difference. I think this is unlikely to be the problem, but it's worth checking.

The test output does look fake.

Edit: Yes, if it compiles successfully, then you have the needed libraries installed.