Page 1 of 1

Can i have power on GPIO - 3.3 volts, but no VIN or no power on 3.3 volts pin ?

Posted: Sun Feb 27, 2022 4:42 pm
by iongheorghe
Hello,
I would like to know if I destroy an ESP 32 if I apply 3.3 volts to GPIO16 for example, BUT is no power on VIN or on 3.3volts pin.
My VIN power it is controlled by another ON/OFF circuit, but on GPIO16 I have permanent power.
Thank you.

Re: Can i have power on GPIO - 3.3 volts, but no VIN or no power on 3.3 volts pin ?

Posted: Mon Feb 28, 2022 12:59 am
by ESP_Sprite
It's not a great idea in general, with any chip/microcontroller... there's ESD protections that shunt power on any pin that is above the power supply voltage, to the power supply rails. In your case, it means you'll be trying to power the chip *through* the GPIO.

What you can do is either turn the ESP off by grounding its EN pin (its power use is negligible when you do that), or if you really need to keep your current setup, connect a high-value resistor (say 33K or so) between the GPIO and whatever it's connected to in order to limit the current.

Re: Can i have power on GPIO - 3.3 volts, but no VIN or no power on 3.3 volts pin ?

Posted: Mon Feb 28, 2022 2:51 am
by iongheorghe
My configuration and what i want to do.
My ESP, it is powered by a battery or an external 5 volts.
Both of them are connected to the VIN pin.
The mosfet T1 decide if the power to board is from Lipo or from outside source.
If no outside source, the power it is supplied by Lipo. If the board it is connected to an outside source, the power to the board will be from the outside source.
The software on the ESP, has a timer which will shut down the incoming power to the VIN if no action on the keypad for more than 40 seconds.
What I want is to keep the board running if it is an outside source.
I need to detect the power before the T1.
If it is outside power, no timer.
The board get power by pressing the start button, which make the IRF to conduct and send power to ESP.
By software, ESP keeps the CONTROL line HIGH and ESP has permanent power.
When 40 seconds timer is UP, the ESP put the CONTROL line LOW and power to ESP will Stop.
Now, in normal condition, power goes to Start/Stop circuit, and after I press the Button goes to ESP.
But by the time I press the start button, power is already to GPIO16 and ESP does not have yet any power on VIN pin.
This is my problem.
Will ESP destroyed.
Dtasheet said the max voltage on any one pin id VCC+0.3 volts, meaning 3.3+0.3 = 3.6
But in my case, with no power on VIN should be 0+0.3= 0.3 volts, and not 3.3 volts.
What to do?

Re: Can i have power on GPIO - 3.3 volts, but no VIN or no power on 3.3 volts pin ?

Posted: Tue Mar 01, 2022 1:42 am
by ESP_Sprite
There's multiple options.

The 'nice' option that keeps you within datasheet specs is to feed the external power signal into e.g. a N-channel mosfet gate, with the source to ground. The drain will then be pulled down to ground if you have voltage on the external input. Route that to GPIO16 and enable the internal pullup on that pin.

The 'lazy' solution is to put a 33K (or so; anything 10K-100K will likely work) resistor between the external power and GPIO16. The ESD protection in the ESP32 will make sure that the voltage never goes above the limit and the resistor makes sure you don't supply enough current to actually power the ESP32.

Re: Can i have power on GPIO - 3.3 volts, but no VIN or no power on 3.3 volts pin ?

Posted: Tue Mar 01, 2022 2:21 am
by iongheorghe
Thank you for the suggestion.
Can you please make a hand drawing and post it.
What N mosfet you suggest.
What is the command to enable pull-up on GPIO16 ?
Please believe me, I am so new to that, and I need help.
Thank you very much.

Re: Can i have power on GPIO - 3.3 volts, but no VIN or no power on 3.3 volts pin ?

Posted: Tue Mar 01, 2022 6:21 am
by ESP_Sprite
Random sketch: (Note I added an 1K resistor from the gate to ground to make sure the 5v0 is actually 0V when not plugged in. You may or may not need that in practice, but probably better to include it anyway.)
sketch.jpg
sketch.jpg (222.44 KiB) Viewed 3620 times
For the mosfet, you can use any random logic-level N-channel mosfet. I tend to grab the AO3400, but that's mostly because I have oodles of them around. In your case, you might get away replacing this new mosfet and your existing mosfet T1 with a second IRF7317; that'll save on the amount of different components you need to buy.

Pull-up enabling depends on what SDK you use, for ESP-IDF, you'd use e.g. this.

Re: Can i have power on GPIO - 3.3 volts, but no VIN or no power on 3.3 volts pin ?

Posted: Tue Mar 01, 2022 7:42 am
by iongheorghe
Thank you for help.
I did try in my own to figure out and read about pull-up and I made a test on Proteus.
I found the hard way that I need a resistor on the gate, but it did work. See the pictures.
As mosfet I found BSS138, which on Proteus had a chip.
I will make the board and test it live.
Thanks again.

Re: Can i have power on GPIO - 3.3 volts, but no VIN or no power on 3.3 volts pin ?

Posted: Thu Mar 16, 2023 3:44 pm
by Ivanov_1959
You have a model for simulating ESP 32 in Proteus. Please share this model to me. Thank you very much. You can send by e-mail: dv-59@yandex.ru or give a download link.