Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By donbrew
#89745 Solved! I used this circuit with a "jiggle" sensor instead of the PIR and eliminating the transistor path to + and the diode.
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

Image
User avatar
By donbrew
#90126 Turns out that was not dependable. However, simpler is better.

signal from vibe sensor--------1K resistor----------- + 1 uF capacitor - ------------RST

I don't have the math, I don't think the values even matter. It does work reliably.
User avatar
By eriksl
#90144 That is a simple way, not necessarily the best, KISS is not always applicable. Keep in mind that a 1 uF and even the more usual 100 nF capacitor can store quite a bit of charge and especially ceramic capacitors can discharge very quickly, which can lead to major surge currents when switching, up to multiples Ampères. I am not an expert on this (analog electronics), but I'd say, connect the capacitor itself over a resistor to prevent this (if you didn't already do so).

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.