Notes: It should be noted that the supply pin (Vcc) voltage needs to be the same as the logic level voltage (IN) pin for this relay to work. For example, you would need to use the 3.3V rail on a Raspberry Pi as its GPIO pins operate at 3.3V.
And realised that I was powering VCC using 5V.
So I tested using VCC at 3.3V from the pi and it does not switch. It quietly half-clicks, but doesn’t switch. So my relay does not seem to work at 3.3V
I can get it working using the 5V line and switching with the 3.3V GPIO line (as wired in the photo above) using this code:
import RPi.GPIO as GPIO
from time import sleep
relayPin=24
GPIO.setmode(GPIO.BCM)
GPIO.setup(relayPin, 0) # Relay clicks and green LED turns on
sleep(2)
GPIO.setup(relayPin, 1) # Relay clicks and green LED turns off
GPIO.cleanup()
Is there any risk in using it this way? Could I damage my pi?
Thanks, John
Can you confirm that the relay you are using is the one from the product page for this thread - the image isn’t quite clear enough to be sure. But if it is this one then it will not operate reliably with 3.3V logic levels, whatever the Vcc supply is. It might work, it might not. The fact that it works with one setting on the GPIO pins (whatever ‘setup’ actually does) and not with the proper setting (‘output’) indicates it is marginal. The flicker of the green LED indicates the same thing.
I would recommend a relay that is specified for 3.3V logic levels. It will likely also be specified for a Vcc of 3.3V also, because the logic signal is referenced to Vcc and Gnd.
Thanks for the quick reply.
Yes, I can confirm it is the one from the product page.
I looked up the source code for the setup function (raspberry-gpio-python / Code / [be8e4d] /source/c_gpio.c), but my C is somewhat rusty, so I am not sure what is going on.
Thanks for the suggestion to get another relay, but I think I might risk it
The pi is an original 1B (and I have another spare if it dies) plus the relay will only be switching 5V at 800mA so worst case it dies and I have to buy a new relay.
I will provide feedback to core as this is not working at 3.3V so they need to at a minimum change the description.
Hi John
A circuit for this device would be handy but as usual not easy to find.
Someone produced one some time ago when all this came up. I don’t remember if it was an official circuit or someone took the trouble to reverse engineer the board.
I think it was established that the logic signal is OK at 3.3V but for reliable operation the RELAY SUPPLY should be 5V. As you just found out. You must have got a relay that does not like the 3.3V.
I looked at the product page and it looks like that 3 pin header is marked Sig, Gnd, 5V. so where does the 3.3V for a relay supply come from. This is only somebody’s sketch on the page. The marketers have very cleverly obscured the screen print on these pins. If that pin is actually MARKED “VCC” then that would create much confusion. It looks to me that somebody has finally realised that 3.3V is out of spec for the actual relay and it needs 5V to be reliable. Then marked up the product page accordingly.
Personally I don’t care. There is not enough info available for me to evaluate whether the device will do my job or not so I personally would not purchase one. It goes to follow then that I am never going to look at one to find out what the screen print says.
Cheers Bob
Hi,
I also tested using the pin 1 3.3V like your picture. The relay switched correctly, so I guess it is the lack of current from the GPIO pin which is causing the issue.
Thanks,
John
I have one of these, buzzed out the circuit. (see pic below)
The DC coil resistance is 68ohms and draws 84mA when activated on VCC = 5V; 50mA on 3V3.
3V3 would not be reliable as the relay action is less positive.
A low on the IN pin will trigger it.
Hi James
Can’t work. Turn the transistor upside down. Emitter to VCC (positive), collector to relay.
Cheers Bob
Not a particularly good design if you are correct (which you are probably are except for transistor orientation) as VCC HAS to be 3.3V if you are using 3.3V logic. That means you can’t use a 5V relay supply in case the relay won’t work with 3.3V.
If you have +5V on the transistor emitter and only 3.3V on the base the transistor would be on all the time. Ir would be better if the transistor was a NPN as a low side switch so the relay could be powered separately.
@Robert93820 Thanks for picking that up Robert.
You are correct, the transistor looked wrong but I didn’t have time to check it fully this morning.
I have now edited the pic and reposted it. Looking at it now makes sense. Any pullup would need to be to VCC or higher to ensure the transistor is normally off.
The relay action is not very good at 3V3 and I would not trust it to be reliable long time. But the action is very solid at 5V. Past experience has shown these type of relays need about 70mA for a good solid switch.
You are right there. I think the make and break time for these relays is 10ms. It is anybody’s guess what it would be at 3.3V. I don’t anybody realises any other repercussions this slower operation will have on other things. Like switching larger currents with the longer arcing time. Anything like this might drastically reduce the life of the device.
I don’t have any of this type relay in the 5V range and if I did they would probably be Omron. I could measure the operate time at the lower voltage if I had one. I think I have a couple of this style (Omron)
at 12V and if I get the time and motivation I might see what the difference is at 66% of nominal. I think that once operated they will hold at the lower voltage but I would not use them to operate at this voltage. I hav a feeling that operate time could extend out past 20 or even 50mS. Whatever it is it would not be good.
To be honest I have had quite a lot to say in the past about operating these relays way outside specification but no one seems to take any notice. Even Core who continually market these things as 3.3V units. Some units which use low side switching or an opto transistor switch can have 3.3V logic and are able to have a 5V relay supply. That is all good. BUT if your schematic is correct that design is CRAP. I think I saw somewhere that these units need to have VCC the same as the logic voltage to work. That appears to be so.
As I am getting a bit fed up talking about this subject I think I will pull the pin on it with one last bit of advice
Use at 3.3V relay supply at your own risk and don’t complain if experiencing problems later.
Cheers Bob
You all have to be careful not to confuse the relay specs with the module specs. I can’t comment on this exact module, but I have some very similar ones, that look different on top (screw terminals instead of pins, smaller LEDs), but have the exact same screen print on the back, and use the exact same relay. While the relay markings say 5V, the specs for the ‘IN’ voltage on my modules say:
Trigger Voltage: 0-1.5V (Low); 3-5V (High)
And the modules I have work fine at a 3.3v trigger. I don’t understand the comment that if you’re using a 3.3V trigger, you should use a 3.3V Vcc? I’d think that the 5V for the relay has to come from somewhere?
So I’d expect these ones from Core to work fine with a 3.3v input too? I’d be using a 5V Vcc though.
Hi dave
If the circuit is as James drew about a year ago (above) the Vcc has to tne the same as the logic level (3V3???) If Vcc is 5V and logic is 3V3 the transistor will not turn off and the relay will stay activated
Copied from the descriptive text. Getting a circuit for some of these products in harder than pulling teeth. For me no circuit means no sale.
Quote
"The relay is active when the control signal is pulled low. If control is left to float or at Vcc voltage, the relay is inactive.
Notes: It should be noted that the supply pin (Vcc) voltage needs to be the same as the logic level voltage (IN) pin for this relay to work. For example, you would need to use the 3.3V rail on a Raspberry Pi as its GPIO pins operate at 3.3V."
End quote.
Cheers Bob
The circuit I buzzed out uses a PNP transistor switch. The transistor was labelled S8550 which is a PNP.
It would be easy for a manufacturer to change the board to use a NPN; then 5V VCC would work with 3.3V IN. It would be switching GND (low side switch) the one I buzzed out was switching VCC (high side switch).
With no circuit it would be trial and error to see what worked.
Sadly this is all too often the case.
With little or zero technical details the consumer is expected to purchase, then reverse engineer (as you did) or try to find out the device will not suit your application. not a good state of affairs.
Yes it would. Only means changing the sense of the driving logic. You could then have 2 models, high side or low side.
I think we decided before that operating 5V relays at 3V3 puts them in the “perhaps it will work” range which to me is a NoNo. I see some devices have 3V relays fitted which is a better idea although that might exclude the use of 5V for these. Haven’t looked into this as I have had no reason to do so.
Cheers Bob
But I still say you should not have to purchase a module to find out if it is suitable. There should be enough info available to make that decision. Start with a schemetic.
Hi Fractal.
Yes, that model does and would be all good as long as the RPi or whatever can supply the relay current. But there are a hell of a lot out there using 5V relays and claiming to be OK at 3V3. These are the ones I query as they are operating well outside the relay spec which has got to put them into the doubtful category. The operating speed would be affected as well but in some cased this might not matter.
Anyway I personally would not use 5V relays @ 3V3 due to the reliability question.
Cheers Bob
I would also mention here regarding the device that is the subject of this thread that the indicator LED only indicated that the relay has BEEN REQUESTED TO OPERATE. It does NOT indicate the relay has actually operated. Could cause some confusion.
I checked the board again.
The 3 terminal surface mount device has the label 2TY which google says is a S8550 PNP transistor.
Data sheet for relay lists the following. I’d like to see a graph of operating voltage, note the max operate voltage is 3.75V well above 3.3V. Probably why the relay click was not as definite as I would like when I used 3.3V VCC. Most likely would not operate eventually.
Regarding power I use the relay on the Raspberry Pico where the 3V3 power can supply 300mA. My recollection is that the relay pulls about 100mA so you would be limited to three relays if using the Pico power supply. The photocoupler is an EF817 which is within the I/O spec.
You are correct. The LED just shows a request to operate although there is a strong reassuring audible click. An LED on the relay contact side would self defeat the purpose of the opto-isolator and would have to be part of the user design.
I agree I don’t understand why using a 5V relay with 3V3 is being considered. Why are we having this conversation?
According to the manufacturer’s data sheet the “pick-up voltage” is 75% of 5V, that is 3.75V which is much higher than 3.3V. You might get lucky and have one work but is it really worth the risk? 581c81ac16e36.pdf (3.6 MB)