ASK AN EDUCATOR! “Is there a way for an Arduino to turn itself off?”

Jimbo asks:

Is there a clean way for an Arduino to cut its own power?
I’m hacking into an existing circuit that is battery-powered, and I would like to be able to, say, reset the microcontroller, which then waits for some kind of input from the hacked device, and then when it’s done processing, it turns itself off (to save batteries on the host circuit).

Absolutely! And its quite easy to do when you use some of the lower level functionally of the Arduino’s AVR. Most micro controllers contain a piece of hardware called a Watchdog Timer which, when enabled, will perform either a hard or soft reset of the device. The cool thing about utilizing the watchdog on the newer Arduinos (ATMEGA168/328) is that you can actually execute a function after each reset (ATMEGA8s can only perform a hard reset). There are two things you need to do to properly utilize the watchdog. First, when you initialize it, you set the quantity of time the micro controller waits before performing the reset, set in “setup_watchdog(X);.” You can set X to 0=16ms, 1=32ms, 2=64ms, 3=128ms, 4=250ms, 5=500ms, 6=1024m, 7=2048ms, 8=4096ms or 9=8192ms. The second thing you need to do is “pet” the watchdog in order to prevent unwanted resets. By periodically adding “wdt_reset()” to your code, you reset the watchdog’s timer and preventing the reset. This is also a good way of adding stability to your code. If you software hangs, the watchdog with reset the device.

With regards to power consumption, you are in luck. If properly utilized, the Arduino can draw mere micro-amps when put to sleep. This sleep function, when paired with the watchdog, can result in a very low power and stable device. There are approximately 5 sleep modes that dictate which functions are put to sleep and are detailed in the AVR doc. When I set my Arduino to POWER_DOWN mode, I measured only 20.7uA at 3.3V :-).

There is a good page on Arduino’s site that demos the sleep functions.

Check out Nathan Nawrath’s Nightingale project, which gives a very good example as to using the watchdog and sleep functions.

You might also want to check out the Narcolpetic library for Arduino, which makes putting Arduino to sleep super easy!

I hope this answered your question and good luck with your sleepy Arduino!

Next up is Hal with a question about teaching future EEs!

Don’t forget, everyone is invited to ask a question!

Click here!

“Ask an Educator” questions are answered by Adam Kemp, a high school teacher who has been teaching courses in Energy Systems, Systems Engineering, Robotics and Prototyping since 2005.

Adafruit publishes a wide range of writing and video content, including interviews and reporting on the maker market and the wider technology world. Our standards page is intended as a guide to best practices that Adafruit uses, as well as an outline of the ethical standards Adafruit aspires to. While Adafruit is not an independent journalistic institution, Adafruit strives to be a fair, informative, and positive voice within the community – check it out here:

Join Adafruit on Mastodon

Adafruit is on Mastodon, join in!

Stop breadboarding and soldering – start making immediately! Adafruit’s Circuit Playground is jam-packed with LEDs, sensors, buttons, alligator clip pads and more. Build projects with Circuit Playground in a few minutes with the drag-and-drop MakeCode programming site, learn computer science using the CS Discoveries class on, jump into CircuitPython to learn Python and hardware together, TinyGO, or even use the Arduino IDE. Circuit Playground Express is the newest and best Circuit Playground board, with support for CircuitPython, MakeCode, and Arduino. It has a powerful processor, 10 NeoPixels, mini speaker, InfraRed receive and transmit, two buttons, a switch, 14 alligator clip pads, and lots of sensors: capacitive touch, IR proximity, temperature, light, motion and sound. A whole wide world of electronics and coding is waiting for you, and it fits in the palm of your hand.

Have an amazing project to share? The Electronics Show and Tell is every Wednesday at 7pm ET! To join, head over to YouTube and check out the show’s live chat – we’ll post the link there.

Join us every Wednesday night at 8pm ET for Ask an Engineer!

Join over 36,000+ makers on Adafruit’s Discord channels and be part of the community!

CircuitPython – The easiest way to program microcontrollers –

Maker Business — “Packaging” chips in the US

Wearables — Enclosures help fight body humidity in costumes

Electronics — Transformers: More than meets the eye!

Python for Microcontrollers — Python on Microcontrollers Newsletter: Silicon Labs introduces CircuitPython support, and more! #CircuitPython #Python #micropython @ThePSF @Raspberry_Pi

Adafruit IoT Monthly — Guardian Robot, Weather-wise Umbrella Stand, and more!

Microsoft MakeCode — MakeCode Thank You!

EYE on NPI — Maxim’s Himalaya uSLIC Step-Down Power Module #EyeOnNPI @maximintegrated @digikey

New Products – Adafruit Industries – Makers, hackers, artists, designers and engineers! — #NewProds 7/19/23 Feat. Adafruit Matrix Portal S3 CircuitPython Powered Internet Display!

Get the only spam-free daily newsletter about wearables, running a "maker business", electronic tips and more! Subscribe at !


  1. Useful post thanks!

  2. Thank you very much for answering my question! I will look into Watchdog and Sleep functions. Keep doing what you’re doing; the internet thanks you!

Sorry, the comment form is closed at this time.