How the heck does this work (the Crudest possible way of switching a relay with ESP 01s works!)

Hi, so I searched through the categories and didn't find anything related to the ESP01s module. So I'm posting it here. (treating as if it's a general electronic component. I guess that's not entirely inaccurate. :grinning:)

Few Words Summary

Here's the "schematic" and summary if you can't understand. I guess in the Arduino forum when you ask in few words, you're asked to explain, and when you explain, you're asked a summary right? So here's both.

I should fry the ESP 01s and waste money right? There are 101 better ways to do this right? None works for me, and this works perfectly. I want to know why. If you like, read the long version below. :+1: :+1: :+1:

I'm a total novice into MCU programming, so after ordering a UNO board, few additional components, I looked up a few tutorials, and got to work on a small project. Since this is one of my very first, there's nothing fancy. Just using a ESP-01s module to switch a relay module on off.

As far as the code goes, it's simple enough. Just using the Blynk app and its library to generate a GPIO PWM through WiFi, and running a relay module from there. Extremely simple and just works. This actually doesn't use the UNO, and the ESP 01s runs all by itself. It has only 8 pins and says it runs on 3.3V.

I got everything working, but not the power supply issue. After using a UART USB TTL with 3.3V to upload the code and it started running, I removed all the extra jumpers and plugged it into a powerbank, and checked if just providing 3.3V and GND to the ESP 01s works. This is because it was the easiest way for me to get 3.3V. ESP 01s works, the GPIO2 pin puts out a PWM when I press the button on the Blynk app.

Getting that PWM to run a relay was the biggest hassle I faced. I have the really basic 2 channel 5V relay module, and since it runs on a different voltage, I tried racking my brain how to provide the power.

I first used the 5V pin and GND on the USB TTL itself. (plugged to a powerbank, so only to get power) It does send power to the relay, (since I can see the IN1 LED light up), but for some reason, the relay doesn't activate. I thought maybe this is because USB TTL can't provide enough power to energize the EM coils. Oh well.

Then I tried as I might to attach a separate cable with it's microUSB plugged to a small component that gives out easy access to the pins. Plugged this to the other USB port (has 2 USB As) of my powerbank and got the 5V and GND attached to the relay. For some reason, this didn't work either. Relay simply does not turn on. (maybe something wrong with it, the USB cable or the component, let's say)

Then I attached both the USB cable and USB TTL to different ports of my laptop. Then, everything works. However, when I removed the USB TTL, and plugged it to the Powerbank, and just plugged the relay to a laptop USB, it doesn't turn on the relay for some reason. ESP 01s works fine with when USB TTL is attached to the powerbank. (To reiterate, I plugged the USB TTL to powerbank just to get 3.3V for the ESP 01s)

The only reason I can think here is that somehow the relay and ESP 01s has to be on the same power circuit. (Since plugging both to laptop USBs work and they are commonly powered, and the powerbank USB ports are powered separately) So the only solution seemed to be to somehow get a 3.3V from the micro USB component.

After racking my brain for a lot, I was simply fed up so just connected the ESP 01s to the same micro USB thinking devil may care. I got the ESP 01s dirt cheap after all. So as you can see from the photo, a USB cable comes to the Micro USB component, and it outs 5V and GND from two holes. I have put two male jumpers through it, attached female jumpers from the other side. What this does is just gives out 4 leads with two 5Vs and two GNDs, I have plugged one set to the relay, and one set to the ESP 01s. A single jumper runs from the ESP 01s's GPIO2 to IN1 of the relay.

According to everything I read, this should simply smoke the ESP 01s chip. However, plugging the relevant USB cable to anything simply works perfectly!! The chip powers up and connects to WiFi, the relay is charged, and the PWM switch works. It doesn't matter whether this is any USB port of my laptop, or any USB port of my powerbank.

This also renders moot whether my previous issue was if the USB cable, micro USB component or any port of the powerbank is defective. Everything is okay. (I know the laptop and USB TTL are not defective because I used them to upload the code successfully) I'm just saying out loud the debugging steps that go through my head here. Please let me know if I'm wrong.

So how the heck does this work and previous versions doesn't? I'm clearly not supposed to power the ESP 01s with 5V, because it is said to fry the chip. But that should happen immediately right? Somehow that doesn't. The relay needs 5V, and if somehow the USB cable and micro USB component is somehow so bad that the resistance drops the 5V voltage to 3.3V (I know right :grinning: ), that shouldn't power the relay. However, it seems that this setup is giving perfect amount of power to both the relay and the ESP 01s.

I ask anyone knowledgeable how the heck is the possible? As far as I can understand, there's only three extremely unlikely explanations for this.

  1. I have found a set of magic 10cm jumper cables that takes 5V and outs 3.3V to the ESP 01s :rofl: :rofl: :rofl:
  2. ESP 01s is 5V tolerant, and every forum I read on the internet is wrong. It does not cause any harm to the MCU, and everyone is just running around trying to power it with 3.3V only.
  3. I have found a magical ESP 01s that IS 5V tolerant, even though is clearly says not.
  4. USB cable and micro USB component has such a bad construction that it somehow drops 5V to 3.3, AND I have found a magical 5V relay that can be powered by 3.3V.

So which is it? Can someone explain? Here are the photos. See and answer me.

Schematic? Pictures show us very little.

Hello @indrajithgamage
You use a a lot of words to tell us very little, I gave up reading. Please see How to get the best out of this forum
We need code and a schematic and a description that gets to the point of what you are asking.


Keep the post simple.

It shows little because it has little. I edited the forum, now check and answer me.

Code is irrelevant here. It already works. I'm asking about supplying power.

Read the summary and answer perhaps?

Your schematic is fine, much MUCH better than all the text you gave us. I don't know what your question is though, I mean you asked 'How the heck does this work?', I see nothing to answer, you connected a GPIO pin to the relay and the relay, I assume, operates as intended. It works because that's how it's supposed to work. What do you not understand?

You, OP, are really putting 5V into the 3.3V of the ESP01?

I think this is a better way, you might want to check the spec and design of the board.

My thoughts exactly! You're scratching your head right? That's exactly why I'm asking how the heck does this work??? 5V to intorelarable 3.3V (if every forum is to be believed) and nothing wrong!

This is working like a charm. Just to check, I kept it on for like an hour plugged in, and still nothing has happened. I guess if 5V is supposed to fry the chip, it should have already gone on smoke right? Still working without any issue. :ok_hand::ok_hand:

Saturday, 07 August 2021, 00:32AM +05:30 from Idahowalker via Arduino Forum

Yeah, but as you can see, mine is really simple and it works without any issue at all! No transistors, no capacitors, no regulators. Two jumpers for 5V,GND, and you get PWMs as you want!

Turns out, the huge scare about ESP-01S being NOT 3.3V tolerant is a farce. Can you imagine how many IOT projects would be simpler if ESP-01S can be given just 5V? That's

Have you checked the circuit on the relay board, I think it is very well possible that there is an optocoupler and some other devices on it.

Most (many? all?) ESP boards have a 5V power supply input and an on board 3V3 regulator for the actual chip. I am not familiar with the ESP01 but I would expect it to have one. I suspect you have really connected the 5V supply to the 5V input, so the ESP01 is OK from that point of view.

The rest of the answer will be as @JOHI has suggested, or very similar, so there isn't 5V on the ESP01.

Are you aware of this: Quote by Mark Twain: “I apologize for such a long letter - I didn't h...”

And to address the problem you mention (and a few other problems) I wrote the forum instructions mentioned in reply #3.

Yes, there are optocouplers on the relay module! (duh) That's completely irrelevant here. What I'm saying is, ESP-01S runs like clockwork on 5V. Everyone says it needs 3.3V, and it fries if given 5V, but that DOESN'T HAPPEN!

Saturday, 07 August 2021, 01:00AM +05:30 from JOHI via Arduino Forum

Okay, just Google ESP-01S. It has 3.3V pin, but no 5V. This is the module almost everyone uses to get WiFi enabled for arduino projects.

There's no regulator or anything on it. Just check the second photo of me holding it on the OP. According to the official data sheets and EVERY person on forums, giving 3.6V or more to 3.3V will fry the chip. Just google and see that as well.

You are the only person on earth saying it's 5V tolerable. Find me one source that says it is so. I'll give you a hundred places where it says 3.6V is the max.

I think you will find I did not say that!

AFAIK the ESP8266 is not 5V tolerant, maybe you got lucky, but don't rely on it.

You maybe referring to ESP8266 based complete boards, like by Adafruit, Lua, NodeaMCU etc. Those come with dozens of pins, USB ports, buttons, jumpers, serial com chips and what-not. Obviously they have regulators. I'm talking about the bare bones ESP-01S with nothing expect 8 pins in it, that doesn't even fit on a breadboard. Just check the photo. :+1::+1:

Hence why I said:

I thought that was clear, I don't actually know about that particular board so I was telling you what I thought would be the case based on my experience with other boards and your experience that it works OK on 5V. If that's not the explanation then maybe someone else can offer a better one.

More speculation, maybe it does work on 5V OK but the manufacturer does not guarantee it.