Using D5 to wake from sleep on an Electron

I have received a code handover and was just reviewing and found something strange. Pin D5 is configured as pull-down and interrupt on rising edge. The device uses pin D5 to wake from System.sleep(). However, in the System.sleep() API reference (Here) it says D5 cannot be used as a wake from sleep pin on the Electron ( D1- D4 are). However, the device runs perfectly fine and is able to wake whenever 3.3V is applied to D5. How is this working?

Also, when I change D5 to be pull-down with interrupt on changing edge, the device perfroms the interrupt fine while it is awake. However as soon as the device calls System.sleep() the interrupt is triggered then will not trigger again while sleeping. This points to D5 becoming a floating/pull-up pin when in sleep mode, but then how is the original setup of pull-down and rising edge interrupt working?

Edit: am using an E310 Module

I’m pretty sure there is no restriction on using D5. The list in the classic sleep section seems to be wrong, however the new sleep API documentation defers to attachInterrupt and that indicates that D5 is fine on the Electron.

The reason CHANGE interrupts aren’t working for you is that you can’t combine change and pull. Basically, the pull is removed if you go into sleep mode. You’ll need to use an external pull resistor with CHANGE.

You can only wake on INPUT_PULLDOWN + RISING or INPUT_PULLUP + FALLING using the internal pull resistors.

1 Like

thank you very much, does it state somewhere in the datasheet on how you cant combine change and pull up/down?

It’s in the sleep documentation, but not in the classic API sleep documentation.