Taking into account the expensive prices of some electric
locks and the insecurity of
some traditional key-locks, i thought about.. why do not make a affordable version of an
electric lock?
The intention is to use it for student access control and to register inputs and outputs
using RFID access control, I still don't know what components I should use, but that's
why I'm here to learn from experienced people.
I do not know how to ensure that the traditional lock can become an electronic lock,
there are many types of electronic locks on the market, but the idea is that anyone
who has access to a fablab can improve their lock.
Innovation object
The first idea is to remove the mechanism that allows the
piece to move to open or close
the door.
Change mechanical parts for electronic devices
So i did a little draw of how I am planning to modify the
lock
I am planning to replace the lock's cylinder with a DC motor that is going to be
triggered by a microcontroller by using some type of RF tech, probably is going to be
RFID
So then, I ended up with a list of component that I will be using for testing
DC motor (maybe a stepper motor)
RFID reader
RFID cards
A lock (obviously)
The intention is to use it for student access control and to register inputs and outputs
using
RFID access control, I still don't know what components I should use, but that's why I'm
here to
learn from experienced people.
I am inspired by so many projects that have been created around the world under the
direction of fablabfoundation and that I can be part of it
I have several ideas but as I have never created anything related to the invention or
innovation of things, I prefer to go slowly, maybe my project idea is not as good as others,
but I
want to explore and know other projects, everything will be based on the facilities
presented to
me to achieve a good final product.
The lock is composed of a mechanism that turns the key to open or close.
1. This component will be removed and
replaced with a 3d print, as it is seen to be
somewhat large, it will not have the slot to insert the key.
2. This component will be manufactured with a gear or a lever so that
when the servo
motor is operated with the RFDI card, it can open or close.
3. This component will be eliminated and will no longer be required for
the
operation of the lock, a base will be placed inside the lock base to fix the
electronic circuit and the servomotor. See Applications and
implications
My idea is to use the lock to control the attendance of students at the Macuspana
Higher Technological Institute where I am currently a teacher, which is why I have
considered using ESP-12F WiFi module is developed by Ai-thinker Team. core processor
ESP8266 in smaller sizes of the module
encapsulates Tensilica L106 integrates industry-leading ultra low power 32-bit MCU
micro, with the 16-bit short mode, Clock speed support 80 MHz, 160 MHz, supports the
RTOS, integrated Wi-Fi MAC/BB/RF/PA/LNA, on-board antenna.
The module supports standard IEEE802.11 b/g/n agreement, complete TCP/IP protocol
stack.
This will allow connection to the network so that the information is saved in a
database.
After seeing all the complications that have been generated as a result of the coronavirus
(COVID-19) and as a way to prevent people from having contact with access doors, I decided
to change the project to contribute in some way to reduce that contact between people.
Starting from the initial idea of the lock, with opening controlled by RFID, the design is
rethought in such a way that it can work by an app used ESP32, this is to avoid that access
is always available, which is why the following are included components.
Quantity
Component
Description
1
ESP32 WDROM SMD
wifii development chip
1
Module RC522 RFID NFC
Reader and Writer NFC Module RC522
1
Electronic door panel
powered by 12V DCC
1
Amplifier MT3608
Step Up DC / DC
2
diffuse 5mm LEDs
1
Transistor BD135
NPN
1
CH340C
Serial a TTL comunication
1
Mini USB female SMD connector
2
J3Y
NPN Transistor SMD SOT-323
2
GF1
Diode SMD
2
0.1uF Capacitor
25v maximum SMD
5
10k 1206 SMD
Thin film resistance
1
Conector JST 2pin
To connect lithium battery
2
SWITCH_SKQMBBE10
push button
1
BATTERY-CHARGER-LI-PROT
lithium battery charger
1
LM1117
3.3v Linear voltage regulator
2
PINHD-1X2/LONG
Male header
1
220 Ohm
Thin film resistance
2
10uF capacitor deramido SMD
WCAP-CSGP_0805-WAVE
2
LED-0805 diferente color
SMD 0805
1
PINHD-1X7/LONG
Male header
1
Phenolic plate 10x10 cm
Fiberglass as a base
Components.
To begin with, you have to perform the functional tests of the components.
The open-source Arduino Software (IDE) makes it easy to write
code and upload it to the
board. This software can be used with any Arduino board.
As I am using arduino to perform the tests, it is necessary to download the library to be
able to use the RFDI module (MFRC522).
To add the library Go to the Tools menu and select "Manage Libraries", a window appears, in
the text box, you have to write the name of the library or 522, a list appears, now you have
to install the one that corresponds to MFRC522.
To do the control test, in the "File" menu, select "Examples", then "MFRC522" and finally
click on "AccessControl".
For arduino to recognize the board, the library must be installed.
In the "File" menu select preferences and write the following link:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
In the "Tools" menu select plate and click on "Card manager"
Write esp32 in the text box and install.
Now you have to select the NodeMCU-32S board.
ESP-32S is a powerful, generic WiFi-BT-BLE MCU module that targets a wide variety of
applications
ranging from low power sensor networks to the most demanding tasks such as voice encoding,
music streaming and MP3 decoding.
Touch Sensor: The ESP32 comes with 10 capacitive touch sensors connected to GPIO pins-
Touch0 (GPIO4)
Touch1 (GPIO0)
Touch2 (GPIO2)
Touch3 (GPIO15)
Touch4 (GPIO13)
Touch5 (GPIO12)
Touch6 (GPIO14)
Touch7 (GPIO27)
Touch8 (GPIO33)
Touch9 (GPIO32)
These GPIO pins can sense variations if it touches anything that conducts electricity like
the human skin. So, when we touch the GPIO pin with our finger it generates this variation
that is read by the sensor. We can use the touchRead(GPIO) function to read the value from
the touch sensor.
KEY FEATURES OF ESP32-S DEVELOPMENT BOARD:
Microcontroller: Xtensa LX6 32-bit
Clock Speed: 160MHz
USB Converter: CP2102
USB Connector: Micro USB
Flash Memory: 4 MB
RAM: 512Kb
Digital I/O: 32 (26 usable)
PWM: 16 channels
Analog Outputs: 2 channels, 8-bit
Analog Inputs: 16 channels, 12-bit
Communications: 3 Serial, 4 SPI, 2 I2C, CAN bus, I2S Stereo
Integrated Sensors: IR remote, Hall sensor, temperature sensor, touch sensors, pulse
counter
Bluetooth: 4.2 and BLE (Bluetooth Low Energy)
WiFi: Built-in 802.11 b/g/n 2.4GHz
Buttons: EN (Reset) and IO0 (Boot)
Programming: Compatible with Arduino IDE
Pin Spacing: 0.1″ centers. Breadboard compatible
Operating Voltage: 3.3V internal power and I/O. 5V-9V external power with on-board
regulator
The project consists of creating a form that allows people to open the door without having
to use a key.
For this, a mechanism is required that when using a mobile application as the first way to
open the lock, but since we are always exposed to the failure of the Wi-Fi communication,
there is the second way to open the door using RFID (radio Frequency
Identification (RFID)
tags or transponders are small devices that utilize low-power radio waves to receive, store,
and transmit data to nearby readers. RFID tags are comprised of the following main
components: a microchip or integrated circuit (IC), an antenna, and a substrate or
protective material layer that holds all the components together. ), it consists of bringing
a card to the module and allows to open the lock.
A solenoid is used for access control.
It has a shaft with a dedicated slanted cutout for sliding with a door. It is basically an
electronic lock designed for a cabinet, a door, a lock, etc. The latch is normally extended,
so when you apply power to it, it opens the door.
To connect a solenoid you need a power transistor and a diode. It is recommended to use a
power supply that can provide 500 mA.
Characteristics
Operating voltage: 12VDC (It can work from 9VDC, but it will cause slower operation and
weaker movement).
Consumption current: 650 mA at 12 VDC and 500 mA at 9 VDC.
Designed for an activation time of 1 to 10 seconds.
Measurements: 5.5 cm long x 2.2 cm wide.
Base measurements: 3.8 cm wide and 5.5 cm long.
Electronic design
Schematic design of the circuit.
Library used.
Making adjustments to the layer.
Once the plate design is finished, it must be exported as a png image.
First it is done with the traces.
After with lines (outside).
It is important to remember the resolution, because when you use for when you use fabmodules, you can see that data there, in this case it is
1500 dpi.
To carry out this task I chose the design hello.USB-UPDI.FT230X board components traces
interior, I downloaded the image USB-FT230XS-UPDI.traces.png
lines.png
outlines.png
Now with the help of fabmodules.org, the loading process is performed to calculate the
values for the trace.
Remember to verify that the dpi value is the same that was given when exporting the png
image in Eagle.
Select the output format.
Select the process.
Check the parameters marked in red.
Preview of the trace.
The procedure for cutting the line is repeated.
Check the parameters.
Preview of the line.
Preview of the line.
Card ready to solder the components
Esp32 integrated to the card
Finally, the electronic components are integrated to the board, the soldering process of
each component is slow and requires patience, at least in my case.
For programming, the following code was used using arduino as programmer.
#include
#include
#include
#include
#include
#include
#include
#include
const char* ssid = "The_Hublab";
const char* password = "makers702010";
char auth[] = "vqZISRPIFyPPLAn85uknW0f541_uPjbC";
#define entrada 26
#define RST_PIN 22 //Pin 22 para el reset del RC522
#define SS_PIN 21 //Pin 21 para el SS (SDA) del RC522
#define seguro 27 /// pin chapa de puerta electronica
#define ledabrir 14 // led indicador de estado abierto
#define falso 12 // led indicador de tarjeta erronea
MFRC522 mfrc522(SS_PIN, RST_PIN); ///Creamos el objeto para el RC522
void setup() {
SPI.begin(); //Iniciamos el Bus SPI
mfrc522.PCD_Init(); // Iniciamos el MFRC522
Serial.begin(115200);
Serial.println("Booting");
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Blynk.begin(auth, ssid, password);
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("Connection Failed! Rebooting...");
delay(5000);
ESP.restart();
}
ArduinoOTA
.onStart([]() {
String type;
if (ArduinoOTA.getCommand() == U_FLASH)
type = "sketch";
else
type = "filesystem";
Serial.println("Start updating " + type);
})
.onEnd([]() {
Serial.println("\nEnd");
})
.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
})
.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error);
if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
else if (error == OTA_END_ERROR) Serial.println("End Failed");
});
ArduinoOTA.begin();
Serial.print("IP: ");
Serial.println(WiFi.localIP());
Serial.println("Control de acceso:");
pinMode(seguro, OUTPUT);
pinMode(falso, OUTPUT);
pinMode(ledabrir, OUTPUT);
pinMode(entrada, INPUT);
digitalWrite(seguro, LOW);
digitalWrite(falso, LOW);
digitalWrite(ledabrir, LOW);
}
byte ActualUID[4]; //almacenará el código del Tag leído
byte Usuario1[4] = {0xA3, 0xCC, 0x01, 0x20} ; //código del usuario 1
byte Usuario2[4] = {0xC1, 0x2F, 0xD6, 0x0E} ; //código del usuario 2
void loop() {
Blynk.run();
ArduinoOTA.handle();
digitalRead(entrada);
if (digitalRead(entrada) == HIGH)
{
Blynk.virtualWrite(5, "Abierta");
Blynk.run();
digitalWrite(seguro, HIGH);
digitalWrite(ledabrir, HIGH);
digitalWrite(falso, LOW);
delay(5000);
}
else if (digitalRead(entrada) == LOW)
{
Blynk.virtualWrite(5, "Cerrada");
Blynk.run();
digitalWrite(seguro, LOW);
digitalWrite(ledabrir, LOW);
digitalWrite(falso, LOW);
}
// Revisamos si hay nuevas tarjetas presentes
if ( mfrc522.PICC_IsNewCardPresent())
{
//Seleccionamos una tarjeta
if ( mfrc522.PICC_ReadCardSerial())
{
// Enviamos serialemente su UID
Serial.print(F("Card UID:"));
for (byte i = 0; i < mfrc522.uid.size; i++) {
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
ActualUID[i] = mfrc522.uid.uidByte[i];
}
Serial.print(" ");
//comparamos los UID para determinar si es uno de nuestros usuarios
if (compareArray(ActualUID, Usuario1)) {
Blynk.virtualWrite(5, "Abierta");
Blynk.run();
digitalWrite(seguro, HIGH);
digitalWrite(ledabrir, HIGH);
digitalWrite(falso, LOW);
delay(5000);
}
else if (compareArray(ActualUID, Usuario2)) {
Blynk.virtualWrite(5, "Abierta");
Blynk.run();
digitalWrite(seguro, HIGH);
digitalWrite(ledabrir, HIGH);
digitalWrite(falso, LOW);
delay(5000);
}
else
Blynk.virtualWrite(5, "Cerrada");
Blynk.run();
digitalWrite(seguro, LOW);
digitalWrite(ledabrir, LOW);
digitalWrite(falso, HIGH);
// Terminamos la lectura de la tarjeta tarjeta actual
mfrc522.PICC_HaltA();
}
}
digitalWrite(seguro, LOW);
digitalWrite(ledabrir, LOW);
digitalWrite(falso, LOW);
}
//Función para comparar dos vectores
boolean compareArray(byte array1[], byte array2[])
{
if (array1[0] != array2[0])return (false);
if (array1[1] != array2[1])return (false);
if (array1[2] != array2[2])return (false);
if (array1[3] != array2[3])return (false);
return (true);
}
Performing functional tests, when passing the card near the RFID reader, the lock
must be opened, here everything works fine..
The initial design of the case was 3d for printing, the model is included in the project files.
For material reasons, mainly due to the resistance to the type of weather, acrylic was used,
the housing was manufactured to properly distribute the circuit and the electronic lock.
It was a very interesting job, from the design, the laser cutting and assembly, to the
placement in an access door.