I have an ESP8266, and a MCP23008 I2C GPIO expander.

The GPIO expander has the ability to trigger an interrupt when a pin changes - this is handy, as it means we can do something when an input pin changes (in my case, when a doorbell button is pressed or the door is opened and a reed switch activates).

The ESP8266 has 'deep-sleep' mode, which normally you wake from by the RTC activating the RESET pin by wiring the two pins together (through GPIO16). Sleep is probably an optimistic word, as actually it's more like shutting the chip down entirely - when you hit the RESET, you boot from scratch.

My thought was to hook up the INT output of the IO expander to the RESET pin - in order to wake from sleep when something happens. However, the INT pin remains active until the register is read - if I am holding the ESP8266 in reset, that'll never happen!

Would a valid solution that works with the vagaries of the ESP8266 be to make a basic one-shot MOSFET monostable circuit to fire when the INT pin is active?

  • \$\begingroup\$ if you want to wake on outside events, as opposed to a timer, you don't need gpio16, just pull RST low to reset, or use CP_PD, or an external VCC switcher. you can tie 16 to RST, wich will pull RST back up once the reset is underway since 16 is high during reset. \$\endgroup\$ – dandavis Jul 4 '17 at 9:10
  • \$\begingroup\$ Okay - so if I were to configure the INT pin to be active high, tie it to CP_PD - when the interrupt is enabled we power up the ESP. To go back "to sleep", we can read the INTF register, INT pin goes low and CP_PD is pulled low again. I'd be concerned that I don't know exactly when the INT pin goes low - if it's before the I2C read is finished then we would end up doing half a read before being turned off again, leaving it in an odd state \$\endgroup\$ – naxxfish Jul 4 '17 at 9:38
  • \$\begingroup\$ you could write the normally-low pin 4 or 5 to HIGH on boot, then write it LOW to power down. \$\endgroup\$ – dandavis Jul 4 '17 at 9:40
  • \$\begingroup\$ Actually looking at Microchip's AN1043 page 4 it looks like the INT pin is cleared when the read is completed. So that's not an issue! \$\endgroup\$ – naxxfish Jul 4 '17 at 9:41
  • \$\begingroup\$ In fact - the INT pin on the MCP23008 on power on is high, in Active-Low mode. If I were to hook that up via a diode to the CP_PD pin, and also a GPIO pin via another diode - I can make a very basic OR gate so that when I boot for the first time, I bring the GPIO pin high to keep CP_PD high - reconfigure the MCP23008 to be active-high (therefore making it low), then when I'm ready take the GPIO low to power down to remove volts from CP_PD and shut down. It also has the added benefit of "disabling" the interrupt whilst processing. \$\endgroup\$ – naxxfish Jul 5 '17 at 9:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.