Hacker News new | past | comments | ask | show | jobs | submit login

You can use the standard AVR sleep modes and interrupts on Arduino. Put the uC to sleep and have it wait for a pin to change or a timer to elapse before waking instead of idling at full power. See the Arduino docs (or the Atmel datasheets, which are easy to read):

https://playground.arduino.cc/Learning/ArduinoSleepCode

There are libraries that do this automatically on Arduino too, allowing you to schedule [cooperative] multitasking and sleep the uC between tasks. E.g.

https://github.com/arkhipenko/TaskScheduler

is really good, I've used it before. You basically queue up a list of task callbacks and a schedule in your `setup()` and then do a call to `tasks.execute()` in `loop()`, which pops off the next task that is due in a queue or sleeps otherwise. It's simple, but much more straightforward than manually using `if millis() - last > delta1... else sleep()` and not as rigid as using the timer ISRs (which really serve a different purpose).

On more complex platforms you can also use an RTOS, which is kind of like a more beefed up version of this model. Actually you can do this on AVR too, but I haven't ever seen anybody actually use FreeRTOS/ChibiOS/whatever on AVR.




This is relevant to my interests being that I just got into this Arduino thing. Thank you


Bear in mind that while what he said is correct, there are other concerns on an assembled board, as opposed to the bare chip. Arduino has a voltage regulator that is always consuming current. The Power LED is always consuming current. You should be sure to set pin 13 (the indicator LED) as an output and turn it off, since even as an input, there will be leakage current through the LED. The other active components on the board have their own quiescent current levels, etc.

You can get an AVR device to run on a coin cell for months or years (I have a design that does just that). You'd have to modify an Arduino significantly to do the same.


Very true, though there are some better Arduino variants. The Pro mini is the canonical "low power" Arduino as it uses a very efficient LDO regulator. I also use bare ATTiny's for a lot of uses, they don't require any passives and can run directly from a LiPo as long as you use a protected cell or connect a feedback line to the ADC.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: