# Putting an ESP8266 to sleep via either of two signals

I've got a circuit which I'm hoping to use to shut down my ESP, except where an interrupt happens from an external chip (MCP23008 GPIO expander), or I have chosen to manually keep myself enabled.

Being a bit cheap, I wanted to do this using diodes - D1 is being fed from the interrupt line on the MCP23008, and D2 is being fed from another GPIO pin on the ESP. It seems that this works for keeping the pin held high (the ESP boots just fine on power up, when the INT pin is high by default, then I bring the GPIO pin high to keep it up), however when the interrupt pin goes low (I set it to Active-High mode), and I turn off the GPIO, the pin remains at 3.3V - even though the two sources on the other side of the diode are now at 0V. Clearly the capacitance on the input is retaining the charge and there's nowhere for it to go.

So I've put a 1K2 pull-down resistor in - however this doesn't seem to have quite the desired effect, and the pin sits at about 2.5V (3.3 - diode drop, more or less) and the CPU does not appear to run. I'm not sure if it's just because the pull-down is too strong.

What is the correct solution here, and can it be done with just diodes and/or MOSFETs (and passives)?

EDIT: this is a followup to ESP8266 Wake from deep sleep with an interrupt (not a duplicate as the question is different)

• You need to determine what is driving the signal high. Remove the diodes and try your pulldown on each of the two inputs and on CH_PD in turn, until you determine which results in a notably non-zero voltage across the resistor. Then figure out why. You may need to revise your overall plan. – Chris Stratton Jul 6 '17 at 22:06
• ESP has funky GPIOs: as you pull CH_PD low, some pins go high, but 4+5 don't. you shouldn't need the diodes if you use INPUT_PULLUP instead of OUTPUT +HIGH to float PH_PD in union with the active high external, unless it's not an open collector... – dandavis Jul 6 '17 at 22:13
• Worth mentioning that because the default setting of the interrupt pin is active low, low impedence out. It can be open collector if configured as such, but only after booting once to write the registers. So I have to make it function when the pin is driven high. – naxxfish Jul 7 '17 at 4:56
• Also this is pretty much exactly what I'm trying to do – naxxfish Jul 7 '17 at 6:01

If you want to use diodes for the OR gate you could consider Schottky diodes which have a lower forward voltage drop. If you were to aim for a 350 mV drop at 25°C you should restrict the current to 0.3 mA. $R = \frac {V}{I} = \frac {2.95}{0.3} = 10 \; kΩ$.