I am currently creating an embedded project and would like to know what you all think is the best way to proceed.

My setup at its most basic is an ATMEGA328P, a simple momentary pushbutton, a 2500mAh 18650, and an 11 LED ring run by a WS2812.

I am using the FastLED library for running the WS2812. I can only have one button that will be tasked with both power and mode functions (cycle through 10 stored presets). Think long press is power on/off and short press is next mode. Would it be appropriate to place the ATMEGA328 in SLEEP_MODE_PWR_DOWN, turn off BOD and the ADC, and just let it sleep waiting for the interrupt from the button? If it's drawing on the order of 150nA (which I've seen in my research) I think this would be a very acceptable way to proceed. I would just use a P channel MOSFET triggered by the ATMEGA328 to supply power to the WS2812 driven LED ring.

Is there another and or better way to do this? Is it a bad design principle to not have a way to cut power to the processor in the event something goes wrong? (The battery will be internal and not removable).


Your thinking seems mostly ok.

Remember that the self discharge rate of the Li-Ion cell is about 10%/month so this will dominate your current calculation. It may be the equivalent of 300-500 nA continuous current, so battling to get the current ever lower may not help you much in terms of battery life.
You may find this discussion helpful.

If your are using a Pchan switch to power your WS2812b's make sure you set the output port driving it to an input with a '1' in the output register before deep sleeping. You should do the same with the pin driving the WS2812b data line.

There is nothing wrong with sleeping and waiting for a pin change interrupt, just remember to measure your battery voltage when you power back up, since the WS2812b won't work below 3.5V so you need to detect this critical threshold.

  • \$\begingroup\$ Thank you for the response Jack. What is the purpose of setting the output port to an input with a value of '1' before deep sleeping? Does this just ensure a known state while sleeping? \$\endgroup\$
    – Eric
    Jun 29 '18 at 2:24
  • \$\begingroup\$ @Eric, it actually deceases the current used by the port logic. \$\endgroup\$ Jun 29 '18 at 3:13
  • \$\begingroup\$ @Jack Creasey "the self discharge rate of the Li-Ion cell is about 10%/month". Well, when full, maybe. But it quickly drops to a lower and lower rate as the SoC of the cell decreases. \$\endgroup\$ yesterday
  • \$\begingroup\$ @DavideAndrea, sure you are right. At neutral SOC (0%) the rate of self discharge will be a lot lower ....but it has a very high output resistance, so you can't pull much current from it. So your point is? \$\endgroup\$ yesterday
  • 1
    \$\begingroup\$ @DavideAndrea ...you are absolutely right ....my typo. \$\endgroup\$ yesterday

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.