Wednesday, October 7, 2015

Arduino Driven Current Activated Power Controller

I like things to be easy, and I would really like it if the shop-vac connected to my miter saw box (or router or table saw if I've moved it) would simply turn on when I cut something.  It would definitely get used a lot more often if it happened automatically, cutting down on the amount of dust in the garage and my lungs.  There are existing products that solve this problem like the i-socket Autoswitch, but I decided it might be fun to try and build one myself with an Arduino.  So I did :)

Parts list:
1x Arduino (I used a Nano)
1x 30 amp ACS712 Current Sensor
1x relay.  I used a 30 amp relay just to be safe.
1x project box, I used a fairly large one to make wiring easier.
2x modular power outlets, I bought a 12 pack.
1x modular receptable (like you generally see on a computer power supply)
1x USB Power Adapter (I used an old iPhone charger), or something like this
1x Pack of terminal connectors
1x 16x2 LCD, with an i2c adapter (I used a version from ebay/china)
1x 1x4 LCD button (I used a version from ebay/china)
Romex electrical wire, I used 12 gauge I had lying around but for a 15amp circuit 14gauge is fine.

Finished product:

For the assembly I took my dremel and cut holes in the sides of the box, then I used the dremel to trim the "ears" on the outlets because they were a little too long to snap in to place.

Then I fit each of the power outlets and receptacle in to the box, and ran the eletrical wire.  Here's a drawing of how I ran the electrical in the box.

Then I did a thorough "walk through" of the power to make sure everything was connected properly, nothing was touching anything it shouldn't, etc. and made sure I wasn't going to set the house on fire when I plugged it in.  Then I connected the Arduino to the ACS712 and the relay, wrote a basic sketch to turn the relay on and off and uploaded it to the Arduino.  The relay toggled on and off as expected, so all I had to do was figure out how to the current sensor.

I ended up using some example code from a thread on SparkFun to read the current going through the ACS712, and then basic logic to enable the shop vac when the amount of current exceeds the set limit, and turn it off (after a configurable delay) when there is no current.   The sketch is available here.  If you don't want to use an LCD or the membrane buttons you can carve that logic out of the code.  The top line of the LCD displays the current amount of amperage, the configured / trip current, and the current state of the mode button which toggles buttons 3 & 4 from changing the current limit to the sleep timer.  The bottom line displays the sleep time, the override state, and pwr which is the relay state.

The ugly insides.

What would I do differently?
I'd use stranded wire to make the wiring easier
I'd figure out how to better mount stuff in the box so it looked good
Use a different power supply, I just ordered this and this to see what works best.

No comments:

Post a Comment