DIY

Deep Sleep Wireless Alarm

Wireless deep sleep alarm The purpose of the manufacture of this device is to make an alarm about which position (closed or open) to be garage door. The difficulty lies in the fact that there is no electricity in the garage and it is problematic to conduct it there.
The foreman decided to do this project because he forgot several times that he had left the garage door open.
He decided to use the ESP8266 ESP-01 Wi-Fi module because of its low cost and the ability to enter a low power deep sleep mode when not in use. Since the garage door is not opened/closed very often, putting the module into sleep mode makes the circuit ideal for battery power.
Tools and materials:
-ESP8266 ESP-01 Wi-Fi module;
– * J1 – 2-pin male connector 2.54 mm;
– * J2 – 3-pin male connector 2.54 mm;
– * J3 – 8-pin socket 2×4 mm, 2.54 mm;
– * R1 and R4 – resistor, 10 kΩ, 1/4 W;
– * R2 and R3 – resistor, 1 megabyte, 1/4 W;
– * C1 and C2 – electrolytic capacitor, 2.2 μF;
– * Q1 – N-channel field-effect transistor 2N7000;
– * S1 – Reed switch with a magnetic contact with normally open and normally closed contacts or limit microswitch with normally open and normally closed contacts;
– * B1 – AAA battery holder;
– AAA battery, 1.5 V – 2 pcs;
-Custom PCB;
-Wires;
Receiver Unit Parts List
-ESP8266 ESP-01 Wi-Fi Module;
– * J1 – 2-pin 2.54mm male connector;
– * J2 – 8-pin female 2×4 mm, 2.54 mm;
– * D1 – RGB LED;
– * R1 – Resistor, 4.7 kΩ, 1/4 W;
– * PS1 – AC adapter, 3 VDC, 100 mA;
-Custom PCB;
General Tool
-Computer;
-ESP-01 Programmer Adapter UART;
-Soldering iron with a fine tip; -Nippers; -Pliers;
* – Designation on the diagram
Step one: the principle of operation
There are a number of published projects in the public domain that use the ESP-01 deep sleep mode. But they only emit a wake-up signal when the switch is opened or closed. Or, additional circuitry was required to generate a wake-up signal, and this additional circuitry continued to drain the batteries even when the ESP-01 module was in deep sleep mode. The goal of this guide is to make a circuit that solves this problem with passive components that draw very little current.
Putting the ESP-01 into low power deep sleep is quite simple and requires only a few lines of code in software. However, there is a problem with the activation of the module when the door position switch is opened or closed. To wake the module out of deep sleep, a high-low-low-high (logic) pulse must be applied to the RESET pin of the module. The solution was to use RC circuits (resistor, capacitor) and an SPDT switch with a set of normally open (NO) and normally closed (NC) contacts to generate a reset pulse whenever the switch state changes.
How the reset circuit works:
(See transmitter wiring diagram) Assume switch S1 is in the normally closed (NC) position. In this position, the capacitor C1 is charged through the resistor R1, and this positive voltage is displayed on the RESET pin of the Wi-Fi ESP-01 module as a logic signal (high). Resistor R2 on C1 is so high (1 MΩ) compared to R1 (10 kΩ) that it has little effect on charge. When the switch is in this position, capacitor C2 is an open circuit, causing any charge in C2 to be discharged to 0 (zero) volts through resistor R3. When switch S1 is in the normally open (NO) position, positive current is supplied to capacitor C2 through R1. When C2 starts charging, the voltage across C2 slowly increases from 0 to 3 volts in about 0.5 seconds (RC time constant = 0.22 seconds). This rise from 0 to 3 volts is observed at the RESET pin of the ESP-01 Wi-Fi module and is interpreted as a reset signal that wakes up the module. Meanwhile, since C1 is no longer connected to the current source, it slowly discharges to zero volts through R2. When the S1 switch changes state again, the whole process repeats, again sending a reset signal to the module.
Using a Field Effect Transistor (FET):
Field Effect Transistor (FET) Q1 is used to reflect the voltage state of the normally open (NO) switch circuit, which is applied to the Rx input pin of the ESP-01. The module software reads the Rx input to determine the position of the switch. A field-effect transistor was used in the circuit, because, unlike a conventional transistor, its input (gate) does not consume current and does not affect the RC circuit. In addition, the source/drain circuit connected to the Rx pin of the module will not receive power when the module is in deep sleep, and thus does not consume power. The Rx pin is used instead of GPIO0 or GPIO2 to read the state of a switch.
General operation description:
The ESP8266 ESP-01 Wi-Fi module used in the receiving device has been programmed to act as an “access point” (that is, a server) using User Protocol (UDP), and the Wi-Fi module used in the transmitting device has been programmed to work as a “Client” also using UDP. Please note that this Wi-Fi system is standalone and does not require an internet connection or access to your home computer network or router/server. When the door position switch changes state, the transmitting device (client) wakes up, establishes communication with the receiving device, and sends the state of the switch to the receiving device. Upon receiving the switch state, the receiving device will either turn on the red LED (door open) or green LED (door closed) and send a confirmation message back to the sending device, informing it that the message has been received. After receiving the acknowledgment message, the sending device will remain awake for another 1 second and then enter sleep mode. If no acknowledgment message is received within 1 second, the sending block will try to send the switch state again. If after 10 seconds the confirmation message is still not received, the transmitting device will refuse to transmit and enter sleep mode to conserve battery life.
Testing the circuit showed that the entire circuit consumes less than 18 μA in deep sleep mode. Assuming a 1200mAh battery is used, the battery life can be expected to exceed 2 years.
The attached picture shows the entire system before the transmitter unit (left) was installed on the garage door and the receiver unit (right ) was packed in a small box for installation in another room of the house.
< img class = "aligncenter" alt = "Wireless deep sleep alarm" src = "https://usamodelkina.ru/uploads/posts/2021-07/1625166180_1-1.jpg"/> Wireless deep sleep alarm  Wireless deep sleep alarm Step two: printed circuit boards
Unfortunately, the wizard did not provide the files for making the board for free access and they need to be ordered at a special service. Considering the low cost, it is not that expensive.
The master ordered the boards on the website oshpark.com
Go to the site and click the LOGIN icon to create an account and log in.
Then click “SHARING”, to open the “Shared Projects” page.
In the search field, enter the email address: [email protected]
Press the button “Load projects”. The following two projects should be displayed:
ESP-01_Wireless_Indicator.kicad_pcb
ESP-01_Wireless_Switch.kicad_pcb
For each of the two boards, hover over the Actions button and select Oder Board.
Follow the instructions on the screen to complete the checkout process.
Wireless alarm with deep sleep mode Step three : PCB Assembly
After receiving the PCBs from the manufacturer, install the components listed in the parts list using the schematic. Make sure you install the correct resistors in their designated locations. In addition, capacitors C1 and C2 are polarized, so they need to be oriented correctly.
If using a breadboard PCB, locate and install the components listed in the parts list using the illustration and circuit diagrams as a guide. Solder the components in place. Then use a wire to connect the components using the diagrams as a guide.
Wireless deep sleep alarm Step Four: Programming ESP8266 ESP-01 Modules
Download and install the Arduino IDE on your computer. After installing the Arduino IDE, you must also install the ESP8266 board package so that the Arduino IDE can recognize and program them.
Next, create two subfolders in the Arduino folder named WirelessSwitch_Client and WirelessSwitch_Server. The Arduino folder is created during installation, usually in the Documents folder.
Download the WirelessSwitch_Client.ino file and paste it into the WirelessSwitch_Client folder created in the previous step.
Download the WirelessSwitch_Server.ino file and paste it into the WirelessSwitch_Server folder created in the previous step.
Install one of the ESP8266 ESP-01 modules into ESP01 programmer UART adapter.
Connect the ESP01 programmer adapter module to the PC USB port.
Double-click the WirelessSwitch_Client.ino file to run the file and invoke the Arduino IDE. The Arduino IDE window displays with a list of WirelessSwitch_Client source code.
In the drop-down menu “Tools/Board” select the universal module ESP8266.
Select the drop-down menu “Tools/Port” to select/check the choice of the COM port (for example, COM1, COM2, etc.).
Select “→” (download) to start the compilation and download process. The program will be compiled and automatically loaded into the ESP-01 module. When the upload is complete, the message “Done Uploading” will be displayed in the lower left corner of the IDE window. The following text will be displayed at the bottom of the IDE message box: “Leaving …” & amp; “Hard reset via RTS pin …”
Disconnect the ESP8266 ESP-01 module from the ESP01 programmer adapter and define it as “Client”.
Next, program the ESP8266 server
Install the second ESP8266 ESP-01 module into the UART adapter ESP01 programmer.
Connect the ESP01 programmer adapter module to the PC USB port.
Double click the WirelessSwitch_Server.ino file to run the file in the Arduino IDE. The Arduino IDE window is displayed with a list of ESP8266_WirelessSwitch_Server source code.
In the drop-down menu “Tools/Board '” select the universal module ESP8266.
Select the drop-down menu “Tools/Port” to select/check the choice of the COM port (for example, COM1, COM2, etc.).
Select “→” (download) to start the compilation and download process. The program will be compiled and automatically loaded into the ESP-01 module. When the upload is complete, the message “Done Uploading” will be displayed in the lower left corner of the IDE window. The following text will be displayed at the bottom of the IDE message box: “Leaving …” & amp; “Hard reset via RTS pin …”
Disconnect the ESP01 programmer adapter from the USB port, remove the ESP8266 ESP-01 module from the ESP01 programmer adapter and define it as a “server”.
After the modules have been programmed, they are ready to connect to the appropriate motherboards for use.
You're done. Below you can download a video file that demonstrates the operation of the device.
ESP8266 ESP-01 Wireless Switch With Deep Sleep Mode

Source:

usamodelkina.ru

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button