Low power battery voltage monitor
The issue with the circuit you have given us, is in order to turn on the MOSFET the capacitor needs to initially be discharged. That is, the right side of the cap needs to be at, or close to, the same voltage as the gate.

Now there really is only one way to make that happen, that is, turn on the output pin in the high state and wait long enough for the charge on the capacitor to equalize, then set the pin low and take your measurement.

After that, either set the pin high again and leave it as an output, or turn off the pin and repeat the whole process again next time.

Adding a discharge path would be better as shown below, but it does add the leakage current of R5 through the GPIO back in.

However: Please be aware, the GPIO needs to be able to handle the full battery voltage on it in these circuits. The PNP in the linked answer, which in my opinion is a much better solution, provides you with the isolation you probably need. Though I might have switched the BC547 NPN for a small signal MOSFET.







simulate this circuit &ndash; Schematic created using CircuitLab