I'm hardly surprised, disconnecting the ground will almost certainly violate the maximum voltage and polarity ratings of the nodeMCU.
Consider that the DIO pin effectively becomes the ground (lowest potential) pin on the device while the supply is still present. You really need to switch the supply if you want to power it off but you are likely to run into a different problem, the time it takes from powering up to reading the switch.
Thanks, could you explain how switching the ground violates the maximum voltage and polarity ratings?
Also, I had tried using a P Channel mosfet, but the issue I had was the supply voltage is 9 volts, and the allowable DIO voltage is 5 volts. I couldn't figure out how to drop the voltage to the input pin without consuming power when the device was off. What do you mean "you are likely to run into a different problem, the time it takes from powering up to reading the switch" ?
Also, the push button's I'm using are rated at 150mA @ 24Volts DC. I think a simple solution would be to remove the Mosfet completely and use the pb as a high side switch to Vin on the NodeMCU. The pb inputs could then be pulled low when the corresponding button isn't pressed (while off/booting), and go high to 3.3 volts using the zener configuration (consuming no power while off). I measured the current consumption and it didn't go above 300 mA for the time it was turned on (stays on for 4 second intervals). I believe the current rating of the button is increased by lowering the voltage to 9 volts, but I'm not sure what the limit would be. The naive solution of maintaining the same power rating is incorrect. I've emailed the manufacturer for their input, but haven't heard anything back... Any idea how to determine that?
Thx.
Sean
- - - Updated - - -
Like below. Just not sure if the button is rated for 300mA @ 9VDC, the spec only says 150mA @ 24VDC ?
- - - Updated - - -
One thing I didn't try when using the P Channel Mosfet was connecting the input to the drain (via the 3.3v zener). I had it connected to the gate of the Mosfet.
Does anyone see an issue with this idea below?