Blink LED while Arduino is sleeping in power down with external timer ?

Hi All,

Electronics newbie here !

I am building a handheld remote that will have 4 LEDs turn on when remote stations acknowledge a data transmission. To save battery power I put the handheld unit to sleep as well as power down the Xbee radio.

To further reduce my power needs, I am thinking that if I had the LEDs slowly blink while the unit is sleeping I would save power while the LEDs are in the off state.

My questions :

1- Can this be done with some external components like a 555 timer ? The LEDs share the same ground but are connected to 4 different arduino pins.

2- Is this worth doing or will the extra components consume the power that I would like to save from having LEDs off. They are surface mount green LED, the resistors are 330 Ohm surface mount.

I have attached a basic schematic of the LEDs.

Yes it can be done and if designed correctly the 555 would draw extremely little current over the LED itself. And yes you will be drawing battery power while blinking in sleep state. You will need to design a gate perhaps off a different pin that enables the 555 when the Arduino goes to sleep.

Need more detail to give you better answer.

wolframore:
Yes it can be done and if designed correctly the 555 would draw extremely little current over the LED itself.

No. The 555 is an ancient IC. Very power hungry compared to newer devices.

@OP: if you use sleep properly and have all the power hungry parts of the Arduino removed it is hardly worth adding some extra timer. Since the timing is not critical you may use the WDT to wake up Arduino periodically and blink the LED.

there are CMOS 555 (LMC555) that are actually very efficient. Again depends on the circuit design. The Arduino would consume much more than that while awake.

Thanks for the responses.

@ Wolframore, let me know what other info you would like.
Meanwhile I have attached a schematics of what I am thinking based on some of the research I did for the circuit. The schematics is based on components I have at home.

I am not quite there yet because :

1-- The component values most likely need tweaking - comments welcomed - because I am adapting research for
a 5 volt Arduino to a Pro Mini running on 3.3v.

2-- I would like the LEDs to be off longer than on, I think current R1, R2, C1 values would give about 1.5 seconds
ON and 0.5 seconds OFF.

3-- I also would like the LEDs to be always ON when the handheld unit is "awake", I can use pin#3 to turn the
blink section on or off in code based on if system is awake or not but it feels like I would need a way to
bypass the transistor or the entire 555 circuitry so that the LEDs stay on when system is awake.

thanks

wolframore:
there are CMOS 555 (LMC555) that are actually very efficient. Again depends on the circuit design. The Arduino would consume much more than that while awake.

While technically this is true, it is not relevant(*). LMC555 consumes 50uA@1.5V and 100uA@5V (typ). You must also add significant current for the RC timing circuit. OTOH properly sleeping Arduino consumes <10uA with WDT active. With no extra cost order of magnitude less.
Comparing 555 current with current of awake Arduino makes no sense - if the Arduino is awake for some other reason it will eat much more current than the 555 but it will also handle the timing “for free”.


(*) LPT50xx timers consume current in tens of nAs. LMC555 is still many orders of magnitude behind.

@Smajdalf, I am not sure I fully understand your 1st post of this thread. The idea behind my handheld unit is comparable to a TV remote. So while watching a show it can sleep and only needs to be awake when I press one of the 3 buttons on the unit. While it is sleeping I want a visual reminder that all 4 remote stations that receive signals from the handheld unit are within range - so I have 4 LEDs turned on the handheld unit to acknowledge their individual status.

To save battery power, my current code and circuit powers down the XBee radio with the use of a transistor connected to a digital pin and puts the arduino in power down sleep mode.

Are you saying that I would still save power by waking the arduino every 3 or 4 seconds to blink the LEDs that need to be on ? Will the power consumed by waking the Arduino be more than the savings from the LEDs being off ?

So I would end up with an interrupt routine that either wakes the system up because a button is pressed or the sleep period has expired and it’s time to blink the LEDs.

I also read posts that suggest that power save mode with WDT running requires less power than power down mode with wdt running ?

Thanks

Dan you can enable/disable the 555 with a mosfet switch from one of the Arduino PIN's. It would consume no power while Arduino is on and LED would not be blinking. While it consumes power while blinking it would be much less than Arudino. I have seen circuits where the CMOS 555 circuit consumes a few milliamps over the LED output.

Personally I like CMOS circuits and when designed correctly can add functionality to your microprocessor circuits without other issues...

For your schematic - you will need to invert the output. It will be on longer than off as designed. Also looks like the Arduino has to be on blink anything because 3.3v is sourced through a pin... Think through it. I think you're on the right path.

The right way is to sleep Arduino for i.e. 4 seconds -> wake up -> turn on LED(s) -> sleep for short time (16, 32 or 64ms) -> turn off the LED(s) -> sleep for 4 seconds. IMHO there is no way and no parameter how 555 may beat this. If you already have a MCU in the system ofc.

The right way is to sleep Arduino for i.e. 4 seconds -> wake up -> turn on LED(s) -> sleep for short time (16, 32 or 64ms) -> turn off the LED(s) -> sleep for 4 seconds.

Agreed.

The LEDs will waste so much power that the sleep mode may even be irrelevant.

Thanks for the replies gang !

I have to say I really like this forum and all the valuable input I get from everyone !!

While I have some time on my hands, I will try to explore various options from your replies.

Could I get guidance on the steps I need to take to have the watchdog sleep for 2 different duration (4 secs and say 250ms or maybe 500ms ?). Also how do I get it to keep doing that except when a button is pressed and the "button interrupt" has been triggered ?

jremington:
Agreed.

The LEDs will waste so much power that the sleep mode may even be irrelevant.

Do you mean that the 2nd shorter sleep period like 250 or 500ms that I am after might not be worth it because the LEDs will be on during that bit and use up power ?

I guess a revised schematics (based on the original one below) could be the arduino pin#3 directly to the R7 resistor and transistor to supply (or not) the common ground for the LEDs. So skipping over the 555 circuitry.

Do you mean that the 2nd shorter sleep period like 250 or 500ms that I am after might not be worth it because the LEDs will be on during that bit and use up power ?

To determine whether sleep mode will really save much power, you need to figure out how much average current the LEDs will draw when blinking and compare that with the MCU current.

Don't forget that the output pins will continue to supply current in sleep mode, unless you turn them off.

The average current per LED is

Iave = (duty cycle)*(Vcc-Vled)/Rlim

Where Vled is the LED forward voltage, Rlim is the value of the current limiting resistor and duty cycle = (time on in seconds)/(flash repeat time in seconds).

could be the arduino pin#3 directly to the R7 resistor and transistor to supply (or not) the common ground for the LEDs

Just use GND for the common LED ground. The output pins determine whether the LEDs are on or off.

I still see circuit issues with your design. If the 555 is to switch those led’s with the Arduino off how are the leds getting power?

@wolframore :
I understood that once a pin is set to a state, when the arduino sleeps the state stays the same. So pins that are HIGH would stay HIGH and power each LED as required.

The idea is handheld unit send a command to remote units, if in range they respond and the corresponding LED is turned on (on the handheld unit). Now once the user has seen this and is no longer pressing buttons the handheld unit can go to sleep and so can all 4 LEDs regardless of their individual state.
That's why I was thinking of using another arduino pin (pin #3) to act as a "master on-off" for all the LEDs.

@jremington : if I follow what you are saying, my thought of using pin #3 as a "master switch" as described above would consume more power since the individual pins would keep the original state and only the master on-off would be toggle by the WDT routine. I would be better off with code that blinks only the LEDs that were previously ON individually so that each output pin is written LOW during its off cycle instead of staying high but having the master pin be LOW.

That's why I was thinking of using another arduino pin (pin #3) to act as a "master on-off" for all the LEDs.

You can turn off all the LED anode pins using a single instruction. Same power consumption either way.

I think I misunderstood what you are saying with this...

Don't forget that the output pins will continue to supply current in sleep mode, unless you turn them off.

Is turning off each pin better than my idea of using a "master switch" with a transistor connected to a arduino pin and the ground of all 4 LEDs ?
Because you wrote :

You can turn off all the LED anode pins using a single instruction. Same power consumption either way.

Your method wastes an output pin, a transistor and a resistor.

In addition, my previous comment was not completely correct. Setting the anode pins to input will turn them off as well as save a little power.

Everything you ever wanted to know about power saving in the ATmega can be found in this tutorial.

I have been away so not following up on this thread.

I am having a hard time wrapping my head around using the WDT to blink some LEDs and trying to get my whole unit to sleep for as long as possible. If anyone could give me project guidance - maybe the structure my code should have, that would be great.

As I mentioned before, the unit is like a TV remote so it needs to sleep while no one is pressing one of the 3 buttons. Only the "ON" button would actually turn the confirmation LEDs on - so that would be the one button that would require the WDT to start blinking LEDs every 4 seconds.

What I am trying to achieve is :
---sleep the unit,
---wake it up on any of the 3 buttons being pressed,
---keep it awake for let's say 3 seconds to make sure all data is sent out,
---then put it right back to sleep until next button is pressed.

It would only wake up periodically if the last button that was pressed was the "ON" button - to blink the LEDs

This feels like the Inception movie (sleep within sleep) :slight_smile:

thanks for the help !

You need an RTC to keep time in power down sleep mode, if buttons are the only wakeup option.

Many people do something like this, in order to sleep as long as possible:

(1) set the WDT to wake in X seconds (from the available options)

(2) go into power down sleep mode

(3) upon wakeup, add X to the total elapsed time in seconds, and check whether something is to be done. If not, go back to sleep.

This will only be approximate timing.

An alternative is to use power save mode, in which Timer2 can be driven by a 32 kHz watch crystal to keep time during sleep. This mode can be used to implement a self contained RTC with accurate timing, but more current is drawn than in power down mode.

thanks.

If I understand correctly, the steps you mention will have the unit wake up every 8 seconds (max available option) run the main loop to do something if required and go back to sleep.

I was hoping to figure out a way where it can sleep an entire day if no one presses a button.

Something like :
--sleep the unit if no button pressed and awake for more than 3 seconds.

--if button interrupt fired, run main loop to see which button is pressed and send out data.
also reset the 3 second period to make sure all data is sent.

--if pressed button was the ON button, start a watchdog timer to blink the lights every 4 seconds
and go to sleep

if a button press interrupt is triggered again stop the WDT and run the main loop again, etc.

does this make any sense ? I am not sure I fully understand the WDT and where code resumes from and how to make sure it does not reset the whole unit.

also can I set it to different values to get LEDs OFF, sleep 4 secs, LEDs ON, sleep x- mS and loop again