Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

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 has had paid day off for voting for our team for years, if you need help getting that going for your organization, let us know – we can share how and why we did this as well as the good results. Here are some resources for voting by mail, voting in person, and some NY resources for our NY based teams as well. If there are additional resources to add, please let us know – adafruit.com/vote

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 code.org, 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.

Join 24,000+ makers on Adafruit’s Discord channels and be part of the community! http://adafru.it/discord

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!

Follow Adafruit on Instagram for top secret new products, behinds the scenes and more https://www.instagram.com/adafruit/

CircuitPython – The easiest way to program microcontrollers – CircuitPython.org


Maker Business — To make it through a tough business cycle, layoffs should be a last resort

Wearables — Rub’n’buff

Electronics — Multimeter Bandwidth – AC Signal

Python for Microcontrollers — Python on Microcontrollers Newsletter: CircuitPython 6 Release Candidate, new hardware & more! #Python #Adafruit #CircuitPython #ElectronicHalloween @micropython @ThePSF

Adafruit IoT Monthly — Matrix Portal, Solar Lawn Sprinkler and more!

Microsoft MakeCode — micro:bit version 2 Announced!

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

New Products – Adafruit Industries – Makers, hackers, artists, designers and engineers! — New Products 10/21/2020 Featuring Adafruit Voice Bonnet for Raspberry Pi – Two Speakers + Two Mics (Video)

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



2 Comments

  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.