Mains Voltage Relay Test Jig




Introduction: Mains Voltage Relay Test Jig

For some reason I always end up needing a reason to switch a mains powered device with a microcontroller so I decided to finally make a test jig with some spare parts I have lying around. Hopefully this will be much safer than having exposed mains wire floating around everywhere. :)

Before attempting this project you:

  • MUST be comfortable working with mains voltage
  • Have access to a 3D printer (or be able to fabricate the box somehow)

Step 1: Bill of Materials

This example I used in this project is using an ESP8266-01 to control the relay. Case is made for a 5x7cm prototyping board, so you can adjust as necessary.

  • 1 x IEC320 C14 Panel Mount Plug
  • 1 x NEMA-5-1 Snap Mount Receptacle (Panel Cutout: 1" x 1.1")
  • 1 x Panel Mount Fuse Holder
  • 1 x 5A, 6 x 30mm Glass Fuse
  • 1 x On/Off/On 20A/125VAC Snap Mount SPDT Switch (Panel Cutout: 25.5mm x 10.2mm)
  • 1 x 5 Position Terminal Block
  • 1 x 5V Relay Board*
  • 1 x USB Charger (AC to DC 5V Switch Mode Power Supply)*
  • 1 x 5V to 3.3V Regulator Module*
  • 1 x ESP-01 ESP8266
  • 1 x Male & Female Pin Headers
  • 1 x IEC320 C13 to NEMA5-15P AC Power Cord
  • M3 Nylon Nuts, Screws, Standoffs
  • Mains Rated Wire

*These are what I used in this project since this is what I had lying around. If you have a AC to DC 3.3V Switch Mode Power Supply and a 3.3V Relay Board you won't need the 5V to 3.3V Regulator Module.


  • Soldering Iron
  • Screwdriver
  • 3D Printer
  • Wire strippers

Step 2: Printing the Case and Mounting Parts

You can get the 3D models for this project from Thingiverse:

Once you have completed printing you can go ahead and mount the panel mount plug and secure it with the M3 nuts and bolts. The receptacle, switch, and terminal block are snap fitted to the case and the fuse is tightened with the nut that comes with it.

Step 3: Schematic and Wiring Up

Circuit is pretty simple. Mains voltage comes in from the C14 Panel Mount Plug, to a fuse, and splits to the SPDT switch (High Voltage) and switch mode power supply (Low Voltage).

High Voltage

The SPDT switch can either be set to go to the Common on the Relay, Off completely, or directly to the NEMA-5-1 Female Receptacle which bypasses the relay. The Relay in my setup is wired up as normally open so that if the switch is set to the it, the microcontroller will have to trigger the relay in order to power the female receptacle.

Low Voltage

The switch mode power supply steps down the voltage to +5VDC which powers the relay coil, and is further stepped down to +3.3V via linear regulator to power the ESP8266. The digital pin on the ESP8266 is then connected to the trigger pin on the relay module.

Wiring Up

I used a terminal block to make the mains voltage wiring a little easier and more flexible in case I wanted to change the setup. The case accepts a 5x7cm prototyping board and is mounted using M3 standoffs. Depending on the size of the switch mode power supply you may need to make some adjustments on how you lay it out on the board. I used headers on the board so that the parts are not permanently fixed in case I need to change anything. Reference main picture for wiring setup.

Step 4: Power It Up!

I'm not going to cover how to trigger the relay with a microcontroller I'll put some links in the reference section for that. But if everything goes well after plugging in the AC power cord to the the male plug you are done! You now have your own test jig.

Step 5: References

Be the First to Share


    • Pocket-Sized Speed Challenge

      Pocket-Sized Speed Challenge
    • Audio Challenge 2020

      Audio Challenge 2020
    • Maps Challenge

      Maps Challenge

    2 Discussions


    4 years ago

    This looks cool. I like that your version of this microcontroller relay has proper Guage wiring and very clean to boot. Many diy Web based or microcontroller relay outlets look untidy. Some even a little unsafe. Great job here.

    One suggestion...This could easily be made without 3d printing. A simple plywood box would be easily made and accessible to most everyone. A hand saw to cut the wood and a drill and file to make the cutouts for the plugs and switch. (or table saw and Dremmal tool) The whole thing could be made of wood for a couple dollars and pending on experience .5 to 2 hours work.


    Reply 4 years ago

    Thanks for the feedback! I edited the instructable with a little better clarification on the intro page so people don't get discouraged when they see the requirements.

    I was definitely one of those people before. A close call for me was more than enough to realize I needed to make a proper jig. Hopefully others do the same because there's a lot of DIY IoT devices for sale that mess with the mains voltage and seeing their subpar designs worries me a bit.