- Sun Nov 29, 2020 4:55 pm
Yep, it's do-able with a single D1 Mini and one tilt switch: https://electronics.stackexchange.com/q ... e-detector
You'll also need to wire the tilt switch into a GPIO so you can see whether the door is currently open or closed when the CPU wakes up. The circuit above just generates the /RST pulse when the state changes (the door opens or closes). I'd have used a reed switch, as they're probably more reliable long-term than 5 cent tilt sensors are, but that's just me. Lord only knows what the contact bounce time of those tilt switches is. A reed switch is typically less than 50ms, so the sequence is:
<door changes state>
reset pulse generated on either direction
D1 mini wakes, makes WiFi connection
<switch has stopped bouncing, so read the GPIO to see whether it's open or closed>
transmit the current open/closed status
go back to sleep
I'm guessing your parts are all through hole, so you need through hole / leaded parts and not SMD. A single CMOS 4030B would do you fine. The circuits linked above generate a brief HIGH pulse, so you'd need to use one gate of the XOR to invert the output to a brief LOW pulse. The old 4000 series is a heck of a lot lower quiescent current than the 74HC86 is. edit: there are low current 74HC86, but all I find are SO or smaller ICs.
A larger issue is that the D1 Mini isn't battery-friendly. It'll draw 5 to 10mA continuous when it's asleep due to the LDO and USB chips, then jump up to 80mA when it's on to send the event notice. That 5 to 10mA will eat batteries pretty quickly. A bare ESP-12F module and a couple of AAA batteries (one alkaline + 1 lithium) would power it for years. Alkalines run ~ 1.45V new, lithiums ~1.8V, so 3.25V total, safely within the 2.8 to 3.6V input of the ESP-12F without needing an LDO. If I'm brain-damaged on that bar napkin power calculation I expect someone will correct me.
Last edited by StanJ on Mon Nov 30, 2020 6:06 pm, edited 1 time in total.