I've solved the battery power supply issue for my Arduino project by simply connecting a USB powerbank. However, I just realised that I can't come up with a good way to add an on/off button! There doesn't seem to be a way to turn the Arduino off using software. My second solution would be to cut up the USB cable (or an extension chord) and solder a switch onto the 5V wire.

Is there a more convenient solution that I'm missing?


You could put the microcontroller into sleep-mode. Then use a button (connected to one of the interrupt pins) to wake it up.

But depending on what Arduino board you are using, and what other sensors etc you've connected to the board, this might not save that much current. For example on the UNO board the usb-to-serial converter is always on, so while your MCU is sleeping and trying to save power, the usb-to-serial continues to draw current.

But adding a switch to a usb-cable would be a lot simpler.

PS doesn't the powerbank have an on-off switch?

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