Saturday, 5 April 2014

power - Circuit to turn microcontroller on when reed switch state changes (to monitor door lock state)


I'd like to build a circuit that provides power to a microcontroller (ESP8266 in this instance) when a reed switch is changed from closed to open AND when changed from open to closed.


This is to be used in a circuit that will monitor the state of a deadbolt lock. I'm planning on attaching a magnet to the end of the bolt and putting a reed switch inside the strike box with enamelled wire running out to the ESP8266 that will be discreetly mounted on the wall nearby. The circuit will run on batteries as running power to the lock location is not practical (nor will it have a high enough WAF to get approval).


When the lock is closed it will open the reed switch and when it is open it will close the reed switch (or the other way around, I'm not fussed whether the reed switch is NO or NC).


When someone locks the lock I'd like the circuit to provide power to the ESP8266 so it can connect to wifi and send a message to the automation server recording that the lock was closed and then power itself down (ideally to a zero current draw state).


Then when someone unlocks the lock I'd like the same thing to happen, albeit that the message will be different, but I'll handle that in code, obviously.


I've researched soft latching power circuits but they only seem to work when momentary switches are pressed. Here's an example from EEVBlog:


https://www.youtube.com/watch?v=Foc9R0dC2iI



Here are another two examples of similar one-sided circuits:


https://randomnerdtutorials.com/latching-power-switch-circuit-auto-power-off-circuit-esp32-esp8266-arduino/


https://www.instructables.com/id/LEIDS-Low-Energy-IOT-Door-Sensor/


This is a similar question but seems to rely on there being constant power available at the lock location so not good for my application:


How to create a locked door detector?


This also seems to be asking a similar question but I can't fathom the answer (and there isn't a final diagram showing how the XOR gate is hooked up to the switch and the microcontroller):


I need a switch that not only detects open/close, but also sends a pulse to wake up an ESP8266 whenever the (debounced) state changes


I've also though about maybe having the ESP8266 in a deepsleep-wake cycle every 5 mins or so and just reporting the state of the reed switch but this would mean the batteries only last a few months and I'd like it to last much longer (>1 yr). The other problem with that approach is that I may have to wait up to 5 mins to know whether the lock is open or closed - often I drive away from the house and within 1 or 2 minutes want to check if I locked the lock on the way out so being able to check instantly would be very helpful.


I also wonder if it could be done using two reed switches, one NO and one NC to somehow trigger the system...?


Any help would be greatly appreciated, even if it's to say that I'm asking the impossible!





No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...