Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Orange pi PC plus - Relay module

Featured Replies

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.

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.

  • Author

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. 

  • Author

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.

  • Author

Actually no there is only one VCC.

 

1-way-5v-relay-module-tekli-5v-role-kart

And this is the schematic from the website i bought the relay.

 

dancinglights_step2%5B1%5D.png

  • Author

The picture i send is from the sellers website and they used the wrong picture i guess. below is the actual board i use.

 

 

vXNXyO.jpg

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.

  • Author

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.

  • Author

Thank you martinayotte, ill try your circuit. And a 10k resistor between IN and gpio PIN indeed solved the problem.  The relay works fine now.

This is my module

 

wholesale-1-channel-5v-12v-relay-module-

On 10/1/2017 at 3:31 PM, martinayotte said:

Mosfet_switch.png

 

@Martinayotte i have the same relais but i have only one wire to pilot them, how can i attach the "load"? 

 

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

Thanks @martinayotte, i give it a look in these days, my last attempt seems that the relais was always on, also with low signal.

 

Thank you so much

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.