I'm trying to control this relay with my rpi2 b+. The problem is, when I do GPIO.setup(myPinNum, GPIO.OUT) this activates the relay. When I then do GPIO.output(myPinNum, True) or GPIO.output(myPinNum, False), this doesn't affect the relay. The relay can be deactivated only by setting the pin back to the input mode. I checked the voltage on the pin, in input mode it is 0, in output mode LOW it is 0.05 and in output mode high it is 3.3. It seems that even those small 0.05v voltage is sufficient to activate the relay. Then I made a voltage divider with 1kO and 10kO resistors, but even with the divider the output LOW still activates the relay. The questions are:

  1. How to solve this problem?
  2. Is this normal that a pin in output LOW has a voltage of 0.05 ?

P.S. Just noticed that one of the pins has 0.03 volts even in input mode and the relay is always activated when connected to this pin. This makes impossible to control the relay with this pin at all, even by setting the mode to input.

  • The relay board in question has transistor drivers, it really should be off for <~ 0.6V if everything is connected correctly. Do all the relays show the same behaviour? Are you absolutely sure you've connected it correctly (5V to VCC, the leftmost pin in the picture; 0V to GND, the rightmost pin; and your drive signal to one in between). What does the appropriate red LED on the board do?
    – Chris H
    Commented Sep 2, 2016 at 13:03

1 Answer 1


I think you have misinterpreted a few things. First, keep in mind the product page notes "low level suction close, high level release". This means the contacts are closed and the circuit will be engaged when the input level is low.

Next, digital logic deals with thresholds. 0.05V is certainly low if the logic level is 3.3 or 5 volts. It does not need to be 0.00000000 V. So there is nothing wrong there. The input signal is low so the circuit is connected. Your problem is you can't drive the signal high to deactivate it.

3.3V is not necessarily high if the logic level is 5V, which is also explicitly what that relay set uses, meaning, you likely can't use it hooked up directly to the pi. You need a level shifter or darlington transistor array (I think the latter is better for relays as they may sink more current than the former will pass but I am not sure; darlington arrays are also cheaper, look for ULN2803 or similar ICs).

If the relay is only disengaged by a high signal, then you are always pulling it low when the GPIO is set as an output, so it is always engaged. Since the relay is unquestionably 5V controlled, you could test this premise by using a small resistor (< 1/2 KOhm) to connect a 5V pin from the pi to an input on the relay (probably the resistor is unnecessary, I'm just paranoid).

When you set the pin as an input, it is actually in a high impedance state and if the relay's input is pulled high by default, then it will disengage, exactly as if nothing were attached. This is different than sending it a low voltage signal.

  • Okay, I just performed some testing.. Will try to be as specific as possible. I connected 5v to relay's VCC, ground to relay's GND. The LEDs stay off. Then I connected one relay control pin to rpi 5v - no reaction. Then I connected relay control pin to rpi 3.3v - the corresponding LED is turned on and the relay clicked. The LED is turned off and the relay clicked once again when the control pin was disconnected from 3.3v. Then I connected rpi ground to the control pin, the effect is the same - the LED is turned on with a click. Is this normal behavior?
    – madfatcat
    Commented Sep 2, 2016 at 16:02
  • So you are saying connection to the 3.3V pin does something different than connecting to a GPIO on high, that you have measured as outputting 3.3V?
    – goldilocks
    Commented Sep 2, 2016 at 16:09
  • Never said this. :) Turns out that something is wrong with the relay.
    – madfatcat
    Commented Sep 3, 2016 at 7:38

Your Answer

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

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