I'm trying to use a Wemos D1 mini as a smart button that will boot up, perform a task, and then shut back down. I'd like to do this as a true power off as opposed to any sort of sleep mode.

I'm hoping I can do something similar to this post https://www.esp8266.com/viewtopic.php?f=11&t=4458

  1. Tie RST pin to a Low GPIO pin so that it doesn't boot
  2. Push a button that will run 3.3v to RST pin to make it go high and cause a boot up
  3. Flip the GPIO pin that is tied to RST to high so that it stays running when button is no longer pressed
  4. Run some code and flip GPIO back to LOW shutting down

Things I've tried:

  1. Tie to GPIO15 (D8) - This stops the boot and starts booting when button is pressed but never finishes booting up. I'm assuming I am causing D8 to go high by pressing my button and interfering with the boot, but honestly not sure

  2. Tie to GPIO4 or 5 (D2, D1). This doesn't prevent boot.

  3. I've also tried #2 with a pull down resistor on the GPIO pin, but that doesn't seem to work either

Any help would be much appreciated.

  • reset button is HIGH and connecting it to ground executes reset
    – Juraj
    Sep 6, 2019 at 5:14
  • how do you plan to turn off the USB chip on Wemos D1?
    – Juraj
    Sep 6, 2019 at 8:59

3 Answers 3


To do this you would usually use MOSFETs to control the power.

Take the following circuit, for example:


simulate this circuit – Schematic created using CircuitLab

M1 is normally off, having its gate pulled up by R1.

Pressing SW1 pulls the gate of M1 low, allowing current to flow through it to power the D1.

The D1 boots up, and immediately drives the GPIO high.

This then turns on M2 (which is normally off, having the gate pulled down by R2), which in turn pulls the gate of M1 low.

SW1 can now be released since M2 is doing the same job.

To turn off, simply drive the GPIO low, or allow it to float as an input, in which case R2 will turn off M2, which then turns off M1, which stops the current flowing.


Try using D8, also follow this for selecting your pins to make sure the code runs as it is attended to work

enter image description here

  • D8 (io 15) must be LOW at boot
    – Juraj
    Sep 6, 2019 at 6:59
  • Would a diode between my button and D8 maybe fix the problem with it getting pushed high?
    – bingles
    Sep 6, 2019 at 19:50

as far as I know, it's not possible [the way as simple as you said]. here's some notes :

  1. after a reset, GPIOs are set as inputs. if you connect a GPIO to RST and make it low, it resets the chip, but immediately sets the GPIOs as inputs and the RST is released.
  2. if you don't use appropriate resistors, you'll burn the GPIO driver by connecting an output GPIO to a supply line. e.g. when you are trying to connect 3.3v to RST and LOW GPIO which is holding RST down.
  3. sleep modes are very efficient. many times, the battery self discharge is much higher than an slept MCU
  4. if you insist, turn the chip off by cutting off it's supply using an external circuitry. a 555 with a mosfet without any res,cap will do the jb (using only it's internal flip flop)
  • reset pin has a pull-up so a pin in input mode will nott pull it LOW
    – Juraj
    Sep 6, 2019 at 8:18
  • @Juraj that's exactly what I assumed. he wanted a GPIO to keep reset LOW. but I said it's not possible because as soon as chip resets, the GPIO is input and the reset is released. it boots up Sep 6, 2019 at 8:50
  • sorry, yes, you are right
    – Juraj
    Sep 6, 2019 at 8:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.