# 3.3 V relay switches on/off/on - off fails 2nd switch off connected to Pi4

UPDATE Issue only happens when load is connected, triggers every time without load

This 3.3 V .relay, link to the the >>> Datasheet

As the title mentions, it works fine until I try to switch it off the second time round, then I see the red LED turning on (it looks a touch dim).

Tapping the relay housing(lightly) triggers the relay Stuck relay then!

But why only after the second attempt and never on the first power off ?

EDIT: I looked at the datasheet thinking it needs a bit more voltage, but max is 3.9v!

import RPi.GPIO as GPIO
#from time import sleep
pin =2
# Set up input pin
# set bcm pin mode
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(pin, GPIO.OUT)
#  turn on relay in revese mode so sety pin to low
state = GPIO.input(pin)
if state:
print('on')
GPIO.output(pin, GPIO.LOW)
else:
print('off')
GPIO.output(pin, GPIO.HIGH)


Edit schematic Sorry I have really bad drawing skills!

I have posted this on the raspberry pi.stackexchange but think the question may be better suited here. Thank-you.

• Hi saj, a schematic of the hardware is appreciated for questions like this, even if it is very simple. (you can edit the question to add it) Feb 18 at 18:22
• Hi @PeteW, schematic added as suggested, thanks for looking
– saj
Feb 18 at 18:41
• There are a few problems: (1) You've linked to an AliExpress ad which has no datasheet for the module. (That's typical of them.) (2) You've linked to the datasheet for the relay used on the board which is useful as it contains the specifications including drop-out voltage. (3) Your schematic is only a connection diagram and it doesn't show the components on the board. We may not have enough information to solve the problem as it is likely that a switching transistor on the board is not turning off. Feb 18 at 19:01
• HI @Transistor,thanks for your input sadly I don't know how to get or create a schematic as I have no idea about the circuit
– saj
Feb 19 at 0:02

Your information about your circuit in the blue rectangle is very sparse, but I assume it is just representing the relay (note 1). If that is the case then you should expect problems because the rPi output cannot source more than 50mA according to this source and that would be at reduced voltage even.

The coil is specified at 25 Ohm and typical 3V, so this would require 120mA. Now, why this manifest itself as you describe is not obvious, but first solve the drive problem (see below) and check if that does not solve the problem.

Bottom line - you will need a buffer of some kind between the coil and the GPIO output. A MOSFET or transistor is a very cheap and simple solution for this. There are plenty of design examples for such solution. Example here.

Note 1: If the rectangle you draw is the relay, then I don't understand why you need both Vcc and GND. You should use either one or the other to get active relay when output is low (use Vcc) or get active relay when output is high (use GND).

PS: a hand written drawing can be better than a poor digital drawing. Importance is the information is there - not the looks of it.

• Hi, it is just the relay, I'm just trying to show the connections, thanks for the link I'll give it a go
– saj
Feb 19 at 0:03