using arduino uno to turn battery power source off and on

what im trying to build:

a portable battery-powered usb charger (think the mintyboost) that only works when its in motion. basically if you're holding the charger and walking, it should start charging your device. if you stop, the charge halts.

i currently have an arduino uno. i'm wondering what else i should be utilizing to get this working?

for example to address the motion part, an accelerometer doesn't seem right. mercury/tilt sensor? gps?

i have experience coding but none with actually building anything with arduino (besides a few simple tutorials with led lights and such). anything would be a great help to get me started.

A tiny relay would be the most efficient way to turn the battery on and off.

An accelerometer would probably be the most efficient way to detect random motion. A tilt switch will only work for fairly gross movements. GPS will only work over relatively long distances and with a clear view of the sky. Just average each of the three accelerometer readings. If all three current readings are very close to the average, your are still. If any is not very close then you are probably in motion.

johnwasser: A tiny relay would be the most efficient way to turn the battery on and off.

An accelerometer would probably be the most efficient way to detect random motion. A tilt switch will only work for fairly gross movements. GPS will only work over relatively long distances and with a clear view of the sky. Just average each of the three accelerometer readings. If all three current readings are very close to the average, your are still. If any is not very close then you are probably in motion.

thanks for the tips. i mocked up a super simple non-technical diagram just to get my head around things a bit more

would it be something like this? I'd just power the arduino with a 9v and barrel jack adapter.

after looking at some accelerometers, it looks like i should be looking at ones with high precision for small movements and ideally low power consumption. Any recommended ones for usage?

As for relays, I'm trying to get my head around solid state/DPDT/etc etc and which ones would be DC power only (since I want to just use 2 AA batteries as the power source to charge the phone). Any recommended relays I should look at?

I'm using a sparkfun redboard to build the prototype.

If you could cope with three AA cells instead of two, you could run the Arduino off the same batteries as the charger and get rid of that horribly expensive and inefficient PP3. I imagine the relay will be one of the more significant power draws. It would need to be specced according to the current and voltage it needs to switch, but if you're only switching low currents then very small relays are available that only need tiny amounts of current. If you anticipate switching the relay very infrequently and want to minimise the current draw when it's 'on' then it's possible to get relays that will latch on (don't need any current to turn them on).

As far what you are asking for versus the image you provided, this seems vaguely appropriate. I am, however, trying to wrap my head around why you might only want to charge while in motion... but no need to explain it to me.

As for the actual device you are trying to build, for proof of concept use parts which are cheap and readily available. However to scale it down a bit (like the mintyboost), think: (The following is is MUCH larger than necessary, but easy for beginners)

-- Arduino Nano (USB for uploading sketches, voltage regulation and all the power of the Uno) -- 7.4V Lipo battery to Arduino (Vin pin) (small, light, rechargeable, less heat loss and more mAh than 9V) -- 3.7V Lipo to charge the phone (again, very small, light, rechargeable, etc.) -- Relay will work but so will a medium power mosfet. (you have several options, just make power consumption important, both when charging the phone and when it isn't .

I see the last two as being good upgrades as compared to the mintyboost. I hate buying tons of batteries for my projects!

thanks for the suggestions so far! as for the actual board i'm just sticking with the sparkfun redboard.

MOSFET seems more ideal for switching things on and off quickly it seems? But i don't want to get my brain busted too hard right now and will just stick with a relay, even if it might be less power efficient. Can anyone recommend any commonly used relays that would work with 2 AA batteries as the power source? (LiPo seems more efficient but I just want to stick with this for simplicity's sake)