Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

ESP8266 and relay board

Status
Not open for further replies.
Hello,

I am trying to control relay with my ESP8266. I use this board:

**broken link removed**

I tried running it directly from ESP8266 and it works fine, but draws 0.12A which is more then ESP8266 is rated for (0.02A). I tried powering the relay with external power and controling it with ESP8266 but it simply will not work. The only time it worked was when i connected the external power ground with the ground on ESP8266. I do not understand why i need to do that.

Anyway the way i see it i got a few options and would like you to comment on that:

1) i simply use 3.3V from ESP8266 to power the relay and hope it doesnt burn. I seen online many video of ppl directly powering the relay board with esp8266. Any chance of not burning esp8266

2) have the grounds of external power and esp8266 connected. While it works it has 2 problems. Connected like this code will not upload to esp8266 until i disconect the grounds. Its inconvinient but not much problem. What bothers me is that when i have it connected like that, the power on relay shines less bright when the relay is opened. Dont know why.

3) use 5V pin on esp8266 to power the board which is made for 3V. That 5V pin allows much more amperage so it would run the relay board no problem. My question is, will 5V damage this relay board ?

4) same as above but i use stepdown to convert voltage from 5V to 3V. That would be simple enough and so far seems like the best option.

Also i would like to know why ground of esp8266 and whats powering the board has to be connected, any thoughts ?
 
You see the end that has VCC IN GND you hook all 3 to your ESP
5 volt to VCC your output pin to IN and oh yes the GND to the GND

And if it's not working that way the relay board is bad because that is how it should hook up.
I have no problems programming a esp with relay hooked up
This is using a board just like what you have
It takes ground to make path for power to flow from the gpio to led that switching the opc on.
 
Last edited:
You should try to make a schematic of your board if you want to learn why it is behaving that way.

Here is what I believe you have (borrowing these from https://www.handsontec.com/dataspecs/4Ch-relay.pdf) but I think they are basically representative.

ESPrelay1.jpg


It probably only takes about 5mA or so to operate the optoisolator. In other words, that is all the GPIO needs to supply. The problem is, where is the power to operate the relay coil going to come from? It has no choice but to come from the module VCC and therein lies your situation. If the PS that feeds the ESP8266 has enough left over, then that will work but you have to have GND connected also.

Other boards will have a jumper on them, like this:

esprelay-2.jpg

In that case, you could have an external PS with an external GND.

You do not have that option. You don't have isolation other than the relay.

They, apparently, decided that they would leave that jumper out. If you make your own schematic, you might be able to modify it. Alternatively, get a better board.

I could be missing something, but that is how I see it.
 
I will try to clarify what i mean with 2 pictures, first is the picture of what DOES work, but the problem is in first case i am running relay board with 3.3V pin on esp8266 using more amps then its allowed (relay uses 0.12A while esp8266 max is 0.02A). In the second case i use 5V pin to power a 3V relay board, it works but is it good long term for the relay board rated 3V to be run at 5V ?
Untitled.png
 
How are you coming up with 0.12A like this ?
amp2.png
 
Last edited:
I didnt measure like this ... i only measured from 3.3V pin on esp8266 to relay, i never measured from D1 to IN, because i am sure it uses very little amps.
But i see i did a mistake. I was looking at how much gpio pins can give on esp8266 instead i should be looking at how much 3.3V can output and i think 3.3V can handle 0.12A, what do u say ?
 

Attachments

  • Untitled.png
    Untitled.png
    149.5 KB · Views: 270
I think that there is some difficulty in communication here.

The ESP8266 does not have a 3.3V pin, it has a Vcc pin (at least all the ones that I have used) and it needs 3.3V applied to that pin to operate.

What you keep calling the ESP8266 3.3V pin is actually the 3.3V pin on the board.

How are you powering the ESP8266 BOARD? Are you using a 5V supply connected to the USB port (or 5V pin) or are you connecting 3.3V directly to the boards 3.3V pin? (some, that have a diode will allow that).

If you are powering the board from a 5V source, that 5V is regulated to 3.3V and is used to power the ESP8266 at the Vcc pin. IF that regulator can supply enough power to run both the ESP8266 board AND the relay coil, you are fine. If not, you will [NOT] be able to run it reliably. You need to get the schematic and identify the regulator and estimate how much overhead is left.

The second diagram in your post #5 is the better choice in my opinion. But, you have to connect the GNDs on the ESP8266 board and the external PS. This does not have to be a huge problem, but if you don't want to do that, then buy a relay board that allows the option to use an external PS.

I thought that I had explained this pretty well - was I wrong about that or did you not read it?

As far as running a 3V relay coil with 5V. Go get the data sheet and see if that helps. It is sold as a 3V coil by the manufacturer and that is what it is designed to use. 5V may also work - does that mean it will work as well down the road? I don't know, but why not match your components?
 
Last edited:
Yep I agree first off the TS is reading the total current being used and worrying about the wrong thing.

The output is good for around 10 mA so if your using say GPIO 6 to turn on the relay the pin is lighting a led inside a optoisolator
which is maybe at most 10 mA i'm banking it's less.

Next If you check at the the 3 volt pin your reading the total power that reading includes the relay being held in.

Hook it up like this and have fun
amp3.png
 
Based on this comment,

i think 3.3V can handle 0.12A, what do u say ?


I think a short lesson in Ohm's Law is needed.
Voltage = amps x resistance, or
Amps = voltage / resistance

resistance measured in ohms.

a quick summary is,

if your 3.3v I/O pin On the ESP8266 is connected to ground with a 100 ohm resistor, 0.033 amps (33mA) will(3.3V/100ohms = 0.033 Amps).

now a quick application example
If your 3.3v I/O pin is connected to a relay coil with 66 ohms of resistance, you can do the calculation to confirm but I get 0.050 amps (Or 50mA) will flow when the I/O pin is set to OUTPUT and set to HIGH. This will immediately burn out the I/O pin because the datasheet says the absolute maximum that the ESP8266 can handle is 35mA.

Again
Assuming you connect a 30 cm long piece of copper wire with resistance of 0.001 ohm from the I/O pin to ground and set the pin to OUTPUT, HIGH, your poor ESP8266 pin will burn out immediately because you are asking for 3.3 V /. 0.001 ohms = 3300 amps to flow. obviously, your power supply cannot supply that many amps, nor could the thin piece of hookup wire handle that much power without damage. [note that power in watts = volts x amps]

I hope that helps.
 
I was looking at the wrong data. I forgot that i am powering the relay board with VCC (3.3V) and not the actual gpio pin, gpio pin just sends signal and that is very little amperage. And 3.3V pin should handle that 0.12A. It would be great if i could find the data on exactly how much i can get from 3.3V pin, i found different numbers, some saying 0.250A, some saying 0.850A, etc.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top