Is it possible to change clock speed when running sketch?

Low-power lib drops the current consumption from 20mA to 9.5mA at 8MHz, it is still too much. Is there a way how to set clockspeed (for example) to 1MHz, go to sleep, after interrupt wake up, set clockspeed back to the 8Mhz (for 3v3), do some stuff and then go sleep again?


1 Answer 1


Absolutely. The built-in prescaler can dynamically change the clock speed for most of the systems on the chip (USB still needs to run at full speed in order to operate properly).

#include <avr/power.h>


See the datasheet and AVR Libc documentation for more details.

  • Thanks, I've just tryed this, but it didn't help. The power consumption is the same as before. clock_prescale_set(clock_div_8); attachInterrupt(INTERRUPT_PIN, wokenUp, RISING); LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
    – Andreisk
    Nov 5, 2017 at 14:22
  • 1
    Probably because most of the clocks are off in that power mode, so aren't running in the first place. Nov 5, 2017 at 14:23
  • What should I do then do achieve the lowest power consumption with wake up by interrupt?
    – Andreisk
    Nov 5, 2017 at 14:28
  • Disable unneeded peripherals. Reduce overall clock speed. It's all in the datasheet and application notes. Nov 5, 2017 at 14:31
  • Also remove the power led from the Arduino board, as that is also using power without doing anything useful.
    – Gerben
    Nov 5, 2017 at 16:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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