I'm trying to build a simple IOT push-button with the ESP-01. My goal is to have it powered by 2 coin-cell batteries (3v), so I want it to power up when I push the button, and then power itself down.
I was advised on reddit to use a P-channel mosfet to allow the ESP to power itself by holding the gate low via a GPI0 pin, then setting it high to power it down. I'm struggling to get this working. I have it wired up like so:
But as soon as I release the button, the ESP shuts off immediately (it doesn't seem to draw any power through the mosfet). I tested my code by hooking ESP's 3v3 pin directly to battery+, and used a voltmeter to measure at the mosfet's drain pin. When it boots up, the voltmeter almost immediately reads ~3.3v, my code makes a successful HTTP request, and then voltmeter drops ~0v, as expected.
However, when I wire the ESP's 3v3 pin back where the voltmeter was (on the drain pin), the ESP shuts off as soon as I release the button.
What am I missing? I've seen other schematics for "soft-latching" circuits that include an additional NPN transistor, but I'm not sure whether or not that applies to my situation.