Close circuit to power Arduino, then let the Arduino cut the circuit again.

aarg:
If you PM me, I'll tell you the name of a good Ebay supplier.

You don't think others here would like to know?

Here's Kevin Darrah's video on the bad Pro Minis that I mentioned in #12:

ShermanP:
Here's Kevin Darrah's video on the bad Pro Minis that I mentioned in #12:

https://youtu.be/PlGycKwnsSw

From the glimpse of the code he allowed, all the pins appear to be floating inputs. The behaviour of floating pins is undefined. Maybe some test where the sleep mode initiated with all pins in a defined state would be good.

In the meantime, @LarryD has published another version of a latch circuit here
tiny85 self power-off - General Electronics - Arduino Forum (post#15) . . .

F3B65B59-4EE4-4880-A2AD-10E7A0F7BEDB.png

If I get time, I'll simulate it to see how it behaves. Of course, I am sure it works, but I'm curious about how it performs if the the capacitor marked C is relatively large, and the MCU dies, allowing its I/O pin to float high, before C is fully discharged.

So I have desoldered the power LED and voltage regulator from my 2016 Pro Mini (3v 8Mhz).
Now I wanted to measure how much current it actually uses while in sleep, but I get a reading of 2mA in "2mA" mode and when I turn it to "20µA" mode, the Arduino doesn't seem to boot up properly (I assume it gets stuck in some sort of boot loop because the LED next to Pin 9 keeps blinking).
I thought that maybe switching from "2mA" mode to "20µA" mode cuts the power for a fraction of a second causing the Arduino to lose power and then boot again, which requires more than 20µA of power and thus the fuse of the multimeter cuts the power again and again...
But then I shorted the multimeter probes before switching from "2mA" mode to "20µA" mode and then unshorted it again, but the Arduino gets stuck in a boot loop again...

This is the multimeter I'm using btw.

@6v6gt and ShermanP I really like your mailbox projects btw. I think I will try to make one myself, it's a great idea.

My Pro Mini does appear to have a 2016 chip, so I guess it's probably genuine.

Switching the meter to the 20uA range will introduce a shunt, in series with your power source, which may be too high for the Arduino to function.

When you say you measured 2mA in "2mA" mode. I'd have thought that, with the way the scales are organised on that meter, you'd have seen a maximum of 1.99 on the 2mA range. That is, the left most digit can be either a 0 or a 1. Maybe, you have not interpreted the results correctly. But you should also show how you put the device into sleep mode.

This is how I put it to sleep.
I will check the multimeter again later.

That looks like pretty complicated code just for testing sleep current. Here's what I use for that purpose:

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

void setup(){

  for (i = 0; i < 20; i++) {          // all pins to one rail or the other - power saving
    pinMode(i,OUTPUT);
    digitalWrite(i,LOW);
  }
  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(){
}

You would power up with the meter set to the 20uA range, but with the leads shorted, then after about three seconds remove the short. The meter should read about 1uA or less.

I set evwrything up again and tried with your code as you described.
It seems the Arduino shuts down as soon as I go to 2mA or 20uA mode and remove the short. An I don't get a reading on the multimeter, it shows shows a weird "1" which it only does when there is no current.

Edit: After switching up to 200mA mode I get a reading of exactly 4.8mA and in 20A mode .048A. Switching forth and back between 20A and 200mA without shorting doesn't cause the Arduino to reboot btw.

Well, it is actually pretty close to no current. But it should still show up on the 20uA scale.

So you have the power LED removed (or its resistor), and the regulator as well? Is there anything else connected to the Pro Mini? Does it run other sketches ok, such as the Blink example, without the meter?

Oh, one thing to check. Your meter has a fuse inside that can blow if too much current goes through it. Make sure the fuse isn't blown. Well, I guess you can just test the meter with the Blink sketch on a higher amp scale, and it should run ok. If it doesn't, the fuse may be blown.

And you should be moving the positive lead over to the mA current position.

Yes, power LED and regulator are desoldered.
Other sketches like the xomplex one I've linked run just fine.
While testing the Arduino hasn't been connected to anything but the USB to 3v3 serial adapter.

The positive lead was already plugged into to the mA connector on the multimeter.

I'll check the fuses and see if I can replace them if they're broken. But my understanding is that the same fuse is used for all current modes while the probe is plugged into the mA connector. And since I get a reading in 200mA mode it should be okay, right?

Edit: I just checked and there is only one fuse (200mA/250V) and it's fine.

So to measure current, you are inserting the meter into the 3.3V Vcc line from the USB adapter to the Mini?

The only thing I can suggest is to try connecting only power and ground from the USB adapter, not Tx, Rx, etc.

I don't know why or how my code could result in 4.8mA of current. So I really don't understand what's going on.

Do you have a 1M resistor you could use to test your meter? Connected across the 3.3V power rails, you should get a 3.3uA reading on the meter when on the 20uA setting.

I get a reading of 3.24uA for a 1M Ohm resistor.
If I measure that resistor I get a 0.98M reading.
I get a reading of 3.26V on the USB to Serial converter btw.

Edit: After removing all connections but vcc and gnd to the Arduino, I get a reading of 0.09uA, so 90nA. If that is true, that would be awesome!

Edit2: Dang, with my own sleep code it uses 100uA instead. But I need to be able to wake the Arduino up with a button, so I can't use your sleep code. :frowning:

Edit2: Dang, with my own sleep code it uses 100uA instead. But I need to be able to wake the Arduino up with a button, so I can't use your sleep code. :frowning:

Looks for an example sketch where a button is attached to a pin that supports external interrupts (pins 2 and 3 on a uno). An external interrupt can be used to wake the device.

I don't think the 100uA has anything to do with using a pin to wake up the Mini. It's probably the result of not disabling the ADC module during sleep. The last time I measured that, it was 110uA.

The code below calls for a momentary switch on D2, connected to ground. When you push the button, the Mini wakes up, lights up the other LED on the Mini's board for one second, then it goes back into Power-Down sleep. It should sleep at the same current as my previous test sketch - 1uA or less.

Notice that before going to sleep, the current value of the ADC control register is saved, then ADC is turned off during sleep, then the previous value is restored after wakeup. Of course if you aren't using ADC at all, you can just turn it off once and leave it that way.

This also works with pin change interrupts. It doesn't have to be one of the external interrupt pins. My remote control has the four keypad row pins set up on pin change interrupts, and pressing any key will wake up the 328P.

#include <avr/sleep.h>
#include <avr/wdt.h>
int i;
int buttonPin = 2;  //connect pushbutton to ground
int LEDpin = 13;    //on the Pro Mini
byte ADCSRAsave;    //save existing ADCSRA value

void setup(){

  for (i = 0; i < 20; i++) {          // all pins to output - power saving
    pinMode(i,OUTPUT);
    digitalWrite(i,LOW);
  }
  pinMode(buttonPin,INPUT_PULLUP);
  wdt_disable();                      // disable WDT for power saving
  EIFR = 3;                           // clear external interrupt flag register
}

void loop(){
  ADCSRAsave = ADCSRA;
  ADCSRA = 0;                         // disable ADC for power saving
  set_sleep_mode (SLEEP_MODE_PWR_DOWN); // Deep sleep
  sleep_enable();
  attachInterrupt(digitalPinToInterrupt(buttonPin), ISRbutton, FALLING);
  sleep_bod_disable();                // disable brownout detector during sleep
                                      //   must be immediately before sleep_cpu()
  sleep_cpu();                        // now go to sleep

// now asleep, waiting for button press

// button pressed, ISR returns to here, now awake

  ADCSRA = ADCSRAsave;                //restore ADC function
  
  digitalWrite(LEDpin,HIGH);          //flash LED for 1 second, then go back to sleep
  delay(1000);
  digitalWrite(LEDpin,LOW);
}

void ISRbutton() {
  detachInterrupt(digitalPinToInterrupt(buttonPin));  //eliminates switch bouncing issues
  sleep_disable();
}

Sorry for the late response! Thank you so much ShermanP! With that code it works like a charm now!

Ok, when you began this thread, you were looking for a way to switch power on and off in between doorbell button pushes. Now you've got the Pro Mini part sleeping so soundly that you don't really need to bother to turn off the power. But that still leaves your radio transmitter. What are you going to do about that? Can you turn it off from the Pro Mini, or make it go into a very low current state?

Yes, I can put the CC1101 module to sleep using these commands:

  ELECHOUSE_cc1101.SpiStrobe(0x36);//Exit RX / TX, turn off frequency synthesizer and exit
  ELECHOUSE_cc1101.SpiStrobe(0x39);//Enter power down mode when CSn goes high.

With the module in sleep mode, the power consumption is 630nW (including the Arduino). Without the module attached I measured 203.4nW.

That looks pretty good. I think your battery will last a long time.