Electronic lock on Arduino. Automatic "smart" lock and Arduino Electronic lock on arduino nano

Today's lesson is on how to use an RFID reader with Arduino to create a simple locking system, in simple words- RFID lock.

RFID (English Radio Frequency IDentification, radio frequency identification) is a method of automatic identification of objects in which data stored in so-called transponders, or RFID tags, is read or written using radio signals. Any RFID system consists of a reading device (reader, reader or interrogator) and a transponder (also known as RFID tag, sometimes the term RFID tag is also used).

This tutorial will use an RFID tag with Arduino. The device reads the unique identifier (UID) of each RFID tag that we place next to the reader and displays it on the OLED display. If the UID of the tag is equal to the predefined value that is stored in the Arduino memory, then we will see the message “Unlocked” on the display. If the unique ID is not equal to a predefined value, the "Unlocked" message will not appear - see photo below.

The castle is closed

The lock is open

Parts needed to create this project:

  • RFID reader RC522
  • OLED display
  • Bread board
  • Wires

Additional details:

  • Battery (powerbank)

The total cost of the project's components was approximately $15.

Step 2: RFID Reader RC522

Each RFID tag contains a small chip (white card shown in photo). If you shine a flashlight on this RFID card, you can see the small chip and the coil that surrounds it. This chip does not have a battery to generate power. It receives power from the reader wirelessly using this large coil. It is possible to read an RFID card like this from up to 20mm away.

The same chip also exists in RFID key fob tags.

Each RFID tag has a unique number that identifies it. This is the UID that is shown on the OLED display. Except for this UID, each tag can store data. This type of card can store up to 1 thousand data. Impressive, isn't it? This feature will not be used today. Today, all that is of interest is identifying a specific card by its UID. The cost of the RFID reader and these two RFID cards is about $4.

Step 3: OLED Display

The lesson uses a 0.96" 128x64 I2C OLED monitor.

This is a very good display to use with Arduino. This is an OLED display and that means it has low power consumption. The power consumption of this display is around 10-20mA and it depends on the number of pixels.

The display has a resolution of 128 by 64 pixels and is tiny in size. There are two display options. One of them is monochrome, and the other, like the one used in the lesson, can display two colors: yellow and blue. The top of the screen can only be yellow, and the bottom can only be blue.

This OLED display is very bright and has a great and very nice library that Adafruit has developed for this display. In addition to this, the display uses an I2C interface, so connecting to the Arduino is incredibly easy.

You only need to connect two wires except Vcc and GND. If you are new to Arduino and want to use an inexpensive and simple display in your project, start here.

Step 4: Connecting all the parts

Communication with the Arduino Uno board is very simple. First, let's connect the power to both the reader and the display.

Be careful, the RFID reader must be connected to the 3.3V output from the Arduino Uno or it will be damaged.

Since the display can also operate at 3.3V, we connect the VCC from both modules to the positive rail of the breadboard. This bus is then connected to the 3.3V output from the Arduino Uno. Then we connect both grounds (GND) to the breadboard grounding bus. Then we connect the breadboard GND bus to the Arduino GND.

OLED display → Arduino

SCL → Analog Pin 5

SDA → Analog Pin 4

RFID reader → Arduino

RST → Digital Pin 9

IRQ → Not connected

MISO → Digital Pin 12

MOSI → Digital Pin 11

SCK → Digital Pin 13

SDA → Digital Pin 10

The RFID reader module uses SPI interface to communicate with Arduino. So we are going to use hardware SPI pins from Arduino UNO.

The RST pin goes to digital pin 9. The IRQ pin remains disconnected. The MISO pin goes to digital pin 12. The MOSI pin goes to digital pin 11. The SCK pin goes to digital pin 13, and finally the SDA pin goes to digital pin 10. That's it.

The RFID reader is connected. Now we need to connect the OLED display to the Arduino using the I2C interface. So the SCL pin on the display goes to the analog pin of Pin 5 and the SDA pin on the display to the analog Pin 4. If we now turn on the project and place the RFID card near the reader, we can see that the project is working fine.

Step 5: Project Code

In order for the project code to compile, we need to include some libraries. First of all, we need the MFRC522 Rfid library.

To install it, go to Sketch -> Include Libraries -> Manage libraries(Library Management). Find MFRC522 and install it.

We also need the Adafruit SSD1306 library and the Adafruit GFX library for display.

Install both libraries. The Adafruit SSD1306 library needs a little modification. Go to folder Arduino -> Libraries, open the Adafruit SSD1306 folder and edit the library Adafruit_SSD1306.h. Comment out line 70 and uncomment line 69 because The display has a resolution of 128x64.

First we declare the value of the RFID tag that the Arduino needs to recognize. This is an array of integers:

Int code = (69,141,8,136); // UID

Then we initialize the RFID reader and display:

Rfid.PCD_Init(); display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

After that, in the loop function we check the tag on the reader every 100ms.

If there is a tag on the reader, we read its UID and print it on the display. We then compare the UID of the tag we just read with the value that is stored in the code variable. If the values ​​are the same, we will display the UNLOCK message, otherwise we will not display this message.

If(match) ( Serial.println("\nI know this card!"); printUnlockMessage(); )else ( Serial.println("\nUnknown Card"); )

Of course, you can change this code to store more than 1 UID value so that the project recognizes more RFID tags. This is just an example.

Project code:

#include #include #include #include #define OLED_RESET 4 Adafruit_SSD1306 display(OLED_RESET); #define SS_PIN 10 #define RST_PIN 9 MFRC522 rfid(SS_PIN, RST_PIN); // Instance of the class MFRC522::MIFARE_Key key; int code = (69,141,8,136); //This is the stored UID int codeRead = 0; String uidString; void setup() ( Serial.begin(9600); SPI.begin(); // Init SPI bus rfid.PCD_Init(); // Init MFRC522 display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64) // Clear the buffer. display.clearDisplay(); display.display(); display.setTextColor(WHITE); // or BLACK); display.setTextSize(2); display.setCursor(10,0); display.print("RFID Lock"); display.display(); ) void loop() ( if(rfid.PICC_IsNewCardPresent()) ( readRFID(); ) delay(100); ) void readRFID() ( rfid.PICC_ReadCardSerial(); Serial.print(F("\nPICC type: ") ); MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak); Serial.println(rfid.PICC_GetTypeName(piccType)); // Check is the PICC of Classic MIFARE type if (piccType != MFRC522::PICC_TYPE_MIFARE_MINI && piccType != MFRC522::PICC_TYPE_MIFARE_1K && piccType != MFRC522::PICC_TYPE_MIFARE_4K) ( Serial.println(F("Your tag is not of type MIFARE Classic.")); return; ) clearUID(); Serial.println(" Scanned PICC"s UID:"); printDec(rfid.uid.uidByte, rfid.uid.size); uidString = String(rfid.uid.uidByte)+" "+String(rfid.uid.uidByte)+" "+ String(rfid.uid.uidByte)+ " "+String(rfid.uid.uidByte); printUID(); int i = 0; boolean match = true; while(i

Step 6: Final Result

As you can see from the lesson, for little money you can add an RFID reader to your projects. You can easily create a security system using this reader or create more interesting projects, for example, so that data from a USB drive is read only after unlocking.

I, like most people who have one, associate Cottage with the words: relaxation, barbecue, comfort and other pleasant movements for the spirit and body, but there is also a downside: gardening, digging, repairs, construction, etc.

For 10 years, my family and I have been trying to improve and create maximum comfort in our dacha. We build, repair, etc. House, barn, bathhouse…..and finally it came to the street fence, gate and gate. Do this according to conscience, budget and convenience.

After discussing some details, it was decided that the gate should be automatic and the gate should have some of the properties of an access control system. With the gate, the issue was resolved by purchasing an automation kit (drive, rack, remote control, etc.), but with the gate it was necessary to solve some problems, more about them below.

The tasks were the following:

  1. The lock had to work in conjunction with a previously installed video intercom (open the gate without leaving the house)
  2. Be able to open the door with a regular key and without a key from the street and yard.
  3. Will fit within the remaining budget up to 5000 rubles.

Searches in RuNet presented the following price range from 7000 to infinity. Purchasing a ready-made solution was no longer necessary and an alternative with wide possibilities was conceived, namely to cut down the door yourself!

After some calculations and calculations, it was decided to buy an electromechanical lock for about 2000 rubles, a waterproof keyboard for 350 rubles, and a microcontroller that will drive here. Since there were several Arduino nano boards, relays and loose parts and some wires, the difference between the cost of the finished kit was more than 4000 rubles. For me, it’s a great bonus for your wallet and self-development.

Well, now from words to action:

After purchasing all the necessary components, I began sawing.

Keyboard connection diagram

Additional LED indication (white, green, red) of the panel with keypad signals (input, correct password, door open, refused).

  • pin 9 yellow
  • pin 10 green
  • pin 11 red

A panel (grid) made of plexiglass, cut for a box of chocolates and a smile by office neighbors. But the smallest cutter turned out to be a little fatter, so I had to work with a needle file.

Well, it’s the weekend, I went to the dacha.

To open an electromechanical lock, you need 12 V. The power supply supplying the MK was 5 V, the decision was to install a boost dc-dc converter from the Middle Kingdom for the castle. I connected everything and started checking it, it works, but when voltage was applied to the lock solenoid, the Dunya rebooted, causing a short to the power supply. Further more, after connecting the calling panel from the video intercom to the lock, when you pressed the button to open the door, nothing happened, a small current to the lock. Running new wires is not an option; they were already concreted at the exit from the house. I decided to add another relay for the panel and install an additional 12 V power supply. for the castle. After parsing/assembling, everything worked, the MK stopped rebooting. I hid the whole thing in a moisture-proof junction box, hid the wires, glue, silicone and ready!

Progress does not stand still and “Smart locks” are increasingly appearing on the doors of apartments, garages and houses.

A similar lock opens when you press a button on your smartphone. Fortunately, smartphones and tablets have already entered our everyday life. In some cases, “smart locks” are connected to “cloud services” like Google Drive and opened remotely. In addition, this option makes it possible to give access to opening the door to other people.

This project will implement a DIY version of a smart lock on Arduino, which can be controlled remotely from anywhere in the world.

In addition, the project has added the ability to open the lock after identifying a fingerprint. For this purpose, a fingerprint sensor will be integrated. Both door opening options will be powered by the Adafruit IO platform.

A lock like this can be a great first step in your Smart Home project.

Setting up the fingerprint sensor

To work with a fingerprint sensor, there is an excellent library for Arduino, which greatly simplifies the process of setting up the sensor. This project uses Arduino Uno. An Adafruit CC3000 board is used to connect to the Internet.

Let's start with connecting the power:

  • Connect the 5V pin from the Arduino board to the red power rail;
  • The GND pin from the Arduino connects to the blue rail on the solderless circuit board.

Let's move on to connecting the fingerprint sensor:

  • First connect the power. To do this, the red wire is connected to the +5 V rail, and the black wire to the GND rail;
  • The white wire of the sensor connects to pin 4 on the Arduino.
  • The green wire goes to pin 3 on the microcontroller.

Now let's move on to the CC3000 module:

  • We connect the IRQ pin from the CC3000 board to pin 2 on the Arduino.
  • VBAT - to pin 5.
  • CS - to pin 10.
  • After this, you need to connect the SPI pins to the Arduino: MOSI, MISO and CLK - to pins 11, 12 and 13, respectively.

Well, at the end you need to provide power: Vin - to the Arduino 5V (red rail on your circuit board), and GND to GND (blue rail on the breadboard).

A photo of the fully assembled project is shown below:

Before developing a sketch that will load data onto Adafruit IO, you need to transfer data about your fingerprint to the sensor. Otherwise, he will not recognize you in the future;). We recommend calibrating the fingerprint sensor using the Arduino separately. If this is your first time working with this sensor, we recommend that you familiarize yourself with the calibration process and detailed instructions for working with the fingerprint sensor.

If you haven't already done so, please create an account with Adafruit IO.

After this, we can move on to the next stage of developing a “smart lock” on Arduino: namely, developing a sketch that will transmit data to Adafruit IO. Since the program is quite voluminous, in this article we will highlight and consider only its main parts, and then we will provide a link to GitHub, where you can download the full sketch.

The sketch begins by loading all the necessary libraries:

#include

#include

#include

#include "Adafruit_MQTT.h"

#include "Adafruit_MQTT_CC3000.h"

#include

#include >

After this, you need to slightly correct the sketch by inserting the parameters of your WiFi network, specifying the SSID and password:

#define WLAN_SECURITY WLAN_SEC_WPA2>

In addition, you must enter your name and AIO key to log into your Adafruit IO account:

#define AIO_SERVERPORT 1883

#define AIO_USERNAME "adafruit_io_name"

#define AIO_KEY "adafruit_io_key">

The following lines are responsible for interacting and processing data from the fingerprint sensor. If the sensor was activated (the fingerprint matched), there will be "1":

const char FINGERPRINT_FEED PROGMEM = AIO_USERNAME "/feeds/fingerprint";

Adafruit_MQTT_Publish fingerprint = Adafruit_MQTT_Publish(&mqtt, FINGERPRINT_FEED);

In addition, we need to create an instance of the SoftwareSerial object for our sensor:

SoftwareSerial mySerial(3, 4);

After this we can create an object for our sensor:

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

Inside the sketch we indicate which fingerID should activate the lock in the future. This example uses 0, which corresponds to the ID of the first fingerprint used by the sensor:

int fingerID = 0;

After this, we initialize the counter and delay in our project. Essentially we want the lock to automatically engage once opened. This example uses a delay of 10 seconds, but you can adjust this value to suit your needs:

int activationCounter = 0;

int lastActivation = 0;

int activationTime = 10 * 1000;

In the body of the setup() function, we initialize the fingerprint sensor and ensure that the CC3000 chip is connected to your WiFi network.

In the body of the loop() function we connect to Adafruit IO. The following line is responsible for this:

After connecting to the Adafruit IO platform, we check the last fingerprint. If it matches and the lock is not activated, we send "1" to Adafruit IO for processing:

if (fingerprintID == fingerID && lockState == false) (

Serial.println(F("Access granted!"));

lockState = true;

Serial.println(F("Failed"));

Serial.println(F("OK!"));

lastActivation = millis();

If within the loop() function the lock is activated and we have reached the delay value indicated above, we send “0”:

if ((activationCounter - lastActivation > activationTime) && lockState == true) (

lockState = false;

if (! fingerprint.publish(state)) (

Serial.println(F("Failed"));

Serial.println(F("OK!"));

You can download the latest version of the code on GitHub.

It's time to test our project! Don't forget to download and install all the necessary libraries for Arduino!

Make sure you have made all the necessary changes to the sketch and upload it to your Arduino. After that, open the Serial Monitor window.

When Arduino connects to WiFi networks, the fingerprint sensor will blink red. Place your finger on the sensor. The ID number should be displayed in the serial monitor window. If it matches, the message "OK!" will appear. This means that the data has been sent to the Adafruit IO servers.

Diagram and sketch for further configuration of the lock using the example of an LED

Now let's move on to the part of the project that is directly responsible for controlling the door lock. To connect to wireless network and activating/deactivating the lock, you will need an additional Adafruit ESP8266 module (the ESP8266 module does not have to be from Adafruit). Using the example below, you can evaluate how easy it is to exchange data between two platforms (Arduino and ESP8266) using Adafruit IO.

In this section we will not work directly with the lock. Instead, we will simply connect the LED to the pin where the lock will be connected later. This will give us the opportunity to test our code without delving into the details of the lock design.

The scheme is quite simple: first install the ESP8266 on the breadboard. After this, install the LED. Don't forget that the long (positive) leg of the LED is connected through a resistor. The second leg of the resistor is connected to pin 5 on the ESP8266 module. We connect the second (cathode) of the LED to the GND pin on the ESP8266.

The fully assembled circuit is shown in the photo below.


Now let's look at the sketch we are using for this project. Again, the code is quite large and complex, so we will only look at its main parts:

We start by connecting the necessary libraries:

#include

#include "Adafruit_MQTT.h"

#include "Adafruit_MQTT_Client.h"

Configuring WiFi settings:

#define WLAN_SSID "your_wifi_ssid"

#define WLAN_PASS "your_wifi_password"

#define WLAN_SECURITY WLAN_SEC_WPA2

We also configure Adafruit IO parameters. Same as in the previous section:

#define AIO_SERVER "io.adafruit.com"

#define AIO_SERVERPORT 1883

#define AIO_USERNAME "adafruit_io_username"

#define AIO_KEY "adafruit_io_key"

We indicate which pin we connected the LED to (in the future this will be our lock or relay):

int relayPin = 5;

Interaction with the fingerprint sensor, as in the previous section:

const char LOCK_FEED PROGMEM = AIO_USERNAME "/feeds/lock";

Adafruit_MQTT_Subscribe lock = Adafruit_MQTT_Subscribe(&mqtt, LOCK_FEED);

In the body of the setup() function we indicate that the pin to which the LED is connected should operate in OUTPUT mode:

pinMode(relayPin, OUTPUT);

Within the loop() loop, we first check if we are connected to Adafruit IO:

After this, we check what signal is being received. If "1" is transmitted, we activate the pin that we declared earlier, to which our LED is connected. If we receive "0", we transfer the contact to the "low" state:

Adafruit_MQTT_Subscribe *subscription;

while ((subscription = mqtt.readSubscription(1000))) (

if (subscription == &lock) (

Serial.print(F("Got: "));

Serial.println((char *)lock.lastread);

// Save the command to string data

String command = String((char *)lock.lastread);

if (command == "0") (

digitalWrite(relayPin, LOW);

if (command == "1") (

digitalWrite(relayPin, HIGH);

Find latest version You can find the sketch on GitHub.

It's time to test our project. Don't forget to download all the required libraries for your Arduino and check if you have made the correct changes to the sketch.

To program the ESP8266 chip, you can use a simple USB-FTDI converter.

Upload the sketch to the Arduino and open the Serial Monitor window. At this stage, we simply checked whether we were able to connect to Adafruit IO: we will look at the available functionality further.

Testing the project

Now let's start testing! Go to your Adafruit IO's user menu, under the Feeds menu. Check whether the fingerprint and lock channels are created or not (in the print screen below these are the fingerprint and lock lines):


If they do not exist, you will have to create them manually.

Now we need to ensure data exchange between the fingerprint and lock channels. The lock channel must take the value "1" when the fingerprint channel takes the value "1" and vice versa.

To do this, we use a very powerful Adafruit IO tool: triggers. Triggers are essentially conditions that you can apply to configured channels. That is, they can be used to interconnect two channels.

Create a new reactive trigger from the Triggers section in Adafruit IO. This will provide the ability to exchange data between the fingerprint sensor and lock channels:


This is what it should look like when both triggers are configured:

All! Now we can actually test our project! We put our finger on the sensor and see how the Arduino began to wink with an LED that corresponds to data transmission. After this, the LED on the ESP8266 module should start blinking. This means that it has started receiving data via MQTT. The LED on the circuit board should also turn on at this moment.

After the delay you set in the sketch (the default is 10 seconds), the LED will turn off. Congratulations! You can control the LED with your fingerprint from anywhere in the world!

Setting up an electronic lock

We've reached the last part of the project: directly connecting and controlling the electronic lock using Arduino and a fingerprint sensor. The project is not easy, you can use all the sources in the form in which they are presented above, but connect a relay instead of an LED.

To connect the lock directly, you will need additional components: a 12 V power supply, a jack for connecting power, a transistor (V in this example IRLB8721PbF MOSFET is used, but another one can be used, for example, a TIP102 bipolar transistor. If you are using a bipolar transistor, you will need to add a resistor.

Shown below electrical diagram connecting all components to the ESP8266 module:


Note that if you are using a MOSFET transistor, you will not need a resistor between pin 5 of the ESP8266 module and the transistor.

The fully assembled project is shown in the photo below:


Power the ESP8266 module using the FTDI module and connect the 12V power supply to the jack. If you used the pins recommended above for connection, you won’t have to change anything in the sketch.

Now you can put your finger on the sensor: the lock should work in response to your fingerprint. The video below shows the automatic smart lock project in action:

Further development of the Smart Lock project

Released in our project remote control door lock using your fingerprint.

Feel free to experiment, modify the sketch and binding. For example, you can replace an electronic door lock with a relay to control the power of your 3D printer, robotic arm or quadcopter...

You can develop your smart House". For example, remotely activate an irrigation system on Arduino or turn on the lights in a room... Don't forget that you can simultaneously activate an almost unlimited number of devices using Adafruit IO.

Leave your comments, questions and share personal experience below. New ideas and projects are often born in discussions!

In this lesson we will learn how to do simple system, which will unlock the lock using an electronic key (Tag).

In the future, you can refine and expand the functionality. For example, add the function “adding new keys and removing them from memory.” In the base case, let's consider a simple example where a unique key identifier is pre-set in the program code.

In this tutorial we will need:

To implement the project we need to install the libraries:

2) Now you need to connect a Buzzer, which will sound a signal if the key works and the lock opens, and a second signal when the lock closes.

We connect the buzzer in the following sequence:

Arduino Buzzer
5V VCC
GND GND
pin 5 IO

3) A servo drive will be used as the unlocking mechanism. Any servo drive can be selected, depending on the size you require and the force that the servo drive creates. The servo has 3 contacts:

You can see more clearly how we connected all the modules in the picture below:

Now, if everything is connected, you can proceed to programming.

Sketch:

#include #include #include // "RFID" library. #define SS_PIN 10 #define RST_PIN 9 MFRC522 mfrc522(SS_PIN, RST_PIN); unsigned long uidDec, uidDecTemp; // to store the tag number in decimal format Servo servo; void setup() ( Serial.begin(9600); Serial.println("Waiting for card..."); SPI.begin(); // SPI initialization / Init SPI bus. mfrc522.PCD_Init(); // initialization MFRC522 / Init MFRC522 card. servo.attach(6); servo.write(0); // set the servo to a closed state ) void loop() ( // Search for a new label if (! mfrc522.PICC_IsNewCardPresent()) ( return; ) // Select a label if (! mfrc522.PICC_ReadCardSerial()) ( return; ) uidDec = 0; // Output serial number tags. for (byte i = 0; i< mfrc522.uid.size; i++) { uidDecTemp = mfrc522.uid.uidByte[i]; uidDec = uidDec * 256 + uidDecTemp; } Serial.println("Card UID: "); Serial.println(uidDec); // Выводим UID метки в консоль. if (uidDec == 3763966293) // Сравниваем Uid метки, если он равен заданому то серва открывает. { tone(5, 200, 500); // Делаем звуковой сигнал, Открытие servo.write(90); // Поворациваем серву на угол 90 градусов(Отпираем какой либо механизм: задвижку, поворациваем ключ и т.д.) delay(3000); // пауза 3 сек и механизм запирается. tone(5, 500, 500); // Делаем звуковой сигнал, Закрытие } servo.write(0); // устанавливаем серву в закрытое сосотояние }

Let's look at the sketch in more detail:

In order to find out the UID of the card (Tag), you need to write this sketch into arduino, assemble the circuit outlined above, and open the Console (Serial Port Monitoring). When you touch the RFID tag, the console will display a number

The resulting UID must be entered in the following line:

If (uidDec == 3763966293) // Compare the Uid of the tag, if it is equal to the given one, then the servo drive opens the valve.

Each card has a unique identifier and is not repeated. Thus, when you present the card whose identifier you set in the program, the system will open access using a servo drive.

Video:

Presenter youtube channel“AlexGyver” was asked to make an electronic lock with his own hands. Welcome to the series of videos about electronic locks on arduino. The master will explain the idea in general terms.

There are several options for creating an electronic lock system. Most often used to lock doors, drawers, and cabinets. And also for creating caches and secret safes. Therefore, you need to make a layout that is convenient to work with and can clearly and in detail show the structure of the system from the inside and outside. So I decided to make a frame with a door. To do this you will need a square beam 30 x 30. Plywood 10mm. Door hinges. Initially I wanted to make a plywood box, but I remembered that the room was full of spare parts. There is nowhere to put such a box. Therefore, a mock-up will be made. If someone wants to install an electronic lock for themselves, then looking at the layout they can easily repeat everything.

You will find everything you need for a castle in this Chinese store.

The goal is to develop the most efficient circuits and firmware for electronic locks. You can use these results to install these systems on your doors, drawers, cabinets and hiding places.

The door is ready. Now we need to figure out how to open and close electronically. A powerful solenoid latch from aliexpress is suitable for these purposes (link to the store above). If you apply voltage to the terminals, it will open. The coil resistance is almost 12 ohms, which means that at a voltage of 12 volts the coil will consume about 1 ampere. Both a lithium battery and a boost module can cope with this task. Adjust to the appropriate voltage. Although a little more is possible. The latch is attached to the inside of the door at a distance so that it does not catch the edge and can slam shut. The latch should have a counterpart in the form of a metal box. Using it without this is inconvenient and incorrect. We'll have to install a step, at least to create the appearance of normal operation.

In idle mode, the latch opens normally, that is, if there is a handle on the door, we apply a pulse and open the door by the handle. But if you use a spring, this method is no longer suitable. The boost converter cannot cope with the load. To open the spring-loaded door you will have to use larger batteries and a more powerful inverter. Or use a network power source and forget about system autonomy. Chinese stores have large size latches. They are suitable for drawers. Power can be supplied using a relay or mosfet transistor, or a power switch on the same transistor. A more interesting and less expensive option is a servo drive connected to a connecting rod with any locking element - a latch or a more serious bolt. You may also need a piece of steel knitting needle to act as a connecting rod. Such a system does not require high current. But it takes up more space and has more cunning control logic.

There are two types of servos. Small weak ones and large powerful ones that can be easily pushed into holes in serious metal pins. Both options shown work on both doors and drawers. You will have to tinker with the box, making a hole in the retractable wall.

Second part

Publications on the topic