# How to wire for AC mains voltage relay, when printer board is connected to AC-charging laptop computer?

I know this will be a really obvious question to some people, but I have bricked about 3 boards doing this so I want to be certain before I brick a fourth. I don't have a lot of experience working with AC voltage, especially crimping / hacking it like what's going on here. Trust me it was my last resort to ask this.

Basically, as a chamber heater I'm using some 120V heat lamps (here in the U.S.). The problem seems to be that when I connect my laptop to the board (if the laptop is plugged in, which it has to be for long-term serial control), sometimes I:

1. Hear an electric shock sound -- the board is fried
2. Don't hear an electric shock sound -- the board is fried, though

What I interpret from this is that I'm stupidly wiring the 120V heat lamps incorrectly relative to my 3D printer board, such that when I connect it to my charging laptop via USB, the AC voltages are out of phase, causing my board to be fried. Alternatively, it's the 12V/24V power supply that's wired wrong relative to everything else, which also needs to be wired to the same polarity.

I was on the understanding that when crimping a three-wire male electrical cord:

1. White = Neutral
2. Black = Hot (or Load)
3. Green = Ground

... reinforced on the left side of the below image as well:

So, I know that much already. The question is, when I connect this AC outlet to a relay like this, I got NO, COM, NC on one side and IN, DC+, DC- on the other. Which wire goes to COM, and which goes to D-? The board uses COM to denote the voltage that is switched 'on' by the relay, and D- to denote whatever the shared ground is among, the 3D printer, heat lamp, printer board, etc... (For more info, see link to relay)

This 5V relay says it supports AC loads being managed by an arduino / 3D printer, so I was under the impression that I could connect the white wire to its D- pin (which also should receive the "GND" for my 3D printer board) and the black wire to its COM pin. However, what do I do about the green wire? Nothing? Also, was it wrong for me to assume it would support this function when the Arduino is connected to a charging laptop via USB?

Basically, I just need to be sure that my laptop (3-prong), power supply (3-prong), heat lamps (2 or 3 prong) and relay (only 2-prong) all have matching polarities and don't cause an electric shock or fry my board. But I am getting really conflicting results and frying a lot of boards, probably by overthinking this.

• Please add a diagram showing how it is all connected up. Also, do the mains outlets which are being used have a ground connection, and are they on the same circuit from the circuit breaker panel? Nov 1 '19 at 15:17
• You mention a 5 V relay but the link shows a 12 V relay - is it just that the link ended up showing the wrong one? Nov 1 '19 at 15:45
• Be aware that those relays may not be labeled correctly, I have a pack of those exact relays from Amazon and the NC and NO are inverted. Use a multimeter to see if COM and NO are connected when nothing is connected. Nov 1 '19 at 18:50
• I linked the 12V relay accidentally - but the 5V relay looks exactly the same visibly Nov 1 '19 at 22:58

In effect, the ground (from mains) does not need to be connected to the relay, the relay interrupts the "hot" or "neutral" (preferably the "hot", but that is not possible for all plugs, e.g. some European plugs can be inserted 180° turned into the sockets). You connect one of the interrupted wires to the COM, the other interrupted wire (that goes to the lamps) to the NO (or the NC, depending on safety, the logic and/or preference). The ground wire from the mains power socket is not necessary at all (some lamp amratures require this to be connected though). See a schematic below, it uses an Arduino Uno, but you can think of it being the printer board. Note to never connect the ground from mains to the printer board directly!

Image based on source: osoyoo.com

The logic (low voltage side of the relay) needs to be wired as follows:

• DC+ is the voltage power supply of the relay module, this is frequently +5 V, but some modules use +3.3 V (sometimes there is a jumper cap to select the voltage)
• DC- is the ground from the printer board
• IN is the trigger that needs to be connected to the port on the printer board that electronically switches the relay
• Nice picture, like it a lot. Nov 1 '19 at 9:13
• That's how you do it electrically. Mechanical execution of it, however, is serious business, and decides whether the setup is safe or dangerous. Nov 1 '19 at 16:05
• Note that OP uses a 12V module Nov 1 '19 at 17:48
• ^ was mistake, meant to link to 5V relay Nov 1 '19 at 22:58

You need to take a step back and think about what you are doing. From what I read there you are connecting the neutral to the low voltage. You should definitely not mix connections between your high and low voltage side. I think you are lucky to not have broken more things than the logic board.

I quickly drafted this to show the idea.

The relay provides isolation so you do not want any connections crossing over that electrically connects the sides. So you keep the 120V mains stuff on one side and the other side you connect to your logic board and printer supply.

The grounds you can join to a common point or printer frame. I would never join L or N from different cables because at least here in Northern Europe our outlets are not keyed and can be rotated 180-degrees swapping L & N which would create a dead short.

Mains electric specialist here. When working in mains power, mechanical execution of work is everything.

The first rule is do not casually mess around with mains power -- it will kill you! If you've done a lot of low-voltage tinkering with jury-rigged wires splayed all over the place -- do not do that with mains wiring. Ever. Break that habit with mains!

The second rule is hard separation. It is absolutely forbidden, for instance, to have low voltage wires intermingled with mains in a jumble, even inside a metal box.

## A "Chinese wall" between mains and low-voltage

By which I don't mean low quality. Generally all wires associated with mains should be inside a grounded metal enclosure, and all low-voltage wires should be outside that enclosure, or separated by a physical divider.

Here is an ideal setup that will pass muster.

• A standard square drawn steel junction box, with knockout holes, \$1 • a #10-32 ground screw for that hole on the bump • A cover plate, \$1, made to take ....
• ... two common receptacles, but get the higher quality screw-and-clamp type - \$2.50 each so we can use stranded wire. I'm assuming you have more than 2 lights. If not, you can wire this thing so half the sockets are always-on.
• a couple feet of #12 stranded THHN wire, each red, black and white (20 cents/foot)
• A relay-transformer that mounts to a knockout hole.

For now just imagine 3 mains wires coming in: black hot, white neutral and green earth. Earth goes to that #10-32 screw hole on the bump, and the metal case grounds everything else.

I pigtail wires on receptacles because it's easier, but it's also clearer for a novice (than using a receptacle as a splice block). On the receptacles, pigtail neutral with white. Hot gets a red pigtail if switched, and black if always-on.

Fit the relay into a knockout hole, mains wires inward.

Now you have a bunch of black, red, and white wires. Join them by color! Easy peasy! This is why I made such a fuss about getting 3 colors of THHN wire.

Button it all up, and the mains work is done.

## Getting power into our box

I glossed over bringing mains supply into this box. Let's review that further.

That junction box is made to mount on a wall. It's a code violation to use it as a portable box (but lots of people do). However you must use cordage (SJOW, SJOOW etc.) not in-wall wiring (NM, THHN, UF). I just buy a 14 AWG extension cord and lop the socket off. Visit the electrical supply house (Greybar, not Mouser) and get a strain relief that'll fit that cord and a knockout hole.

If you want to mount it on the wall over another box, they make special 4" square boxes for that. If the existing box is a similar box, they make "extension boxes" with open backs. They also make ones designed to go over top of a 1-gang box that is metal or plastic.

If you need the existing outlet space on the wall, you can use surface conduit systems like Legrand Wiremold (not to be confused with cable organizers intended for low-voltage cables only). You extend off an existing outlet, leaving that with its original function, then run surface conduit to another box, where you mount these items.

## Make the system talk to it

That was a lot of heavy lifting, but the rest is downhill.

On the above relay, you simply attach 2 wires to W and R. (in fact, common thermostat cable is "W"hite and "R"ed, coincidence: not). If you short those wires to each other, the relay operates and the lights turn on. Use an appropriate relay if needed. There is low voltage AC on these wires (24VAC between them, 34V peak, isolated from earth and mains) which means you can route these wires without mains-level protection.

They make other relay-transformers, but I really like how this one puts the low-voltage on opposite sides of the knockout from the mains. They also make cheaper relays that accept 24VDC or even 12VDC, but then you have to supply that.

• Note that most 3D printers are connected to Mains wire using C13 connectors into a fused C14 plug, which then connects to the inlet of the Power supply. Nov 1 '19 at 16:59
• I would plug this into a separate mains socket @Trish . If an unswitched socket is needed to plug in the 3-D printer, I would add it (as discussed). It could be done more elegantly with C13/14 connectors, but I am avoiding this to stay within equipment readily available at any hardware store or electrical supply. Good point that it either needs to be fused or large enough wire to be protected by the distribution panel's circuit breaker. Nov 1 '19 at 17:41

Let's look at the notes on the relay first, as these tell us what to connect the terminals to.

## Powered side

• NO/NC - Normally Open/Normally Closed lead. Which you use determines the switching behavior: open line on signal (NC) or closed line on signal (NO). Connect this to the powered component.
• For heater components it is best to use NO, as a failure of a signal automatically stops heating, making this a safety means! If any of the supply wires are ripped or pulled from the terminals or the board is fried, the power of the heater doesn't come through.
• COM - Common. This is the other lead of the switch part of the component, the line that transports the power to the switch. Connect this to the power supply.

## Low Voltage signal side

• IN - Input. Here the switch signal goes in
• This is a 5 V Signal
• DC+/DC- - This is the power supply for the switch and should be the same as the power supply for the Board. Check your Rating!
• Red "High" on DC+
• Black "Low" on DC-

Note I used European colors to differentiate the 5 V side from the mains-power side better. You have your Neutral in white, Phase in black, Ground in green on your Power Supply picture. This color conversion can be handy.

If the heater lamp has a connection for the ground wire, use it! This should be the same ground wire the power supply is connected to, to ensure safety.