The MOSFET... can be safely removed. You can drive your Pullup directly from a microcontroller output pin instead of using a FET. The load doesn't draw enough current to justify an external FET.
You can also use an internal pullup (switched on/off) instead of an external one, saving a pin.
Making R1 higher will provide better protection against EMI, ESD, etc.
BAT54 has about 0.5-1µA leakage at your low voltage . Decide if this is bad for your battery life. If so, use standard diode (not Schottky). Thanks to R4, current which can flow into input pin is quite limited anyway.
1Mohm pullup makes me uneasy. Slight humidity along the wires would be sufficient to leak a few µA, making your micro believe the switch is closed.
Also, 1Mohm * 10nF will need a long time to settle. If you really want to conserve power, you'll need to put the micro back to sleep while you wait for it to settle...
Here's my proposal.
The amount of charge you'll consume is what is needed to charge C2 up to a voltage which the micro reliably reads as a "1", let's say 3V * 10nF = 30nC.
Here's my solution:
- Remove MOSFET, remove R7
- R1 = 1k
- Set C2 to 1nF, and put it in parallel with the diodes for better EMI filtering
- Replace R5 with 33nF capacitor
- Set SW_EN as output, driven to GND
To query the sensor:
- Set SW_EN to HIGH. This allows the 33nF cap to send a pulse into the cable, and charge C2. If the switch is open, C2 will charge to 90% VCC. If it is closed, its voltage will quickly decay back to 0V.
- Wait 500µs (TBD)
- Check GPIO_IN
- Set SW_EN to LOW
- Go to sleep
This consumes 100nC on each check (charge in the 33nF cap under 3V), so if you check 10 times per second, it is 1µA.
The current sent through the cable will be quite high (a few mA). This should be enough to overcome any leakage due to moisture.
You can also use a resistor instead of a 33n capacitor, but then you'll need to compromise on the input protection resistors.