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?
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.