I would like to measure the battery usage of my ESP32 device. As my device runs in deep sleep mode 99% of the time, it's important that the battery monitoring circuit does not add too much to the current usage while the device is asleep (I will only check battery level during the once a week that the device will be switched on).
I have followed this guide which describes a low power battery usage circuit using a p-channel mosfet to allow current through the voltage divider only when a digital IO pin is turned on.
I have attempted to simulate this circuit here, however it does not behave as expected. When I switch the digital IO to HIGH, the p-channel gate is not opened. If I replace the capacitor with a wire, it seems that the circuit at least switches on and off, but it seems there is probably an important reason for including the capacitor here.
Is there something wrong with the circuit shown in this guide? Is there something wrong with my simulation of the circuit?
(Note: I've also successfully simulated the circuit given in this answer but I prefer the jeelabs.org version simply because it uses fewer components. This question is to find out whether it will work for me.)