Electronic – arduino – How should I power the permanentified project

arduinoatmegahardwarepower supply

I have transferred my project from an Arduino to a microcontroller. I want to make it into a permanent installation; for that I need to power it.

If I want to power it via a wallwart, what precaustions/safety circuits should I add? How about with a battery?

If I had a choice, which would be more advisable?

Best Answer

Note: All references to 5 Volt supplies et cetera apply only to the standard Arduino boards that are based on a 5 Volt design. Boards like the Arduino Due, Fio, and 3.3 Volt versions of the Pro and Pro Mini, as well as 3.3 Volt Arduino clones, need to take this into account: Where you see 5 Volts mentioned, replace with 3.3 Volts for those boards.

First, the decision factors for type of power source:

  • What does your project do, how much power does it consume at peak (guesstimate if you can't measure it), and what percentage of time it is programmed to stay in low-power mode?

    • If the device is going to be in low power most of the time, a wall-wart is wasteful and inconvenient, compared to a self-contained battery pack.
    • If peak power requirement is high, such as multiple high-power LEDs or a motor being run, then a wall-wart makes sense, however.
  • How physically accessible is the device, or how accessible do you want its insides to be?

    • If the device will be placed permanently in an out of the way place, wall-warts avoid the inconvenience of changing batteries
    • If you do not want anyone accidentally or on purpose opening up the enclosure and messing with the device board (you do have it in an enclosure, right?), then again the wall-wart is the better option.
  • Is portability or hand-held use intended?

    • Clearly, in such cases the device needs to be battery powered.
    • A hybrid approach is to use rechargeable batteries, add a charger circuit into the enclosure, and charge it from a wall-wart as required. More green than throwing out batteries often, yet avoids tethering the device to a power cord.
  • Is a power line available at the permanent deployment location?

    • If not, then wall-warts are evidently out!
    • Solar panels and rechargeable batteries have been used a lot for remote weather monitoring projects, that's an interesting approach. Again, needs additional electronics for the solar charging and battery monitoring
  • Is always-on relatively important?

    • Depending on the mains supply conditions, some places would then preclude a wall-wart. Batteries are the only option.
    • However, batteries bring their own challenges around always-on: Some form of noticeable (e.g. loud buzzer) / remote (e.g. radio) alerting is needed for lwo battery conditions, triggered before the battery is too depleted for such alerting.
    • Of course, Arduinos are not specified for mission-critical always-on operation: While they behave well enough in practice if operated 24-7, ensure that no one's safety depends on this operation.

Now, the wall-wart option:

  • If possible, use a high-quality 5 Volt regulated wall-wart (isolated mains power adapter with a clean 5 Volt DC output)

    • Connect this to the +5V pin of the Arduino, not VIN or the DC jack, thus bypassing the on-board 5 Volt regulator, which would otherwise generate some heat on the board. In permanent implementations, heat causes degeneration or device failure.
    • Often, USB mobile phone chargers of quality-sensitive brands provide excellent regulated 5 Volt power, at an unmatched price: Just use the best USB charger you have spare! This is not applicable to 3.3 Volt boards, of course.
    • Check the output power quality of your wall-wart of choice before trusting your precious device to it: Some chargers can output 6 or more volts while nominally being 5 Volt adapters. Many of the commonly used microcontrollers in standard Arduino designs can not tolerate voltages above 5.5 Volts, so goodbye Arduino!
  • If quality of voltage regulation of the wall-wart is not assured, then using a wall wart designed for 7.5 to 9 Volt DC output is suggested, with the on-board voltage regulator IC doing the 5 Volt regulation:

    • The Arduino official recommendation states "9 to 12V DC, 250mA or more, 2.1mm plug, centre pin positive."
    • The 5 Volt Arduino designs do, however, accept voltages down to 7 Volts, even less at a pinch. The higher the voltage supplied, the greater the amount of power the on-board voltage regulator must waste as heat - and we already discussed that. Hence the conservative voltage range suggested above, despite the official stance on this matter.
    • This connects to the DC barrel jack if available, or else the VIN pin (and GND for the negative wire), on the Arduino board - not to the +5V pin mentioned for the earlier method.
    • It is best to find a wall-wart rated for 500 mA or even 1 Ampere, if possible. Two reasons: (1) The Arduino and whatever else makes up your permanent device, will have headroom to draw more than the mere 250 mA minimum recommendation, and (2) higher rated power adapters typically last longer if run at well under rated capacity, since they are designed to cope with a higher load.
  • If any parts of the permanent Arduino device, say a motor or Piranha LEDs, require high current - which for this discussion is anything greater than say 100 mA - then it is best to supply that subsystem with power directly from the wall-wart supply, in parallel to the supply being provided to the Arduino board itself.

    • This requires specific design decisions, such as controlling the high current device via a BJT, MOSFET or relay, and ensuring the grounds of the respective subsystems (the Arduino, and that power-hungry thing it is controlling) are well-connected, at a single point.
    • Supplying this power directly off the VIN, or worse, the +5V line on the Arduino board puts unnecessary thermal stress on the Arduino PCB's tracks and components, such as the rectifier diode, and for the +5V case, the on-board voltage regulator.

For using a battery:

  • Use batteries designed for supplying higher current than the peak current needed by the device. The rectangular box-shaped 9 Volt batteries are typically not specified for such currents (some are), so are best avoided.
  • If the device spends a large percentage of time in low-power inactive modes, then a low leakage current type of battery is recommended, to extend the operating period.
  • Use a set of batteries that provide at least 6.5 Volts, e.g. 5 x AA cells, and connect them to PWRIN (DC barrel jack) or VIN and GND, as before.
  • If the Arduino-based device is not sensitive to supply voltage quality, e.g. it does not use the Arduino's ADC for any sensitive data acquisition, then additional efficiency can be achieved by using a 5 Volt DC-DC buck regulator between the battery and the circuit, and feeding the output to the +5V pin (and GND). Buck regulators or switch-mode DC-DC regulators are more efficient than linear regulators such as the one on board the Arduino. Thus less power is wasted as heat, and the batteries should last longer.
  • If rechargeable battery operation is desired, a good option is a LiPo battery shield that incorporates charging and battery monitoring in one place. Some such shields even have a 5 Volt switching regulator on them, with efficiently regulated 5 Volt DC fed directly into the Arduino's +5V pin.
  • Design some form of battery status reporting into the permanent Arduino device if possible, so that an early warning can be provided well before the batteries run out.

One interesting battery strategy involves designing the final Arduino device to run at reduced operating voltage, such as 3.5 Volts and up. This requires using a reduced clock crystal (say 8 MHz instead of 16 or 20 MHz), the microcontroller needs this reduced frequency for stable operation at reduced voltage.

The device is then powered by just 3 AA cells, so the battery pack voltage varies from 4.5 Volts at full power, down to around 3.0 Volts or so in depleted state. No voltage regulation is required, the battery pack directly feeds into the +5V pin on the Arduino.

This also eliminates the efficiency loss at the on-board voltage regulator, which is bypassed in this arrangement. So long as the set of 3 batteries can provide at least the bare minimum voltage the specific microcontroller can operate down to, your device will continue working. This information can be determined from the datasheet of the particular microcontroller to be used.

I hope the above notes provide at least an initial basis for designing the power solution for permanent deployment of your Arduino project.