Prevent current lekage on input pins during sleep

I have a project with a Atmega328P that controls a camera. The system spends most of the time in sleep mode (LowPower library: LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF)).
I've managed to get power consumption during sleep down to about 7 uA, which is very important for battery life, as the system will be left unattended for one year running on low-sefdischarge batteries.
To receive weekly system status updates, I added a RockBlock Iridium Satellite Modem, which I keep off most of the time using a low-side switch based on an IRLB8748 MOSFET.

The problem is that when the satellite modem is connected, even with the MOSFET switch turned off, the power consumption jumps to 30 mA during sleep.
There are three digital pins connected to the satellite modem: 7, 8 and 9, used for software serial TX, RX and a to control the Enable pin of the satellite modem.
To try to solve the problem, I'm switching all those pins to INPUT before going to sleep (I've tried INPUT_PULLUP too). This reduces power consumption to 1 mA, but it is still far from the 7uA I get if I disconnect the satellite modem or if I simply disconnect pins 7, 8 and 9.

I've read about the Atmega328P taking power from input pins when powered off, but I'm not sure if that also applies to the case when you go to powerDown sleep mode via software, but the chip is still powered up.

In this post: https://forum.arduino.cc/t/prevent-arduino-taking-power-from-input-pin/531658 Wawa makes interesting suggestions for a similar problem, but I don't fully understand them and I'm not sure if they will apply to my case.

How can I prevent this current leakage through these pins during sleep?

Really need to see a schematic for this.

And specifications for this "RockBlock Iridium Satellite Modem" - what are its low-power specs?

Sure! This is the schematics. I've highlighted in red the most relevant parts. The system is powered by a 7.4v battery pack, with a permanently powered 3.3v rail that powers-up the Atmega328P and a 5V rail powered up/down by a MOSFET (low side switch).

The power specs of the satellite modem are here: https://docs.rockblock.rock7.com/docs/power-consumption-guidance. There they recommend powering down the satellite modem if staying unused more than two days, in my case the modem is used every seven days at most.

What's going on here:
image

Looks like you're trying to disconnect the ground? :thinking:

Yes, it is a low-side switch. Is there a problem using this kind of switch in this case?
The 5v power label might be confusing, but refers to the digital pin controlling the MOSFET.

What is the behaviour of that voltage regulator when you disconnect its ground?

You're leaving the entire satellite modem "floating" at its positive supply - I'd say that's asking for trouble with leakage from the 3 IO lines to ground through the rest of your system!

See this recent thread:

Have you tried measuring the current into the 5V (pin 1) here:
image

Why not use a high-side switch?

Or a regulator with an 'Enable' ?

Addendum:

(potential) leakage from the unswitched 5V (or whatever the regulator gives with its ground missing) back into the IO pins to ground:

image

1 Like

Use a high side switch to avoid exactly this sort of problem. Pololu sells them as "power switches".

It would be better to put the RockBlock modem to sleep, as it is almost always a bad idea to connect unpowered modules via I/O pins to powered modules.

2 Likes

Thanks a lot for the advice. I remember running into trouble when trying to high switch with a MOSFET a voltage higher than the microcontroller vcc. Do you have any suggestions or reference to look at?

When you cut the ground connection of the modem, all of its pins will float up to 5V, or nearly 5V. Then since the 328P's Vcc is at 3.3V, you have current flowing from the 5V supply through the protection diodes of the 328P's GPIO pins, to the 3.3V rail. It doesn't matter how you have the GPIO pins set.

The solution is to switch the high side 5V supply to the modem, not the low side. But you may have the same problem in the opposite direction unless the 328P pins are set to input, or output low, if the modem has protection diodes too.

Do you have the same problem with the camera power control?

2 Likes

That's exactly what the linked thread is about!

Or, again, use a regulator with an 'Enable' ?

There are many solutions, as the problem has been around for 40-50 years. To learn about them, use your favorite search engine, with the phrase "high side switch schematic".

1 Like

@jremington Thanks for your help. And you and the others (@awneil and @ShermanP ) were right. I used the circuit you suggested in another post for a high-side switch and it works perfectly. I'm back to 7uA during sleep. I used the very same components and values you suggested in that post, but my switched voltage and load are slightly different. Do you think I should modify the values of the resistors or use other components? Or this should work just fine? In the following figure I summarize the changes in my application.

It may not matter much since the resistors will see current flow only when the modem is turned on, but I would guess you could make all three of them 100X the values you show, and it would still work fine. And I don't think you need R4 at all.

This appears to be a very interesting project. I see the name on the schematic is "GlacierLapse". Is this your design? Would you like to say more about it?

Thanks for your interest. Yes, it is my design. I'm a glaciologist and I've been monitoring glaciers and glaciar lakes for more than 12 years. We have some glacier time-lapses more than 10-years long in the Canadian Yukon. My early designs consisted of a camera with the shutter constantly pressed and a 12v timer (meant for animal feeding) that would power the camera up for one minute a few times a day. As the camera had the shutter pressed, as soon as powered up, it would shoot a picture. That system proved to be very reliable, but we started to need more flexibility with the picture timing, better timekeeping and telemetry to know the systems were working fine. Also I realized I could improve efficiency to allow reducing the size of the battery packs we used to guarantee 1-year of continuous operation. The products in the market are terrible, so I decided to build something better, and I'm pretty pleased with the result. This change of the high-side switch will be the last before building a few systems that will be installed in Patagonia. I work at Universidad de Magallanes in the southernmost tip of South America. This is how the prototype looks so far:


Those thin cables dangling are a modification I had to do to test the high-side switch.
I'm very amateur in electronics, so any other suggestion to improve the design is very welcome.

That's pretty impressive for someone who claims not to know much about electronics. What is the daily time schedule for the things that are going on? Do you take one picture a day, at noon, and fire up the modem at the same time? And what are bluetooth and GPS used for? Are you saving the pictures on the camera, or transmitting them daily?

If you are down to 7uA idle current, I'm not going to nit-pick. After all, what's a few microamps among friends. :slight_smile: But for future reference, if battery life is really critical, you can use the INT/SQW output of the DS3231 to control a mosfet switch in the 7.4V battery line, which would let you turn off the power completely to everything except when you need to wake everything up. The RTC would operate off its coin cell. It would trip the alarm pin at the alarm time, and the processor would power up and do its thing, then program the next alarm time into the RTC. Its last act would be to clear the alarm flag, which would return INT/SQW to tristate, which would turn off the mosfet, and the power. The mosfet circuit would be arranged a bit differently, but have the same two stages - the main P-channel mosfet and an N-channel mosfet for the gate.

I've done a good bit of work recently on the DS3231, and see that you have my favorite module for that. I just hope it has the DS3231SN, and not the DS3231M. The only problem with the module is that it has a small coin cell holder. I know you are powering the BAT pin from a 3.3V GPIO, so it may not matter. But if that source ever goes away, you would want to use a CR2032 holder, which would just be wired into BAT. I think that cell provides six times the capacity of the little one.

What I wonder about is temperature extremes. Is it cold enough that you have to worry about the batteries or the camera?

Well I think your project is very well done. Congratulations! Now if only we had a few more years of glacier life to photograph.

Thanks for the advice. At the beginning of the project I thought about using the timer as you suggested, but I struggled to design the MOSFET switch, so I went for this option. But is something I would like to try for future projects. Of those 7 uA, about half is the DS3231 (which is indeed the SN version), so I won't redesign everything to save just 3.5 uA. I'm using a rechargeable battery, so I can power the DS3231 through the BAT pin (directly from the 3.3v rail, not from a GPIO pin) and, at the same time, keep a battery there in case the main battery is disconnected.
It takes pictures every X hours (usually between 2 and 4), as long as the sun is above a set elevation relative to the horizon (I'm using -6°).
The GPS is only for units without the satellite modem, and it is used to correct the DS3231 time drift once every two to three weeks. Precise time is important for two reasons: (1) stereoscopic setups, when you want pictures taken at the same time to avoid the effects of changing shadows, and (2) for Ground Control Points. I'm using an almost identical setup that, instead of a camera, has a flashlight that points to the camera, usually a few kilometres away. Two or three of those bright dots in the picture are used as control points to co-register (align) all the images.
The Bluetooth is to configure the device from a mobile phone and download data from the unit. It records the time each picture is taken in case the camera clock dies. It also records battery voltage and temperature when each picture is taken, so in the future, I can improve my battery life estimations.
Pictures are stored in the camera. In the future, I might do one that accesses the pictures and transmits them. Will see.
The satellite modem only transmits once every week or every two weeks. Just to let me know if everything is going well. In a few locations, if there is a problem, I can go and fix it or send somebody to do so. In others, I can go only once a year, so the data is mostly for peace of mind, but it is also useful to set fixing a dead camera as the first priority once in the area.
Here are some pictures of the first prototype and the glacier it is looking. And the view of the camera that has been running since 2012, which overlooks a glacial lake that fills and drain every year. Some years more than once.
Thankfully there will be a long time before these large glaciers disappear.

Here's the circuit I use for that:

It shows the other module, which has a pullup resistor on INT. Yours doesn't have that, which is the way you want it.

The INT pin is normally tristate (off), but when the alarm time is reached, it goes active low. As in your circuit, because of the high voltage being switched, we need the two-stage switch, but the polarity here (active low) is wrong for that. But that is solved by connecing the N-channel mosfet as shown. A positive gate-source differential only develops when the source goes low. That turns on the N-channel, which in turn grounds the gate of the P-channel, turning it on. On this module, Vcc is needed only to power the onboard pullup resistors for I2C traffic, but your module doesn't have those unless you populate them.

Is the module's VCC pin connected to anything? If you're powering through the BAT pin, I think VCC should be grounded, which might save a microamp or two. Also, changing A4 and A5 (SDA and SCL) to INPUT before going to sleep might also save some power. Then change them back to INPUT_PULLUP to do I2C, or just do another Wire.begin. The Serial and Soft Serial Rx and Tx lines may also source some current during sleep.

What I've been working on is calibrating the individual DS3231 by adjusting the Aging register. I use a GPS module that has a PPS (pulse per second) output that is extremely accurate. But even with that, it's calibrated only at the current temperature. The DS3231 has an automatic temperature adjustment, but I don't know how well it works.

So you don't really know at this point whether this thing will last a year or not, particularly in the cold.

That's a very useful circuit! thanks for sharing and for the explanation. I'm sure I'll use it in future projects.

The VCC of the DS3231 is not connected to anything. I just tested connecting it to ground while in sleep and the power draw didn't change. I'm not sure if it should drop right away or it needs to be connected to ground when the module wakes up or something. Maybe then it will disable something that saves power.
Anyway, it would be good to know if connecting it to ground is the recommended configuration when powered only through BAT.
In a year from now I will be able to say more about the time drift of the DS3231 when exposed to low temperatures.
I'm already doing the trick of turning A4 and A5 and pretty much all pins that are not used during sleep to input. That's a good one.

You can buy a tried and true, professional design from Pololu: Pololu Power Switches

Good work!