Controlling 8 channel 12V relay with Pi

Hi Folks,
I am trying to control an 8 channel 12V relay with a Pi. Below is a picture of the board.
If I plug the VCC and GND into the Pi with the IN1 and 2 to respective GPIO pins, then when my python code tells it to turn on, the little led on the board to show it is on turns on and then off when required. (so far so good, code works)

When I put a multimeter to the terminals though, the power doesn’t change. There is power going into the relay but the NO doesn’t get power, the NC doesn’t lose power (not sure if it is supposed to)

Following some research, I wondered if I should supply additional power from the power supply to the COM and GND pins that are currently jumpered. That had the effect of led’s no longer coming on.

If anyone can shed some light on what I am doing wrong, it would be amazingly appreciated.


The relay will not have power at the terminals. It simply opens or closes the switch. So you can provide any sort of power at COM and that will be routed to the NC connector when the relay is not triggered, and to the NO connector when the relay is triggered. You have it currently set to switch to ground. So if you connected one terminal of a device such as a lamp to the NO connector and connected the other terminal of the lamp to the battery positive, the lamp would light when the relay is closed. Or, you could put the relay in the positive supply to the lamp by connecting the positive battery to the COM. The relay is just a switch and doesn’t care what supply you are using at the terminals or what the polarity is.


I think I suddenly understand how I am so confused.
I have power from a power pack going into the middle terminal for the relay and the same power going to the COM. Shouldn’t that mean that when I trigger the relay, the NO connecter should have power?

But digesting what you are saying, does that mean that I don’t need to have the power connected to the middle terminal on the relay?


Hey Karen,
Welcome Back!

Looks like you have the right ideas regarding how to hook this one up. One thing that may be helpful for you is our Getting Started with Relays Guide as it covers the INs and outs of Relays and how to interact with them.


1 Like

This is the way to wire it up and to check it. This is switching GND.
As @Jeff105671 said you could swap the 12V and GND so it is switching 12V.
It doesn’t have to be 12V, it could be any other voltage up to the rating of the relay (30VDC).
Note: The circuit drawing does not match the physical layout of the relay.
Relay terminals. NC COM NO.


I see the problem.

When I used the label COM I meant the middle terminal of the three relay terminals. This would usually (but not necessarily) be the positive from the power supply for the device to be switched.

I see that the PCB uses Com for the common power input for the module. This might, or might not, be the positive supply from the same supply. It could be the positive from a separate power supply.

So you would connect the module common to the relay common if you are using one power supply to power the module as well as the device being switched. If you are using separate power supplies you would wire each power supply separatly to the module common and the relay common.

EDIT: Still haven’t got that right!!!

The COM is a jumper to Gnd, NOT the positive for the module. I THINK it means that the GND for the module supply can be directly connected to the relay COM. In that case, remove it.

Wire the module power to VCC and GND. I don’t know whether or not this can be 12v, or is limited to 5V.

Wire the device to be switched to relay NO and relay COM (+ve).

If the module power can be 12V then the above two connections can be from a single 12V power supply. If the module power must be 5V then you will need two supplies.


Hi Karen and All.
Just been looking for a circuit of this device without any luck.
However there is some sort of a data sheet on the Jaycar site which states

“Please note that VCC must be connected to a 12v power supply to operate”

This would be correct as it has 12V relays fitted. If you have had 5V connected to VCC could be why the relays do not seem to operate. Because they are not operating, not enough volts.

If you connect 12V to VCC and ground and make sure that the controller (Arduino, RPi etc) ground is connected to the same place the device should work. Don’t know what that link does, might have something to do with the Opto coupler. Will have to try and find a circuit or maybe someone could post one.

As for the relay contacts. There are little diagrams printed on the board picturing what the contacts do. You can connect anything you like to these within the relay operating limits. That is contact limits, nothing to do with the coil operation.

Cheers Bob


Hi Karen

This is the first thing you are doing wrong

Connecting power and ground to points when you don’t know what they are is usually a recipe for disaster. Sometimes results in the magic smoke and expensive smell.

Depending on circumstances you could have put reverse voltage on the opto couplers. These contain LEDs which don’t take kindly to reverse voltage of any great magnitude. Could be OK or could be destroyed or suspect which in a way is worse. The device came with the link fitted so without the luxury of a module in front of me or a circuit I would guess is for an operation which is not “normal” and should be left in place.
Cheers Bob


Hi Bob,
So connect the ground to both the Pi and the power supply? Would that explain why the voltage coming from the Pi for the signal pins is pretty low?

Things you do to control a train set :laughing:

1 Like


Thank you so much fantastic people!!!


Hi Karen


It will only be 3.3V which while it might seem low is normal.
You previously say

That indicates to me you are only applying 3.3V or 5V to VCC. VCC needs 12V with enough current to drive the relay coils and should be a separate supply.It has nothing to do with the RPi supply and because of Opto coupling it does not have to. It is completely separate and except for the ground connection it must be kept that way.

If you made the connection as described above about that jumper it is quite possible you have damaged the Opto couplers. That can be checked.

Connect 12V to VCC and ground.
Momentarily connect 3.3V or 5V between ground and each signal input and check for relay and indicator LED operation. The corresponding relay should work for each signal input.

The little diagrams printed alongside each terminal block should be self explanatory for each set of relay contacts.
Cheers Bob



Yep changed the VCC to 12V. So…
VCC 12V from power supply
GND connected to GND from power supply + GND from Pi
IN pins connected to GPIO from Pi

On the other side…
GND to one side of the track switcher thing (pretty sure its a solenoid)
+ve to middle terminal on relay
+ve from NO to other side of track switcher.

I would take a photo but nothing looks pretty at the moment.

Problems solved:
Needed to read the info on the relay better (to find out about the 12V to VCC)
Need to remember that any time there is a link for signals, there needs to be a ground to accompany it.


Before I plugged the ground in, it was only getting to about 1.5 V :slight_smile:

1 Like

Hi Karen

Too low. The signals MUST get a ground return to complete a circuit. And anything else for that matter. A circuit but be complete for anything to work.
You seemed to have learned a lot from this exercise. That is a good outcome.
Cheers Bob


The image you sent shows a Duinotech 8-Channel Relay Module. It is a 12V relay module, so you need to provide a 12V power supply to the VCC and GND pins. The IN1 and IN2 pins are the signal pins that you can connect to your Raspberry Pi GPIO pins.

When you turn on a relay, the COM terminal is connected to the NO terminal. When you turn off a relay, the COM terminal is connected to the NC terminal.

To control the relay from your Python code, you need to set the corresponding GPIO pin to HIGH to turn on the relay, and set the GPIO pin to LOW to turn off the relay.

Here is a simple Python code to control the relay:

import RPi.GPIO as GPIO

# Set the GPIO mode to BCM

# Set the GPIO pin for the relay

# Set the GPIO pin to output

# Turn on the relay

# Wait for 1 second

# Turn off the relay

If you are using a multimeter to measure the voltage at the terminals, you need to set the multimeter to AC voltage mode if you are connecting a load to the relay, such as a motor or light bulb.

Here are some troubleshooting tips:

  • Make sure that you are using the correct GPIO pins for the relay.
  • Make sure that you are providing enough power to the relay module.
  • Make sure that the relay is properly connected to the load.
  • Try using a different relay module.

If you are still having problems, please provide more information about your setup, such as the code you are using and the wiring diagram.

Here are some answers to your questions:

  • The NC terminal is not supposed to lose power when you turn on the relay.
  • You do not need to supply additional power to the COM and GND pins. The jumper between the COM and GND pins is to provide a common ground for all of the relays.
  • The LEDs on the relay board indicate the status of the relay coils. They do not indicate whether or not the load is powered.

I hope this helps!


Hi John
I think you are confusing the issue a bit here.
The first bit is correct. When Karen supplied 12V at VCC for the relay coils and connected the RPi ground at this point the whole thing worked as expected.


Why?? The relay will switch AC or DC so if you are switching DC you would use DC mode. The load does not have to be AC as is sort of implied. You may be getting confused with zero crossing solid state relays which will NOT switch DC. These are the old fashioned type with actual contacts. The only difference is the AC and DC different current and voltage capabilities but this is a function of contact arcing and documented in data sheets.

Of course it will. That is the whole point of a relay. It transfers voltage or load connection from the NC point to the NO point when operated. So any voltage or load will disappear from NC and appear on NO.

This should read from “do not need” to “do not do” as I explained in an earlier reply.

I think you will find that jumper connects the Opto coupler “common” to VCC (relay supply) Ground. If TOTAL isolation is required for some reason this “common” can be isolated by removing the link and the RPi ground connected here (to “common”) to provide the signal return path. I have not been able to locate a circuit so cannot be absolutely sure here but I would just about put money on it.

The last answer is correct. These LEDs would only indicate that relay activation has been requested. They do not guarantee that said activation has happened. Just really indicate that the Opto has worked.
Cheers Bob


I bought one of these a long time ago, never really found a use for it.
Jumper GND is the same as the GND near VCC.
Jumper COM connects to the opto coupler GND.

The contacts of the relay are totally isolated from any of the header pins. (as they should be)
Labelling the header pin COM leads to confusion.
12V to drive the relay coils and signal level of 5V is asking for trouble if the supplies get mixed.
The relay boards Core Electronics supplies use 5V relays a much better option.
Pololu make 12V & 5V versions of the same relay board.



Hi Jim

Thanks. Good someone could confirm my theory. I was pretty sure I was correct.

Only if you are VERY careless.
With this module and indeed any module which has an active high signal the VCC of the controlling device has no reason to be connected to the module, just the signal lines and ground signal return. It is only when you have a LOW signal active that the VCC of the controlling device has to be connected to the relay module. In such a case the input would pretty well have to be Opto coupled to allow this (except maybe high side relay switching) whereas HIGH active switching would work with Opto coupling or directly driving Transistor/Mosfet devices.

For most of them they also state they will work at 3.3V. I have had a few things to say about this in the past such as 3.3V being outside the actual relay specs. Subtract the voltage drop across the driving device (Transistor/Mosfet) from this 3.3V and the situation becomes worse.
Also the available information is a bit thin. No schematics at least on the Core branded ones and only one of these stipulates LOW signal pin active. The presence of a high side link to connect driving device VCC and relay supply suggests to me that all of this type are LOW active. BUT, I have had many years experience and this may not be so obvious to a newcomer and could lead to many frustrated hours wondering why nothing works. I think this could be looked at.
Cheers Bob


This the circuit of the relay driver after ‘buzzing’ it out.
Pretty sure the drive transistor is a mosfet, it does not resistance check like a transistor would.
Anyway, mosfet is the best choice to drive the relay.

Would be nice if Jaycar included this in their datasheet.


1 Like

Hi Jim
Yes this makes sense BUT you have the “COM” and “NC” on the relay reversed unless there is something very wrong with the screen print on the board.

I have always wondered about that indicator LED. It doesn’t tell you that the relay has actually operated. As Karen found out it gave a false impression of relay operation when she only had 5V at VCC instead of 12V. She thought the relay had operated as the LED said so.

Would be nice if everybody did that
Cheers Bob

1 Like