Page 1 of 1

Relay Issues

Posted: Sat Jun 09, 2018 8:46 pm
by DoTheEyeThing
So I ordered a 24v relay
https://www.amazon.com/gp/product/B0789 ... SLEZQ&th=1

There are jumpers to switch between LOW and HIGH triggers. Currently they are HIGH as LOW turned all of the relays on and I wasn't able to turn them off.

I have 24v + and - from an A/C adapter into the relay, followed by 4 gpio pins from RBpi, and COM on the relay to RBpi ground.

My script sets GPIO's to Output.LOW initially (the relays are off) and then when I set them to HIGH they turn on.

Problem is they're acting weird.
1st relay - LED lit, 1-2 seconds later relay closes.
2nd relay - LED lit and instant close.
3rd relay - LED lit and instant close.
4th relay - LED lit, never closes.

I've seen posts saying external power should go through JD-VCC but this relay doesn't have that available. I feel like I must have this wired wrong but I'm too inexperienced to know. Do I need to wire this up with transistor/resistors?

Image
Image

Code: Select all

#!/usr/bin/python
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)

# init list with pin numbers

pinList = [18, 17, 27, 22]

# loop through pins and set mode and state to 'LOW'

for i in pinList: 
    GPIO.setup(i, GPIO.OUT) 
    GPIO.output(i, GPIO.LOW)

# time to sleep between operations in the main loop

SleepTimeL = 1

# main loop

try:
  
  GPIO.output(18, GPIO.HIGH)
  print("ONE")
  time.sleep(SleepTimeL); 
  GPIO.output(17, GPIO.HIGH)
  print("TWO")
  time.sleep(SleepTimeL);  
  GPIO.output(27, GPIO.HIGH)
  print("THREE")
  time.sleep(SleepTimeL);
  GPIO.output(22, GPIO.HIGH)
  print("FOUR")
  time.sleep(SleepTimeL);
  GPIO.cleanup()
  print("Good bye!")

# End program cleanly with keyboard
except KeyboardInterrupt:
  print("  Quit")

  # Reset GPIO settings
  GPIO.cleanup()

Re: Relay Issues

Posted: Sat Jun 09, 2018 11:13 pm
by DoTheEyeThing
I resposted this on reddit and someone helped identify that I need at least 5v to trigger the relays, so I'm looking into ways of doing that. : )

Re: Relay Issues

Posted: Sat Jun 09, 2018 11:21 pm
by Z80 Refugee
That's not what it says on the advertised product details. If you can find me a circuit diagram for the relay board I will be able to comment further.

Re: Relay Issues

Posted: Sat Jun 09, 2018 11:36 pm
by klricks
Test each relay by connecting the IN of each relay to 3V3 GPIO pin 1.
If not working try each IN to 5V GPIO pin 2.
If that does not work the relay is bad.

Re: Relay Issues

Posted: Sun Jun 10, 2018 10:57 am
by pcmanbob
DoTheEyeThing wrote:
Sat Jun 09, 2018 11:13 pm
I resposted this on reddit and someone helped identify that I need at least 5v to trigger the relays, so I'm looking into ways of doing that. : )
probably easier to switch back to low level trigger and use a 2n2222 transistor and a 470Ω resistor like this

Image

So now when you apply a high signal to the transistor base you will trigger the relay by connecting a ground to the CH / IN pin.

Re: Relay Issues

Posted: Wed Jun 13, 2018 12:27 pm
by tlfong01
Z80 Refugee wrote:
Sat Jun 09, 2018 11:21 pm
That's not what it says on the advertised product details. If you can find me a circuit diagram for the relay board I will be able to comment further.
I also have a module with High/Low trigger selectable. I made guesses and drafted a schematic. I have proofread 90% of it. You might like to use it for reference. I think Rpi works only when High trigger is selected. Arduino should work in both High or Low trigger select.
02ndrgC[1].jpg
relay high low select
02ndrgC[1].jpg (131.89 KiB) Viewed 1041 times