United Kingdom
Asked — Edited
Resolved Resolved by rb550f!

5V Relay Not Responding As It Should

So I've just been trying out a 5v relay (with 5v regulator) on port D0 but it's not working as expected. I first tried "Set(D0,on)" and it closed the relay switch. I then tried "Set(D0,off)" and it wouldn't open. I disconnect it from the EZ-B and it opens, plug it back in and it closes again but can't control it from then onwards. I even tried a combined script...


but no change. I'm I missing something here or is there something else I can try?


User-inserted image


Upgrade to ARC Pro

Unleash your robot's full potential with the cutting-edge features and intuitive programming offered by Synthiam ARC Pro.


Just guessing, but maybe put a resistor on the signal pin?

United Kingdom

Thanks for replying @Doombot. I just tried it with a 10K Ohm resistor (that's all I have to try it with) in line with the signal wire, but unfortunately no difference.


Soooo, if I understand, you are powering the relay (gnd and vcc) with 5 volts regulated from an external source other than the EZb, is that right?

Then you have the signal line (1nc) going to the D0 signal port on the EZb, is that right?

If the above is true, the solution is simple, you are missing a ground connection between the relay and the EZb.


@Justin He said he had a 5V regulator coming from the ezb...maybe the regulator just doesnt have enough amps to power the coil...Then the solution maybe is to have an external source of power that has enough juice...of course with the grounds all shorted together.

United Kingdom

Steve G, is there a driver transistor on the relay PCB?


I use one of these TTL level converter for that relay board..Logic level from EZB is 3.3 v and you need to be 5 v...3.3V-5V 2 Channel Logic Level Converter TTL Bi-Directional Shifter Module.Available on Ebay .

User-inserted image

United Kingdom

The relay is being powered from the EZ-B through the regulator. I have tried serval ports but to no avail. The regulator I'm using is a 5v, 3 amp output unit. The relay itself is stated as being able to be used with an ARM processor (and a range of others), and needs 15-20mA Driver Current, so I believe it has a driver transistor on the PCB. Here's a close up...

User-inserted image

United Kingdom

Steve G, yes I can now see the drive SMT transistor (bottom left with 3 pads) just below the back emf protection diode.


Is it a latching relay? I guess I can look up the part number.

United Kingdom

I believe it's a toggle relay, as when I kill the power I can hear it click off. Apply power or run the first script it clicks on until I kill the power again.


Hmmm.. Latching relay.

I think that would solve the concern I had in your thread about using a relay for low voltage cutoff. EZ-B turns it off when the battery is low. Push-button turns it on when you have charged the battery. Doesn't use any power to hold either position.

From Wikipedia:


A latching relay (also called "impulse", "keep", or "stay" relays) maintains either contact position indefinitely without power applied to the coil. The advantage is that one coil consumes power only for an instant while the relay is being switched, and the relay contacts retain this setting across a power outage. A latching relay allows remote control of building lighting without the hum that may be produced from a continuously (AC) energized coil.



@Alan... so I guess a latching relay would just flip/flop positions after power is removed with a high signal pin then? I am trying to figure out how you would alternate between relay positions? Just keep sending the relay a high signal or would you have to remove the power each time before sending it another high signal on a digital pin?

United Kingdom

What I want this thing to do is to turn lights on and off using D0,on/off scripts. Isn't this thing meant to do just that? Or have I got the wrong one? (Wouldn't surprise me with the day I'm having).


@Steve, yes normally (meaning not a latching relay) a regular relay is supposed to do what you mentioned... I keep pushing this one as I know it works (I have a few that I use).... It is only rated at 2amps (I have put more through it however with no issues) Electronic Brick Relay It may be a moot point since you have some...


@Richard R

From what I am reading, there are different types. You could get one that does as you describe, and acts like a toggle, changing position each time signal is applied, or one that has two different signals, on and off, so you set one high momentarily to turn it on, and another high momentarily to turn it off.

@Steve G, Yes, that is one of the things this is meant to do, and should be working. I suspect the issue is that it expects a 5v signal and the EZ-B only provides a 3.3v signal, as @rb550f indicated. You may need a logic volt shifter (so your voltage regulator is dropping the VCC from 7.5 to 5, which is what the relay needs for VCC (power), and the shifter raises the 3.3v signal to 5v which is what it needs to trip relay position.



@steve... RE: what Alan said... just as a stretch try sending the relay set(D0,ON) and then send the same set(D0,ON) again and see if it clicks off... You never know...

United Kingdom

Right thanks guys. I'm getting it now. As @rb550 said, the signal pin need to produce 5v, not 3.3. I'll have a look at your suggestion Richard. Thanks again everyone. Not just this issue (just the cherry on the horrible tasting cake), but I'm REALLY having one of those days where nothing goes right.

Thanks again.

United Kingdom


Worth a try I guess with nothing to lose.


@Steve.... We've all been there... It's frustrating trying to get something to work that shouldn't be that hard in the first place.... been there, done that... Relax, have a beer and know that tomorrow will be a way better day...

United Kingdom


Yeah, a beer sounds like a great idea. Had a 4 hour back and forth argument with UPS earlier about what I thought was a simple issue that could be resolved, then my central heating boiler packed up, and numerous other things were sent to test me. So I thought robotics would be a nice stress free release... Wrong, lol. What was I thinking.

Andrew, make mine a Budwiser, and make it snappy. :P


Ahh man, that has been a crappy day. Sorry about that dude... Andrew, better make it two Buds for Steve.... :)

United Kingdom


Now you're talking. :D

Jokes aside, thanks for the kind words. I've just ordered two of the relays you linked to, so it should be all good.


@Steve... awesome... I promise those are plug in play with the ezb4... Andrew has one in his drive base.... You're welcome by the way.... :)

Forgot to mention.. they are only rated at 2amps, but as I said I have ran more through them...

United Kingdom

No problem. 2 amps will be more than enough for my needs. I'm still going to use the relay I have as well with a level converter that @rb550f mentioned. I've got it so might as well use it.

Thanks again for your input everyone. ;)


United Kingdom


Quick and possibly silly question. The relay you linked to, how do you connect it? So far I have the G, V, S (three pin port on the relay) on port d0 via a 5v reg, and a separately powered LED with the break in one wire going through the Com and NC, but nothing's happening (except for a very faint LED that breifly flashes once when I run a "On, sleep, Off script").


@steve.... you don't need a regulator unless you are using more than 7.4V with you ezb... Plug it directly into the ezb port with 3 wires... G=ground V= Red pin S=signal pin

switching part.... com= common NO= normally open NC = Normally closed

simply set(D0,On) and set(D0,off) to operate... Plug and play dude... :)

United Kingdom


Right. Reg was the problem. All good now. Cheers bud. :)


On second thought, maybe best to use with only 5V... I just tested it with 8.14V that my LIPO was reading.... It worked well enough, but can't vouch for the longevity of the relay at that voltage... I usually use them at 6V because most of my recent projects were using 6V niMh bats.... So just got used to plugging them directly into the ezb without a regulator....

United Kingdom

So why wouldn't the 5v reg work with the relay then? It's connected correctly and it does work.

United Kingdom


I found out what the problem was. The regulator I was using (not an EZ-Robot one, but a UBEC one) was labeled incorrectly. Output was input, and visa versa. It works now I have it back to front.

Thanks anyway. An unrelated question, can an ADC port be set to On and Off, and if so, how?


I made my own 5V regs using LM7805s and some servo extension wire that seem to drive the relay no problem... Maybe there is something different about the ez robot reg? Not sure... Perhaps you'll be fine without the reg... Like I said the relay wasn't complaining or getting hot when I was using 8V with them.... Besides, they are not all that expensive, so won't be a big deal to replace them should they fail before their MFT (mean failure time).... They are probably good for a few 100,000 relay cycles....


You can't control an adc port like you can a digital port.... ADC ports are more meant to measure analog voltage levels...

United Kingdom

I thought as much. Just wanted to make sure as I'm running a little short on Digital ports. I just emailed the company selling the UBEC regs telling them they were labeled incorrectly.

Thanks again.