The information on this page involves working with high voltage AC electrical power. Only perform the operations if you are comfortable working with standard high voltage AC power. If you are not comfortable, then don't do this!
Working with high voltage AC power can cause risk of electrical shock, which could result in injury or death. There is also the risk of fire, which could also result in injury or death, along with property loss. Do this at your own risk!
For this project, I used a standard metal electrical junction box, and I attached the ground wires to the box with the ground screw. However, if this were to be plugged into an electrical outlet that was not properly wired, it could very well cause electrical shock. Use your judgment on whether or not to attach the ground wire to the box. You could alternatively use a plastic box enclosure, but you should use one rated for the purpose to avoid risk of fire.
I am in no way responsible for anything that happens to you or your property if you do any of the things you see on this page. You are responsible to follow all possible safety precautions to prevent property loss, injury, death, or any other possible undesired outcome.
This section shows how to connect a 2 relay board to control an electrical power outlet. The primary reason for this is to be able to power cycle external USB drives that are in an enclosure that requires en external power adapter. It is recommended to only do this if there is no other option to power cycle the drive. Note that when power cycling an external power supply this way, the capacitors in the power supply can keep providing power to the device for a short time after being disconnected from the input power. You may need to increase the relay activation time to account for this.
For this I went to my local small town hardware store and got the following items.
1 Electrical junction box 4x4x2 inches, along with a blank cover.
3 Twin screw cable clamp connectors.
1 Extension cord, 16 gauge, three wire with ground, probably around 10 feet in length.
1 Roll of electrical tape.
I also had the following other items that did not come from the hardware store.
1 USB-A male to USB-B male cable from an old printer.
4 Plastic standoffs, which are described in the Relay Box section.
The following pictures should tell the rest of the operation. I grounded the box to the ground wires, but that is up to you (see the IMPORTANT! message above). I used both relays to control power of both the hot and neutral wire to make sure all power was removed when the relays were activated. A 16 gauge extension cord is ideal as the wires are a good size to fit the relay connections. I used the standoffs because I had them, and I wanted to keep the relay board from touching any of the metal box. You could alternatively wrap the relay board in electrical tape to prevent it from touching, but you would want to make sure it was wrapped good. The cable clamps should securely hold the extension cord so that it cannot be pulled out of the clamps, as if the cord can be pulled out it would be a safety issue. For the USB cable I had to wrap electrical tape around it so the clamp would hold it secure.
If you do this, please do it as safely as possible.