USB Controlled Power Outlets



Idea:

There are a few devices around my desk that I have always wanted to automate and control with my computer. My ideal product is a power strip that also has a USB-A adapter to lets me use terminal commands to change which outlets are on and off in a given moment.

Parts:

  1. Ardunio Nano
  2. Cute wooden box I found at Goodwill
  3. 6x 120vac SPST Relay (5v trigger)
  4. 3x female 120vac plugs
  5. microB cord
  6. 120v "suicide cord"

Result:





This is the final result. It works and I love it. All it takes to control my outlets is the following bit of python:

import serial
import sys
from time import *

# index is between 0 and 2 
# value is true or false for on or off
def set_status(index,value):
	if value:
		ser.write([0,index])
	else:
		ser.write([1,index])
	ret_val = ser.read_all()[0]
	assert not ret_val == 3
	return ret_val

# get the status of an outlet
def get_status(index):
	ser.write([2,index])
	ret_val = ser.read_all()[0]
	assert not ret_val == 3
	return ret_val-4 == 0
	

Insides:






All content on this page belongs to Zachary Porter. You may use, reproduce, or modify anything from this website, provided that you give credit to zackporter.com in your usage.