Electronic WiFi lock – App Android
Open gate or garage with mobile APP and Wemos D1 board
This system allows you to control up to 5 electrical devices via a mobile APP.
How it works and if suitable for your purposes is visible in the following video.
The program is divided into two parts. One part is the mobile APP, the other is the sketch for Arduino. In the sketch it is possible to define the writing above the buttons displayed on the mobile phone and their behavior; if they must become a simple ON-OFF button, or timed with a time of your choice. It becomes possible to send a 200ms impulse to the control unit that opens the garage or gate, or to keep a light on for tens of seconds.
Also on the sketch it is possible to define the behavior of the Wemos D1 card. You can choose between Access point with SSID of your choice to make it work autonomously, or to connect to your own WiFi network.
Since the card generates or connects to a WPA2 network, this becomes the level of security against intrusion. Therefore if you connect it to your WiFi network, do not disclose your password even to guests who ask for it. It should also be considered that any gate or door openings must be connected only to pins 4 or 5. This is because, at the circuit power supply (or at the reset of the Wemos board), the other pins emit an impulse that can make you find everything open after a simple blackout. Therefore reserve the relays not connected to pins 4 and 5 only for lights.
You can add an electronic circuit that inhibits the pulse on power … something I have not done because only two gates there lead with this project.
Define the keys of the APP
First set the number of keys you want to display from 1 to 5 in the HowButton variable. The APP, reading this value, will adapt the display as the following screens show:
Then for each button edit the contents of the variables. These contents are underlined in the following image. The values underlined in blue correspond to what is displayed on the keys by the APP. The green underlined values define the pins on which the button acts. Valid values are only 4, 5, 12, 13 and 14; or the usable pins of the Wemos D1 card. The values underlined in red are the relay activation times expressed in milliseconds. Setting 200 the relay will activate for 0.2 seconds, setting 30000 it will activate for 30 seconds, instead setting zero the button controls the relay in on-off mode.
The Color and HowShow variables respectively allow you to change the colors of the app from light to dark and to switch from an arrangement with the buttons one above the other, to a typical cross view to control a toy car (up, down, right, left…)
Use as ACCESS POINT or connect an existing ACCESS POINT.
To use it as an Access Point or connect it to an existing one, it is necessary to remove the // from one of the two sections visible in the following image. By removing the // with a blue background, the device connects to an access point. By removing those with a red background, the device becomes an access point. Note in the first case you must provide the SSID name and the password of the access point to connect to (instructions underlined in yellow), in the second case you have to baptize the name of the SSID and the password (instructions underlined in green). In the sketch only one of the two sections must be uncommented.
Note the following lines:
IPAddress ip(192, 168, 1, 233); // Address of Wemos D1. You don't have to change it. IPAddress dns(192, 168, 1, 1); // DNS IP. Usually the address of the router IPAddress gateway(192, 168, 1, 1); // Gateway IPAddress subnet(255, 255, 255, 0);
which, with the exception of the second row, are located in each of the two sections (see blue and red circled areas in the following figure).
These lines define network parameters that are valid for almost all cases. However, especially to connect to an Access Point, you may need to change them. In the case, on the APP, you must click on the top left to set the same IP address.
As long as the addresses defined on the APP and on the sketch do not match (or if the Wemos D1 card is off), the APP shows the following screen
Part one: the “Electronic_key” sketch for the Wemos D1 electronic board
This part is an Arduino sketch to be loaded on the Wemos D1 board. The sketch can be downloaded from the following link: Electronic_key_MyelectronicHomeSiteVersion.ino
Before uploading it to the Wemos D1 card, decide whether to use it as an access point or connect it to an existing access point and then modify the lines as described in the previous paragraph.
Part two: the “Electronic_key” APK to be loaded onto an Android phone
This part is an APK to be loaded on Android phone. It was created with MIT 2 APP Inventor. This program communicates with the Wemos D1 board. The board sends the texts to be shown on the individual keys and how to show them. At the moment the APK is not available in the Google Playstore, it can be downloaded only from this link: Electronic_key.apk
If you realize what is described on this page, send me an email (also anonymised) with your considerations.