Welcome to Synthiam!

Program robots using technologies created from industry experts. ARC is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.

Get Started
Asked — Edited

Relays Turn On, But Not Off

Alright. My dewy build is almost finished, but I have hit a problem with the relays I'm using. They require at least 1.5v to activate them, and then nothing to deactivate them.

Using a set digital control, I can turn them on, but turning the control off doesn't deactivate the relays.

Why would this be? Does setting the digital port off not set the voltage low?

How else can I activate them and deactivate them with the ez-b if not in this manor?

Can't find the thread(s), but this has been seen before. I think the solution was to use a pull down resistor, but I am not positive (nor do I know how that would be wired).

Hi @MazeHorizonTech, I have an 8 relay board which I run off my ezb. I had tried many different ways to operate the relays directly from the ezb port, but had the problem you are having. The way I cured it was to build a TIP 120 transistor board and used it as a slave. Rich made a post a while back on how to build the circuit. I will post the location shortly.
The problem with the tip120 is it is essentially a relay to run a relay, and it just seems like a waste to me.

Could a pull down resistor do it? I'm not sure how it could be wired either. Mainly it is just getting the voltage low enough to disable the relay. Why it stays high I do not know...
I agree, but it works. Maybe some else can help. Rich and Richard R gave feedback on this subject but I forget what they said.
Richard R linked to some relays that work out of the box with the EZ-B (I thought I bookmarked that but can't seem to find it today either). The thread where he mentioned it most recently also had the information about the pull down resistors I believe.

@MazeHorizonTech, @AndyRoid:
Alan pointed to the post with correct solution.

To summarize your relay needs a 5v logic to operate (I have a few i got from ebay) it works with Arduino (5V logic), but does not work with a RPI/EZB because the logic level is 3.3v, not enough to trigger the Relay logic.

TIP120 can work but is old, and is not an efficient component.

you need a Logic Level circuit i'm familiar with these:





the first 3 are bi-directional the last one only converts from 3.3 to 5v.

you will need also a 5v to source the circuits
Relays are cheap solutions for reversible motor control...however seems redundant if you use a tip120 to switch on another switch...why not cut the relay out and just use a tip120? They may be "old" but they work. Keep it simple...:P
There is a problem with this thinking. Why could a 1.5v AA battery turn it on and off with no problem, but the 3v ez-b can't?

My test shows that when the ez-b is set on, the port reads 3.3v. Off, 0.0v.
When attached to the relay, it is 3.3v set on, and then 0.85v off...

Why is there suddenly a voltage on the signal pin? In this scenario, the ez-bs signal pin turns into a switch of its own allowing the voltage that is coming in to flow through it. Moving the plug to a different port stops this until it is triggered with the digital control again.
Wow. Simply grounding the signal of the relay to the power source triggers it. Isnt that lovely. So it needs a switch to trigger a switch.
That's why I M pretty sure pull-down resistor is the solution. It pulls a floating signal down to 0 volts. Wish I knew more about electronics so I could explain it better. I am just repeaing what I have heard. If they weren't busy moving offices Jeremie or DJ could explain.

I'm not sure where the resistor would be, or what the value should be.
I think following this would be safe? Or no?

User-inserted image

The resistor in this would be 10k.
My current wiring is as follows.
User-inserted image

If we connect the signal to gnd, it goes high and activates the relay, so the resistor can't go to gnd, right?

Can you post a pick/url of your Relay ?
Did anyone try the 10K resistor, signal to ground and what happened? I am unable to try it at this time, but think we did this in the past. It would be great to get rid of my transistor board on my current relay system if it works. Like Alan said, I assume it would pull down the voltage to the relay and "should" drop out the relay. I have a couple of projects which will need relays so I hope the answer can be found.
I also have been using "Arduino" compatible relays.

Frustration is what made me go to the transistor board.

The sketch description above works for a push button input. I used it on my Madame Nindo project with no "magic smoke".
From the reading I was doing last night, it looks like you put the resistor between the signal and ground before the relay (see attached picture where I have very badly drawn in the resistor).

I am not sure if 10K is the right value or how to calculate the right value. There is much much more available online about using pull-up resistors than pull-down resistors.

User-inserted image
I can test it I think but I too have no knowledge on how to calculate the value.
So here's the scoop with Relays, there are a couple different types: Latching and non-latching. Non-latching are the most popular but do keep in mind that latching relays do exist. The difference is that when you energize the latching relay coil it stays in place if the voltage is removed, a non-latching relay would spring back to it's starting position. With a latching relay you could a pull up or pull down resistor to bring it back to a default position (as Alan suggested). A 10Kohm resistor is the most common value. Why? 5V/10Kohm = 500uA or 3.3V/10Kohm = 330uA, these low currents can continuously run through the resistors such as 1/8Watt or 1/4Watt sized without any chance of heat build up but they'll still be able to quickly pull the signal high or low.

When driving relays you always need a switching transistor to activate it. Why? Because the maximum output current that a microcontroller can usually drive from an output pin is 25mA (ez-bv4 is hardware limited to 10mA). Relay coils usually need at least 50mA to activate. You don't need a large TIP transistor to drive the relay, a simple switching transistor like a 2N3904 is fine.

Here's the rub, a 3.3V digital high signal from the ez-b likely won't be able to drive a relay directly as it is current limited to 10mA. There's not enough current to switch the relay directly but a 1.5V can likely switch a 5V relay no problem because it doesn't have a resistor in series with it (limiting the current).

The most popular way to switch relays with a microcontroller is to connect your signal pin to a resistor, to drive a 2N3904, and connect a flyback diode across the coil of the relay.

Here's a diagram:
User-inserted image
Also - check the relay if it has a flyback diode. Not all relays have a flyback diode. Since an inductor (the relay coil) cannot change it's current instantly, the flyback diode provides a path for the current when the coil is switched off. Otherwise, a voltage spike will occur causing arcing on switch contacts or possibly destroying switching transistors or the ez-b.

More info: https://en.wikipedia.org/wiki/Flyback_diode
I finally found the link to the relay that Richard R says is plug and play with the EZ-B, although the datasheet doesn't seem to validate that since it seems to require too much voltage and too high ma.... It does have a flyback diode (they just call it protection, but that is what they mean).


Jeremie - would you share the link to the relay board that we used on bimbo?
@Alan... I think It gets the 5V from the power pin (I use a couple with my inMoov using 6V and it is fine)... The signal pin is just the trigger (some sort of mosfet maybe?). Anyway 3,3V seems to do fine... I have been using these plug and play for a few years now in various projects with no issues... Come to think of it so has Steve G...
Oh, yeah, I didn't notice that they connect all three pins to the digital port, that makes sense. I guess if using with a 7.4 lipo would probably want to put a 5v regulator inline.

I am on my phone now so can't easily check, but I noticed in the data sheet download zip file that there was also a schematic. Should check to see if it has a mosfet or transistor on board.

So will the resistor work? Or is a diode in the signal line needed?
This is a picture of the relays I tried to use and had the same problem with it staying on. I put a 5 volt supply to it, and gnd to gnd on the ezb and the signal to a port.

I needed the relays to work for the project so I made a transistor switching board that Rich posted. That got me running. I don't have the spec sheet, there was none when I got it on ebay.
User-inserted image

I know others had tried to make this style relay work, but I never heard a final fix.
I put a 10k ohm resistor in the signal line. It inverts the trigger method. I put power on, it turns off. I put digital off, it turns on.

Before it would only partially turn off, not enough to disengage it.
I won't be able to test it until late this week, but maybe a 10k resistor, sig to ground will fix it?
In my mind, adding a diode to the signal pin should do it, but I'm not sure.
I would be concerned with a diode. It could short it out.
But it does work with the resistor, but inverted?
To All,

@ MazeHorizonTech and I still are missing something. We are not using straight relays, but relay boards, many with indicators etc. They are called Arduino compatible boards, but are not ezb compatible. Most are 5 volt which means we should use an external supply and common ground to the ezb. We get it to turn on . How do we get it to turn off?

I played with this in the past and ended up with a transistor switch operating the relay board, do to frustration, which has resurfaced again... LOL...

Please help us understand what we are missing.
I re-read Jeremie's thread. He said some of these relays work inverted due to an optical coupler. You said you placed the resistor between the signal and the ezb which allowed the relay to work, but backwards? Then it is working correctly.
So I think we really need some documentation on @Techno's relay board (is it the exact one that @Techguru linked too?) and I think we'll need some documentation on @ANDYROID's board as well.

I believe that they may have different relay control circuits. One may be transistor controlled and the other could be opto-coupler controlled.

In my first post I explained how to use a relay with your own transistor control circuit, but I'm guessing both you guys are using Relay boards with the control circuit built on.

@ANDYROID the board you posted above has opto-coupler control. I've been able to use this type of board with an ez-bv4 just recently. I needed to connect a 5V regulator to VCC, share the same Ground, and then I use inverted logic. A low digital output (0V) from the ez-b would cause the relay to turn on and a high digital output (3.3V) turned the relay off.
I will try it again the end of the week. I will post the results. Thanks,
This is what I think I did with the resistor in the signal line. Is this okay for the ez-b though?

I think adding a diode to the signal line only would work just like the AA circuit I used. The AA battery acted as a diode stopping the voltage coming from the signal pin. The diode would likely do this as well. I just don't know what diode to use, or where to find it. I have a bunch of de-soldered ones I could use, just not sure how to classify them.
@Techno (or should I call you @MHO now?):)
Adding resistors to the ez-b is always ok, adding resistance only limits the current or pulls a signal high or low by default. Just make sure that if you are pulling an ez-bv4 pin high use the 3.3V supply. Technically you can pull an ez-b I/O pin up to 5V (as the I/O pins on the ez-b are 5V compatible) but we'd recommend 3.3V.

Adding a diode in series with an ez-b I/O pin won't really do much for you besides drop the voltage by ~0.7V (forward voltage drop of the diode). I guess a diode could block any stray voltage from feeding back into the I/O pin but I don't think it's going to help you in this case (unless you are doing your own flyback circuit). If you want to use a diode a couple standards for signal use are 1N914 or 1N4148, for power try the 1N4001-1N4007 series.

I don't think we ever cleared it up but are you creating your own relay control circuitry or are you using a relay board of some sort. If you are using a relay board can you provide a link or a picture?
If the relay is the same in the Post (Alan's link) ...

and following the post, everyone mention the same things (diode, transistor,safe,5v,etc)

and DJ's asks the question:


does that have a transistor on the board?

i also wrote:



Can you post a pick/url of your Relay ?

we can keep writing stuff, probably something will work out:)
Maze posted some info in the other thread:

1) ebay link:

The picture is not clear what kind of components are presented in the PCB, there are something there besides the relay, so a clear picture from the PCB can help identifying the components.

2) Songle Relay (PDF)
That is the relay part, but the PCB does have more than the relay, so the relay per see is a common component does not help.

A good PCB picture exposing the side where is control logic (IN/VCC/GND) will definitely help.
Hmmm.. If you read through that whole thread (which granted, is a year old, so may not not be the relays he is trying to use here) pretty much all the same questions were asked and answered, with the recommendation that it be controlled with a transistor and not directly connected to the EZ-B.

@MHO... Are these the same relays?

Ill get you guys pictures.

The post @thetechguru linked did mention diodes i believe, but it too suggested making a switch to run a switch.

@Jeremie As long as it isn't hard on the Ez-b I may just run the reverse circuit with the resistor.
The diode is exactly that, stopping the flyback voltage, as explained by a previous post, like the AA trigger I made.

The relay circuit has a diode, what appears to be a transistor, and 3 resistors, along with 2 LEDs.
Regarding pull-up (5V) or pull down (0v) resistors connect to a EZB Pin does not change the EZB Pin voltage output.

IF the EZB's pin has 0v and you have a pull up(5V) the result is 0V

If the EZB's pin has 3.3v and you have a pull up (5V) the result is 3.3v

even if the EZB pin has 0.5v (the normal values are 0 or 3.3v) the output will be always the EZB pin no matter what kind of pull up or pull down you have.

pull up/down resistors are used in:
1) open circuits like a push/switch button
2) open collector circuits like I2C, (i2c circuits communicate pulling down (0V) or leaving open the lines)

@Jeremie can you please validate my assumptions ?
User-inserted image

@thetechguru yes they are the same relays, but the reason I am looking for different is stated above.

if the transistor is present top left corner, and you have the diode it seems good to me.

I have a few relays (ebay) besides the transistor and the diode also have an optocoupler. Some people argue is not needed, others say is another safety layer, others say is a protection for bad circuit design.

i would add a logic level circuit between EZB pin the IN1, they are cheap and offer also some protection (in case of a short circuit a LLV is cheap than an EZB).

I don't think the IN1 pin will sink current from EZB,

if you want confirm, you can wire the relay (vcc, gnd) and measure current with a multi-meter between a 5V and the IN1 pin.

Let's wait for Jeremie 's opinion.
@Jeremie, perhaps powering it off 3.3v like you did may change something. I'll investigate.
If it doesn't I suspect that there may be a default pull-up resistor that could be causing you grief. Your board looks like it has a few too many resistors on it.
I then understand this discussion is for relays with a built in transistor switching circuit. I have relays with a opto- coupler circuit. I will start another thread to not cause confusion here. Anyone doing a future search will get information on the opto-coupled style relay.
@Jeremie if I were to add a diode what should I use? Is what would the specs be? I have some but am not sure whether they will work.
User-inserted image

It seems you already have a flyback diode on your relay board so no need to add another. It doesn't really look like a diode but it's an older style germanium.

I'm getting the sense that your relay has an issue, do you have anymore of these boards to test? Can you test something like a servo on the digital pin you are using just to make sure everything is in working order?

I take it back that the board has too many resistors. I didn't notice that second LED on there. So that's one resistor per LED and one for the transistor base.
I've tested 3 different from the same manufacturer. They're all the same. Voltage on the in line.
I also get some voltage at the IN1 pin on my board (-0.7V) but I suspect it's just because the base of the transistor is floating. You could use a 10Kohm pull down resistor on the IN1 pin if this voltage bothers you.
The 10kohn pull down to what? Ground? Because this activates the relay...
So how much voltage is at the IN1 pin? Is it 3.3V or 5V. If that's the case you might have a PNP transistor on-board so the logic will be inverted. You will have to send a low signal to turn it on and a high to turn it off.
If it isn't connected it stays off. If I connect to the ez-b with the port I triggered it stays off. If I turn the port on, it turns on. If I turn the port off it goes half off, signalled by the led, but does not deactivate. If I add a 10kohm resistor to the Gnd or signal line, the relay acts in the way you described.
Couple questions:

There's two LEDs on the board, is one a power LED?

You mentioned that if you send a high signal from the ez-b to IN1 on the relay board the relay activates. (no resistors applied)

You also mentioned if you place a pull-down resistor (from IN1 to GND) the relay activates.

These two scenarios are in conflict with each other.

Are you certain that you have a common ground?

I am unsure what you mean by "triggering a port" but I will say this: The I/O pins on the ez-b are tri-state, which means that when they are not set to a digital high (3.3V) or digital Low (0V) they are in a high resistance state (High-Z). In a High-Z state the pin will appear to have 0V but in reality it is floating and has no state until a high or low signal is sent.
2 LEDs. 1 for power, and the other for activation status(on, relay activated).

Yes, I agree, but it is what is happening. This makes me think that when the ez-b activates, the current flows through it to gnd.

Common ground is achieved by connecting the gnd pin of the ez-b to the gnd of the 5v power source for the relay. This allows, in my mind, common ground. Perhaps not?

In High Z state the relay is doing nothing.

When the port is set on(no resistor) it activates. When port is set off(no resistor) the relay hits the mid point, where it is half way to turning of, as indicated my the activation light dimming.

When port is set on(WITH resistor) it deactivates, and when turned off, it activates.

I too am puzzled by this conundrum. I will play with it again, and see if something changes.
I have a relay of similar design. My knowledge of electronics is very limited so please be understanding.

This relay has a 2TY device, 3 resistors all marked 102, 2 leds and a diode. I am assuming the 2TY is a transistor. If anyone knows this is true, can they tell me the pinout ? I will then try to make a schematic of the one I have.

Maybe we then can get a better idea of what we are dealing with.

Here is a schematic,

User-inserted image

I assume 2TY is a transistor.

Someone please help how to use this circuit.

Diode polarity may be drawn wrong.
Sweet, thanks for that @Andy it gives me a bit more to go on. As I suspected earlier on, the 2T transistor is a PNP (looked it up via it's SMD code). This makes more sense now, in order to activate a PNP transistor you have to bring your signal low.

One thing to remember about PNP transistors is that voltage relationships matter. If you are supplying 5V at the VCC pin and switching the transistor base with 3.3V logic the 1.7V difference might appear as a logic low to the PNP and it will turn on.

You'll likely have to use 3.3V on the VCC pin, that being said, I hope 3.3V is enough to turn these PNP transistors off.

What I also suspect is happening is that there is a 1Kohm (102) resistor + the 330ohm resistor on the ez-b itself in series with the digital pin which is limiting the amount of current that can be "sunk" by the ez-b digital pin. This is likely why the LED is stuck half on. What I would suggest is adding a solder blob across the 102 resistor that attaches to the IN pin in order to create a 0 ohm resistor instead of 1Kohm.

No matter how you look at it, if you want to use the control circuitry on this board you will have to use inverted logic due to the PNP transistor. 0V turns it on, 3.3V turns it off. But remember with a bit of soldering skills you can bypass the on-board control circuitry, solder directly onto the relay coil pins, and use your own circuit to control the relay (I'd suggest a NPN transistor...much easier)

Please note: I believe there's a couple minor errors with the schematic above. The LEDs should be flipped as the cathode should be toward GND and the Flyback diode should be probably be across (parallel with) the relay coil, not in series with it.
Thanks for the explanation.. At last I may get it to work.

My electronic skills are minimal and diode polarity escapes me. Anyway it seems I got it close enough for you to figure it out.

Thanks again,

What is the relay part number ?
I am sorry to say they were an ebay deal I got quite a while ago so I have no information. Here is a picture.

User-inserted image

They are low level logic. (signal Off = relay on, Signal On = relay off)

I would try to find a High logic one. (needs npn transistor) per Jeremie
I think we are complicating what is simple.

the relay is rated to work with 5V, there are other relays from the same family (Songle) one of them is rated to run at 3V (but is not what is in the pcb)

The circuit expects VCC=5V has a PNP transistor, this means when Vb is less than Ve the transistor closes.

1) EZB Pin Low => 0, Vb is less than Ve the transistors closes => relay on

2) EZB Pin High => 3.3v Vb is still less than Ve and the transistor closes => relay on

3) if you put 5V on IN, Vb is not less than Ve and the transistor is open => relay is off

we have a Logic Level issue, how to convert 3.3v to 5V.

Without complicating too much there are LLV circuits less than $1 why not use one ?

I wrote this on the beginning of the thread, no one supported my opinion is it wrong or not adequate ?

I use the KISS principle why complicate, changes and soldering new components ?
Hi @ptp, like many others here, have a limited knowledge of electronics so we are learning as we go. I didn't understand what goes on or how the relay circuit worked. Now I have a better idea. You, Jeremie and others have helped greatly.

If I understand, I just need to buy one of those 3.3vdc to 5vdc converters? I think they also work the other way too? (5v to 3.3v) They cost about $3 and have like 4 or 6 outputs. Right? This would be an easy fix.
Thanks for the explanation and all the help you have given. . I will get a converter and give it a try. I will keep trying things and learn.


It was a question too,

i'm not an expert neither i feel 100% confident, so that is why i asked the question.

i was waiting for Jeremie's or anyone to argue against a LLV, otherwise it seems too me the cleanest solution.

I like more software than hardware and i'm not good hacking circuits i have lost a few circuits, so i look to hardware like lego pieces, integrate circuits versus changing.
if you like breadboards this is the cheapest circuit:


has 8 ports can convert 8 x 3.3v to 5v (unidirectional) but the cost can get more expensive with shipping costs ($4 to $9)

if you like "legos":

these is the cheapest i found in the ebay:


each circuit has 4 ports, they wrote i2c because most people use them to interface arduinos 5v with 3.3v i2c devices, but they are bidirectional they can convert the opposite way.

There is a high side & low side, you can use them also to convert to 1.8v (intel edison)

if you don't trust ebay vendors you can get this one from sparkfun:


also has 4 ports.
Thanks for the info. I ordered 1 and once it is here I will play.