logo elektroda
logo elektroda
X
logo elektroda

How do I connect a reed switch to the ESP8266 ESP01 to reset when a window is opened?

mienki 1563 2
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 17309071
    mienki
    Level 10  
    Welcome,


    I am trying to build a circuit to notify when a door/window is opened.

    I want the circuit to run on battery power.

    The general idea: ESP01? deep sleep, a reed switch and a magnet that when you move away (opening a door/window) resets the ESP and the program executes from the beginning.

    The problem is how to connect the reed switch so that it performs the reset when the window is opened.
    Opening the window (moving the magnet away) should reset the ESP, closing the window (moving the magnet closer) should reset the ESP again.


    The reset signal should be a short "peak"?, if I connect the reed switch to reset, it won't be a peak, it will be a continuous signal (on top of probably draining the battery?).

    I would appreciate your help in expanding the attached schematic.
    How do I connect a reed switch to the ESP8266 ESP01 to reset when a window is opened? .
  • ADVERTISEMENT
  • #2 17319011
    krzbor
    Level 27  
    It's not that simple. You have to build a circuit that generates a pulse every time the level changes, and an additional problem is the reed switch, which is constantly short-circuited when the window is closed. You have to pass current through the reed switch to detect a short circuit, and this again makes it difficult to use battery power. Perhaps what I am going to propose is overkill, but it is doable and will draw little current. I propose to use an ATTINA as the input circuit. This processor should wake up every 0.5s or so, apply power to the reed switch (via a 100k resistor), and measure the state on another input. The state should be compared with the value previously stored in EEPROM - if it is the same, the chip goes to sleep, if different it stores the new state in EEPROM and wakes up the ESP by changing the CH_PD state. The ESP should, after waking up, check the state of the reed switch (this state can be 'issued' on another ATTINY output) and send the appropriate message. Another ATTINY input should respond to the signal from the ESP that data sent and disable the ESP (CH_PD state change). In addition, a watchdog can be implemented on ATTINY - if after a certain time, e.g. 3 seconds, the ESP does not give information that the transmission has been completed, it can be switched off and try to send it again, e.g. in 10 seconds.
  • #3 17322676
    mienki
    Level 10  
    so no combination, e.g. of 2 reed switches or something similar will work?
ADVERTISEMENT