Jump to content

Orange pi PC plus - Relay module


harmbab

Recommended Posts

I am trying to control a relay board on OPI PC plus - armbian. I have used "orangepi_PC_gpio_pyH3" module in python before to control leds, buttons and an 16x2 LCD. 

This is the relay.

 

To control the Relay module i connected VCC to 5V, GND to ground and IN to PIN 35 (Which is PA10 on my board). and used the code below to open or close the relay just to test but no luck.

 

The code does not return any errors, it runs and finishes but no activity on relay. Both leds (Red and Green) on relay are on when connected.

 

 

from pyA20.gpio import gpio

from pyA20.gpio import port
from time import sleep
relay = port.PA10
gpio.init()
gpio.setcfg(relay, gpio.OUTPUT)
gpio.output(relay, gpio.HIGH)
sleep(1)
gpio.output(relay, gpio.LOW)

 

Any help would be appriciated.

Link to comment
Share on other sites

So, if the LED is flashing/working, then you need to figure out if the relay board is Ok.

Did you tried the board alone by grounding the IN pin ?

if it work, do you have a multimeter to measure how much current it takes ?

if more than 10mA, maybe your need to add a MOSFET between GPIO and the IN pin.

Link to comment
Share on other sites

Grounding the IN results same as the connecting the pin. There is a click sound and green led lights up.

 

No i don't have a multi meter.

 

I connected a led to relay module. When i plug out the IN led lights up. When i connect the IN it lights out. But the code still doesn't do anything. 

Link to comment
Share on other sites

Both leds on the relay are always on when all three pins connected.

 

i got the led without relay board to flash as intended for 1 sec on and 1 sec off.

 

Just for science i tried 3.3V for VCC. The script flashed green led on relay on and off and there is even a silent click but it still doesn't do its job.

Link to comment
Share on other sites

I would rather try with a MOSFET, 2N7000 for example, because when IN pin is HIGH at 3V it maybe still enough to keep the opto-coupler conducting.

If you don't have a MOSFET in stock, you can use a NPN transistor (2N3904 or 2N2222 for example) with resistor on its base.

 

EDIT : Oh ! googling for schematics, I found some boards that has the IN reversed compared to other boards, like this one http://www.elecfreaks.com/store/images/product_images/Breakout/Relay/BK_SRD_03.jpg

(this one is reverse compre to previous : https://forums.unrealengine.com/attachment.php?attachmentid=119903&d=1480742998)

When I've asked you to try IN pin to ground, was it really to GND that works ? because the link I've post here is the reverse, it is required 5V on the IN pin.

Link to comment
Share on other sites

I'll y the mofset and the transistor but while waiting for shipping i discovered that the relay i use is triggered  with 0V. (Called active low type i guess). But even set to LOW, gpio pins or even ground can trigger the relay and stay triggered (circuit open).

 

So again just for science i tried to add resistors between gpio pin and IN from the relay. And it kindof worked. I have managed to close and open the relay with the script. But i think my resistors was not enough i guess it was not stable. scipt makes 5 tries to open and close the relay it actually works once or twice. Ill try with higher resistors when i get them.

 

But i dont know if there is any better way to solve this problem.

Link to comment
Share on other sites

The schematic I've provided should be used when you design your own relay board.

In your case, with an already made board, you can see that there is already a transistor or mosfet on the board.

The question is to figured out what is the IN pin require, without seeing the schematic.

Here is where google becomes handy :

Smart-Electronics-5V-1-One-Channel-Relay

So, since it said that IN is low-level trigger, my previous schematic could be applied, the mosfet could drive the IN pin directly ...

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines