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

iongheorghe
Posts: 7
Joined: Fri Jan 17, 2020 3:53 pm

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

Postby iongheorghe » Sun Feb 27, 2022 4:42 pm

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.

ESP_Sprite
Posts: 9770
Joined: Thu Nov 26, 2015 4:08 am

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

Postby ESP_Sprite » Mon Feb 28, 2022 12:59 am

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.

iongheorghe
Posts: 7
Joined: Fri Jan 17, 2020 3:53 pm

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

Postby iongheorghe » Mon Feb 28, 2022 2:51 am

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?
Attachments
Power.png
Power.png (55.52 KiB) Viewed 4176 times
ON-OFF.png
ON-OFF.png (48.58 KiB) Viewed 4176 times

ESP_Sprite
Posts: 9770
Joined: Thu Nov 26, 2015 4:08 am

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

Postby ESP_Sprite » Tue Mar 01, 2022 1:42 am

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.

iongheorghe
Posts: 7
Joined: Fri Jan 17, 2020 3:53 pm

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

Postby iongheorghe » Tue Mar 01, 2022 2:21 am

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.
Attachments
And gate.png
And gate.png (26.62 KiB) Viewed 4081 times

ESP_Sprite
Posts: 9770
Joined: Thu Nov 26, 2015 4:08 am

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

Postby ESP_Sprite » Tue Mar 01, 2022 6:21 am

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 4043 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.

iongheorghe
Posts: 7
Joined: Fri Jan 17, 2020 3:53 pm

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

Postby iongheorghe » Tue Mar 01, 2022 7:42 am

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.
Attachments
No_Ext_Power.png
No_Ext_Power.png (35.73 KiB) Viewed 4013 times
With_Ext_Power.png
With_Ext_Power.png (33.5 KiB) Viewed 4013 times
GPIO16.png
GPIO16.png (16.17 KiB) Viewed 4013 times

Ivanov_1959
Posts: 1
Joined: Thu Mar 16, 2023 3:28 pm

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

Postby Ivanov_1959 » Thu Mar 16, 2023 3:44 pm

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.

Who is online

Users browsing this forum: No registered users and 67 guests