1K resistor, 1uf capacitor, BC457 transistor (flip a 2n222 works).
Motion of door wakes D1 Mini, D1 waits 30 seconds then checks status of tilt sensor, evaluate battery sends email and text advising status. Goes back to ESP.deepSleep(0).
I figure 30 seconds is long enough for the door to get to either it's final position or just send a status of it's true position in case of a false rattle.
Using 5 18650 batteries in parallel with a DC-DC 5 V boost. That may change since I deleted the sensors that needed 5V
https://www.amazon.com/dp/B07S1WN977?ps ... ct_details
https://www.amazon.com/dp/B07YYY57ZM?ps ... ct_details
signal from vibe sensor------------------- - 1 uF capacitor + ------------RST
I don't have the math, I don't think the values even matter. It does work reliably.
A better way would be to use a debouncer, there are ready-made IC's for that purpose. They sample a signal and it needs to be e.g. 16 samples in asserted state (pullup -> pulled down) before the output is asserted and then it will keep the output asserted for some time, without glitches. These IC's are very cheap.
General rule of thumb is that you should never connect mechanical switches to GPIO's, especially when an interrupt is activated on the GPIO. Every mechanical switch produces way more glitches that you imagine during state change, if you have an interrupt connected, the will be called many many times before you even can suspend the interrupt, leading to crashes.