Sunday, August 6, 2017

HOBloom - Building Smart Outlets

WARNING: I am not liable for anything you do as a result of reading this.  Do your own research on what is and is not safe and always be careful when messing with high voltage! Read on at your own risk!

Seriously, AC is no joke proceed with extreme caution and always consult a licensed electrician

Check out the project that these are for as well as the other grow tent!

Live Stream:
Support HighTek:

[ Intro ]

    In this lesson, we will be going over creating smart outlets for your HOBloom automation system. This same wiring will work for any other software but we specifically will be building it to work with HOBloom.  Once we build the outlet and wire up out relay we can use each port on the outlet to control our appliances in our grow room.  Below you will find a list of the materials needed to build the outlet.

[ Materials ]
[ Prepare The Outlet ]

    The first thing we need to do is break the little metal tab on your outlet.  This will allow you to control both outlets individually.  We only need to break the tab on the hot side of the outlet.  We can leave the tab on the neutral side of the outlet as the power is the only thing we need to control separately, they can still ground to the same negative without any issue.  Below are images of the tab before and after removal.

[ Connecting Earth Line ]

    The earth wire is the green(it may also be green and yellow striped) wire coming off your power cable.  If you just have a normal extension cable cut it and strip each wire coming off of the male end of the extension cord.  The green wire gets connected to the green screw on the outlet.  There will only be one and it will be off on its own.

[ Connecting Neutral ]

    Next, we will be connecting our neutral lines from the outlet to the power cable.  Connect the white wire from your power cord either of the two screws on the neutral side of the outlet matching the image below.

[ Connecting The Positive ]

    To connect out positive line we first need two pieces of wire about two inches long.  One end of each wire will be going inside the small holes on the back of the outlet on the positive side.  On the back of your outlet, you should see a small recess with the word "strip gage" or something along those lines.  This is a guide to show you how much you need to strip off your wire to properly seat it in the holes we will be using to set the wire in the positive outlet connectors.  Check out the image below for an idea of what you are looking for and how to use them.

    Now that we have that end connected we will be stripping a very small amount off the other end of the wire and securing it in the first socket in each relay(first from the left) as shown in the image below.

    Once this is all connected, we need to connect the outlets right next to the one we just used on each relay(the middle outlet on each relay).  We are going to connect a wire with a very small bit stripped off the end to each of these sockets.  Just like before it is important to just strip enough to allow the relay to grab the wire.  You should not have any visible wire coming out of the end without shielding on it to avoid the wires touching.  Saftey first is our goal.  Once we have these connected we need to strip a bit off the other end and connect them together as well as the black wire from our power cord using a wire nut.  The images below will show you what this should look like through the process.

[ Connecting Relay To Base ]

    Now that we have our outlet all wired up it is time to move on and connect our relays to our base unit.  On the back of the relay, you will see four pins sticking out.  From top to bottom in the image below the pins are 5V power(VCC), relay 2 control, relay 1 control and ground(GND).

  Use the diagram here for reference on where to connect these pins. Power down your BeaglBone before connecting your smart outlet.  I also highly suggest labeling the two outlets with the pin they are connected to.  This will be shown in the images below and will help immensely when you are setting up appliances in your client.   The VCC pin on the relay gets connected to any of the VDD_5V pins on the BeagleBone.  This would be either pin P9_5 or P9_6.  The next two pins are the control pins for the relay.  These can be plugged into any of the GPIO pins on the BeagleBone.  Finally, the GND pin gets connected to any of the pins labeled DGND on the BeagleBone.

[ Testing Your Outlets ]

    I have created a small python utility for testing the outlets after you have connected them.  To use this tool all you need to do is boot back up your BeagleBone after connecting all the wires for your smart outlets.  Once you are back in, navigate to your /home/debian/repo directory or wherever your home directory is.  For this next section, n you will need to know the GPIO pins you connected your smart outlet relay to in the step above.  First, clone the repo and then enter the repositories root directory using the command below.

    git clone

    cd hobloom-outlet-tester

    Once you have all the code in place and you are in the root directory for the repo you can start the script using the following command.

    sudo python

    This will open the testing utility that will ask you to enter your pins you have connected your smart outlets too.  Enter a pin and type Y when prompted if you have more pins to enter, if not type in N.  Once you have completed entering the pins the script will turn them all off and then one by one power the outlets on.  The way I use this tool is plugging a small light or fan or something like that into each outlet.  I then run the script and watch the output, it will tell you what pin it is turning on.  When it outputs a pin look at what appliance it turned on and label that outlet for future use.  When you setup your appliances in your grow room you will be asked what pin the appliances are connected to.  When you are asked this it is referring to the pin the smart outlet you have the appliance connected to is using.

[ Wrap Up ]
    As always thank you for reading and don't forget to leave a comment below if you have any questions or suggestions.  If you would like to support open source horticulture software like this please check out the paypal and patreon links at the top of the article!

WARNING: I am not liable for anything you do as a result of reading this.  Do your own research on what is and is not safe and always be careful when messing with high voltage! Read on at your own risk


  1. Replies
    1. Thank you! As with anything electrical proceed with caution and read up on safety tips before hand!

  2. Replies
    1. mine is, wait we're talking about my alter ego 'mom' right?

    2. did i win funniest comment of the year?

    3. I'm not sure let me ask her, er him, er.... head explodes

  3. There's a similar post on on a self-contained unit for controlling relays. Works with arduinos, Labjack DAQ units, raspberry pi, beaglebone, ect.

    1. Thanks for the share this article looks great!

  4. Your relays are rated for 10A, while most US sockets are rated for 15A - the relays will fry before your breaker trips, which could potentially cause a fire - just a heads up.

    1. Thank you! I got a few instances of that feedback and I plan to redo it with a fuse for each socket and some better relays. Thank you so much though! It blows my mind how much more helpful people are who comment here directly :)

  5. Why not use a sonoff wireless relay?

  6. Saw this on Reddit. Someone commented that the relays are only rated for a 3A inductive load (any motor). I haven't verified, but as long as you're literally only running some lights off of these, you should be fine.
    If you're using any sort of pump or fan, consider a more robust relay.
    And always read and understand the documentation that comes with your equipment.

    1. Nothing I use comes even close to drawing 3 amps. My LED lights are by far my heaviest current at about 1.2 amps. People on reddit are freaking out because they are morons lol :) No standard equipments for a home grow is ever going to get even close to the max on these relays

    2. I have done a little research and spoken with some of the old school EE guys I know and I would like to point out the user saying these are only rated for 3amps is WRONG. These relays are rated for 10 amps under normal usage and the data sheet was simply stating that under extreme bad conditions(conditions that will never happen inside my grow room) they are still able to handle up to 3amps. The normal rating for these are 10 amps(a current that it would be very hard to even hit half of with household equipment). Under conditions with more resistance they don't recommend going above 7 but again even these are bad conditions that will never happen in a normal scenario. Be careful who you listen to as every one of my EE friends got a really good laugh scrolling through the reddit comments explaining to me why half the things people were saying are wrong. I will be doing another post where I add some 5 amp fuses on each relay just to be super careful but, be very careful blindly listening to things you hear on reddit comment sections... I noticed years ago that 90% of reddit are users who read one article, dont really understand what they are reading and then they want to comment and talk like they are an expert in the field. Always do your own research and talk to professionals