5

my current setup

I've got a single relay connected to my RPi but I can't seem to control it.

As you can see from the image above:
RPi -> Relay
5V -> VCC
Ground -> GND
GPIO4 -> IN1

Measuring voltage I can successfully verify that I can turn on/high off/low the GPIO pin (3.3V to 0V).

The problem is changing that state doesn't change the relay state. As soon as I set the pin's mode to OUT the relay lets the current go through.

Changing the pin's state through the Python API or through the console doesn't do anything, the current is always passing through. (Can turn it off by setting the pin's direction to IN..)

Also the wires connected to the relay are using NO (normally open) and COM.

Somewhere on the relay's product page it states: "Control signal TTL 3,5V-12V". Would this mean that the GPIOs output of 3.3V isn't enough to control the relay?

7
  • Could you post a link to the relay driver board you are using?
    – joan
    Sep 21, 2014 at 19:10
  • Found the item page in English here. Datasheet is in English but I think it's only about the relay, not the board itself link Sep 21, 2014 at 21:23
  • Try applying 5V directly to the relay IN1 (with the gpio wire disconnected!). Perhaps it is active low and 3.3V simply isn't enough to operate the relay.
    – joan
    Sep 21, 2014 at 22:24
  • I tried something similar like using one of the other Power pins on the Pi, pluging it in and out but it didn't work as far as I remember. This just looks harder than it should be honestly :D Sep 21, 2014 at 22:36
  • 1
    No, but it would strongly suggest that it needs more than 3.3V to operate. You could still use it from the Pi but would need to add a transistor or a chip such as ULN2003A as part of the solution.
    – joan
    Sep 21, 2014 at 23:00

2 Answers 2

1

I also came across this.

The best solution to this is that you

  • connect the gpio pin to the flyback resistor then to the Base of the transistor.
  • Ground the emitter.
  • Connect the 5v to the relay terminal and the other to the collector of the transistor.
  • Add a freewheeling diode at the terminals of the relay Yo prevent the back flow of the current.

This should solve the problem.

0

I have same relay. So I control it this easy:

from gpiozero import DigitalOutputDevice

relay = DigitalOutputDevice(17) # Initialize GPIO 17
relay.on() # This will turn relay on
relay.off() # This will not work :( but
relay.close() # This will turn relay off

My wiring is:

+5V -> vcc

GROUND -> gnd

GPIO17 -> in1

Relay will connect NO with COM when activated.

2
  • Could you include some more information on your setup? Pictures of how the relay is connected to the Pi, e.t.c...
    – Darth Vader
    Sep 1, 2016 at 12:39
  • why is relay.off() not working?
    – muilpp
    Nov 13, 2018 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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