1

I have received a 16 channel relay module and I'm trying to drive it through my Raspberry Pi.

I have connected a 12V power supply to the DC+/- of the board as well as the 2x +5V and 2x GND on the pins, and lastly some GPIO pins to control 8 of the 16 relays.

When I boot the Raspberry Pi and set the mode of the pins to OUT the relays are triggered and close the circuit automatically (they are set to NO connection)

  • gpio mode 2 out (this closes the circut)
  • gpio mode 2 in (this reopens the circuit)

My problem is that, further to that, the module does not respond to my write 0/1 commands: gpio write 2 1 and gpio write 2 0 do not work.

Do i have something fundamentally wrong in my wiring perhaps?

A picture of the module

Regarding what I've tried: I've connected the 12V, the 5V and GND twice each and the GPIO pins. The relays do get triggered instantly when they are set to out but then dont respont to write 0/1.

I would use the following:

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)
GPIO.setup(27, GPIO.OUT)

At this point I would normally turn the relay off and on by sending GPIO.output(27, GPIO.HIGH) and GPIO.LOW, right? This does not work. Instead the relay interacts if I let the GPIO float by switching between setup(27, GPIO.OUT) and GPIO.IN (or GPIO.cleanup()).

WiringPi uses gpio write 27 0 and gpio write 27 1 instead of the output high/low.

  • Unless you provide more detail about the module and what you have tried no one can help. – Milliways Apr 3 '17 at 12:49
  • 3
    You should edit additional information into your question, not as a comment. You need to find the spec for the relay board. Does it say it can be driven by a 3.3V GPIO? – joan Apr 3 '17 at 13:55
  • 2
    Given that there are no 3.3V connections on the relay board my instinct would be the same as joan's - you may well need to convert the logic signals coming from the Pi (all at 3.3V) to 5V before the relay board will recognise them and work properly. – goobering Apr 3 '17 at 14:06
  • If your hear the relays trigger I guess either your cabling or logic is at fault. The 16 4pin chips seem to be opto couplers like PC817 (which work with 50% of Vce=2,5V) and the 2 18pin chips are something like ULN2803 line drivers. – LotPings Apr 3 '17 at 16:05
  • 1
    Thank you for the answers guys (and @goobering for the edits). It seems like the answer was that it needed to be driven by 3.3v instead of 5v, although it clearly indicates 5v on the board. (there was no documentation with it) – krasatos Apr 4 '17 at 10:27
2

Switched from 5v to 3.3v connection pin from the rPi and it worked fine.
As per @joan's and @goobering's recommendations it seems like 5v (although clearly indicated on the board) was too much as the module was already powered by 12v adapter.
Unfortunately it was an ebay purchase so there was no documentation along with the board.

BTW, just for the reference, i only had to use 1 3.3v pin and 1 GND pin for the thing to work (there are two of each on the relay board).

Thanks.

  • Works for me also! Also just using 1 3.3V and 1 GND PIN is enough! – frankhommers Sep 2 '18 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.