I have been tinkering with using my Arduino in spots where mains power is not an option so I need to test how long my projects will work on battery power. While it is easy enough to use a AA or 9V battery holder and insert them into the VIN and GND on the Arduino, I wanted a little bit of additional flexibility. I achieved this by using an old aluminium enclosure and a SPDT Miniature Toggle Switch to allow me to turn it on or off.
For the project, I used the following parts. Of course you don’t need all of these, this is just what I had laying around that proved useful. Items marked with an Asterisk are necessary and vital components.
- 2.1mm Centre Positive plug*
- 9V or 6+AA Battery Holder*
- Hookup Wire*
- SPDT Miniature Toggle Switch
- Wire Strippers
- Heat Shrink Tubing
- Aluminium or Plastic Enclosure
- Digital Calipers
- Drill Press, 6.5mm (0.25 inch) and 10mm (0.39 inch) drill bits
- Electrical Tape
- Soldering Station
I used the digital calipers to measure the sizehole I needed for the lid of my enclosure. It was 6mm (0.23 inch) in width, so I drilled a hole using my 6.5mm (0.25 inch) drill bit. I then fit it to make sure the hole was big enough, but that there was also enough clearance underneath.
I grabbed my 9V battery holder and cut off a small amount of heat shrink tubing and then threaded the red wire through the one of the outer pins on the Toggle Switch. It didn’t matter which one as whichever one it was not soldered to would be the ON position. I soldered it then pushed the heat shrink tubing over it to ensure a snug and short free fit.
I then cut off a small amount of hookup wire and repeated the above process with the centre pin of the Toggle Switch.
I unscrewed the outer casing of the plug and then soldered the 2 wires on. The red wire went onto the centre pin, with the black wire being soldered to the outer pin. I then screwed the outer casing back on and plugged in a battery to make sure everything worked.
I kind of forgot to drill a hole and thread through the wires leading to the plug until after I had already soldered it. Oops. So I had to drill a hole big enough for the plug to fit through. While this was a mistake, I am not too disappointed because it means I can take the entire assembly out of the enclosure if I need to without breaking anything.
I screwed on the Toggle Switch and closed the case just to make sure everything was going ok. When this was confirmed, I plugged in a battery and gave it a final test. Everything functioned great! To keep the battery from sliding about, I grabbed some electrical tape and folded it over itself to stick between the enclosure and the battery. This worked well.
Just in case I forgot which side of the Toggle Switch was on or off, I printed some simple labels and stuck them on.
Also posted to Instructables.