Electronic key tablet for intercom. Electronic lock with iButton key (DS1990A) on a microcontroller

However, hundreds of thousands of people face it every day to get to their homes.

Today, access panels are installed at almost every entrance.

And their clients, the residents of the house, don’t even think about what it’s called.

This could be a familiar tablet, a contactless key fob, an optical recognition plate, or even a compact reed switch unit.

Intercom key device

How the key works and how exactly the main microprocessor module of the system interacts with the individual “unlock” depends on the specific model of the system.

Today the most common:

  1. classic Touch Memory, familiar tablets;
  2. contactless RFID, key fobs or cards;
  3. individual optical recognition plates.

The simple answer to the question of how an intercom key works sounds like this: there is a constant polling from the system, waiting for a response from an individual tablet or key fob. In optical recognizers, the identification process begins by inserting a plate into the corresponding receiver.

Inside any individual door opener is an electronic circuit. The intercom key device may involve closing an electrical circuit or activating a radio transmitter to transmit the user's personal code.

The principle of operation of the intercom key

What is the name of the key to the intercom for the entrance door? Probably everyone knows who has at least once lost it and was faced with the need to order a new one.

The most common type of individual identifiers is based on Touch Memory. Inside the usual tablet there is a non-volatile memory block and an interface circuit.

And although the operating principle of a key for an intercom of this type does not change, individual manufacturers have different characteristics, so to speak, of its internal filling.

Therefore, certain types of intercom units only work with a specific list of tablet types.

ONE-WIRE

The ONE-WIRE data exchange protocol allows you to connect 2 or more digital devices to one line.

The Touch Memory intercom key device works in just such a system.

When you put a tablet on the reader, the following happens:

  • the circuit closes, generating a signal to start reading the identifier;
  • Using different closing and releasing intervals, the circuit transmits digital data;
  • If the identifier matches one of the storage records in the memory, the door opens.

The speed of the protocol is highly dependent on environmental conditions and the condition of the contact pads. Thus, a clean key, without surface contamination, attached to a reader of similar quality is identified almost instantly. The maximum time the system tries to identify an individual tablet is 2 minutes.

Interaction between key and intercom

Knowing the correct name for the key to the intercom, you can understand the principle of operation of the system. For example, RFID already clearly indicates the use of radio waves.

This keychain (or card) works as follows:

  1. inside the key fob or card there is an electronic circuit, non-volatile memory, a transceiver antenna, which simultaneously acts as a power source;
  2. when approaching the intercom, energy is generated inside the RFID system by magnetic induction;
  3. the electronic circuit sends a signal to start reading, and when the intercom responds that the intercom is ready, it transmits the identifier.

The answer to the question of how the key for an intercom for an entrance with a contactless operating principle works is always the same, whether it is made in the form of a key fob or a flat card.

There are other options for making intercom openers. One of them is quite common. It is very simple to answer what the optical identification intercom key consists of.

This is a strip of metal. There are holes made in it, the position of which forms an individual access code. This key is read by the receiver using LEDs and photocells.

Conclusion

Today there are a wide variety of human identification solutions on the market.

Intercom systems have become widespread for a number of reasons. The first and most important is simplicity and low cost of production.

The second is proven, reliable engineering solutions and protocols used in access control systems.

Therefore, Touch Memory tablets and the increasingly widespread contactless RFID will remain a familiar item in the pocket or purse of a city dweller for a long time.

Video: What's inside the intercom keys and how it works

An intercom is a device designed to protect the territory from unauthorized entry. It is an apparatus for negotiations between the internal and external zones. In addition, the locking elements block the door lock, preventing anyone from entering without permission. In order to get into the internal zone, it is enough to bring the intercom key to a special connector or dial the code from the keypad.

What does an intercom consist of and how does it work?

The intercom system consists of three main components: an internal zone calling unit - a door station and an intercom, an electromagnetic or electromechanical lock-lock, and an intercom. The intercom can use video or audio. All components are connected to each other by a switch. The design of an intercom directly depends on what additional functions are included in it.

The main function is to protect the internal zone from unauthorized entry and fire. The principle of operation is to trigger an alert about an emergency situation to the central console, concierge or dispatcher console. The alert is not triggered immediately; the person is given the opportunity to leave the area within a certain time. This period of time is programmed when the intercom is initially connected and is no more than 5 minutes.

As an additional function, it may be possible for the visitor to transmit a video or audio message in the absence of the owner of the house, and also vice versa, from the owner to the visitor. Most models support the function of alerting the internal zone with a special signal when opening the door with a key or from the keypad. Keypad intercoms initially have a factory code for opening the door. It can be changed, if desired, directly on the main unit remote control itself through programming from the keyboard.

There are wireless intercom models. The main unit is connected to the mains, and the signal is transmitted between the intercom components via Wi-Fi at a certain frequency. Other devices using this technology can be connected to wireless devices for control. The disadvantage of the system is its limited range. Such devices do not work in buildings with thick walls. They are sensitive to outside interference. Advanced models are equipped with the SMART function, which allows you to transfer video and photos from the intercom to a smartphone.

Video intercoms differ from audio analogues in the presence of a built-in video camera. They allow the image to be transmitted to the internal zone. Some models can display an image from two points, for example, the entrance door and the floor bay. Advanced devices allow you to display up to 32 images simultaneously on the monitor. Many devices can connect to telephone lines and emergency services.

Watch the video in which the master connected the intercom with an electromechanical lock and calling panel.

How does the intercom key work?

Most users of intercom keys are confident that the process of opening the door occurs through demagnetization of the lock. It's a delusion. A standard key is a programmed device with non-volatile Touch Memory, into which special software is embedded. The connection occurs using a single-wire interface (One-wire bus). This bus allows you to connect 2 or more devices to the device via one wire. In a passive state (standby mode), power is supplied through the wire to the intercom unit.

The key also contains a capacitor that provides power to the device at the time of connection. The manufacturer of the intercom system prescribes a special door opening code in the key and microcontroller of the device. It is unique and will not be repeated. The principle of operation of the key: when the key is brought to the connector, information is read from the key and compared with the data in the microcontroller database. The identification process lasts no more than 2 seconds. If the information matches, the door lock is released.

The operation of the key can only be changed programmatically. A universal key is created using the same principle. Its versatility is enabled by the presence of free memory in the intercom microcontroller. It is this that serves to identify whether the key belongs to the device, since its value is written in the software of the key itself. The principle of operation is to read the code of free memory cells, such a key is recognized as registered in the microcontroller base. The identification process takes much longer.

Keys based on Touch Memory are used most often. There are other types of intercom keys. Their operating principle is slightly different. A Proximity-based key is a contactless device that allows you to open doors remotely. Made in the form of a card or keychain, it is less common, but more reliable than a device based on Touch Memory.

Resistive switches work based on a resistor built into them. The resistor value is the key code. The shape of the plate does not allow connecting another resistor to the key, so unauthorized entry will be excluded. The disadvantage of such a key is that it is easy to make a duplicate, since only one resistor value is used for all users of the intercom system.

Reed keys operate on the basis of a magnetic pair: one part of the reed switch is sewn into the key, the second part is sewn into a special flask on the lock of the internal zone. When exposed to the reed switch part of the key, the switch in the bulb is activated, opening the lock. Optical switches operate on the principle of an optocoupler: an LED and a photodiode. The key is made in the form of a plate, on which holes are applied in a certain order. These code combinations are read when the key is placed near the photodiode. The disadvantage of the key is the appearance of dirt that prevents reading. This key must be replaced.

Magnetic keys This is not only daily access to the entrance, it is the so-called identifier of the person who owns such a device. Electronic code media is actively used both in security systems and in various semi-automatic engineering systems. We sometimes rarely think about where we can apply knowledge about magnetic code carriers. But more detailed knowledge sometimes helps us in life. We will try to tell you a little about magnetic keys, cards and key fobs.

There are many identifier models. Some serve as access cards to the office, others open entrance doors, others launch ventilation controls, and others open safes.

Magnetic keys and blanks for intercoms

Let us roughly divide all magnetic media into 5 categories:

1. Electromagnetic access keys

2. Access cards

3. Key rings with code

4. Magnetic bracelets

5. Active and passive tags

Magnetic keys

The most common devices in everyday life. We actively use magnetic keys and blanks for intercoms every day. We used to call them " intercom key", "tablet", "magnetic key" etc. In fact, these names do not accurately reflect the correct name. Some people really believe that such a key can " magnetize". This is also not correct. The correct name is electromagnetic key or electronic identifier. And its operating principle is simple - the device itself contains non-volatile memory on which a unique identification number is recorded. Sometimes this number (code) can be changed.

Magnetic keys and blanks for intercoms are divided into 3 categories

1. Factory coded (not rewritable) . This code is assigned immediately when the key is produced. Both numbers and letters are used. There are billions of combinations of unique codes. The chance of meeting a double (double) is in hundredths of a percent. This is the cheapest option for a magnetic key. The most common model, both for entrances and in any systems.

2. Rewritable blanks . Outwardly, they are no different from their “brothers”. But they cost a little more. All because of the advanced functionality of the key. For such models you can have a code delete and write a new one. Such keys are not used very often. The main scope of application is companies engaged in the production of intercom keys for entrances.

3.Recordable blanks . Just like rewritable ones, they do not differ in design. The functionality is a little more modest - they can be recorded only once. That is, the code can be programmed once and forever. Since they cheaper of the second category (overwritten many times), then this is the key to which your " tablet from the entrance".

4. Universal . In fact, an interesting option is simply a set of ready-made keys that fit many intercoms. There are different options. The essence of such a set is simple - to make keys to all entrances in one bunch. The secret lies in the fact that almost all entrance intercoms produced have a sewn-in serial number, which is copied onto magnetic key in such a set. Prices for universal sets different, as they include different numbers of magnetic tablets.

Pros and cons of magnetic keys and blanks for intercoms

The main advantages of such products are their durability and practically indestructible functionality. Made with the expectation that they will hang around for years together with the keys to the apartment, on one bunch. These can last forever. There are practically no disadvantages, except for their possibility " demagnetize"But you need very strong objects nearby (with a strong magnetic field) to damage the internal key code.

Access cards

Magnetic cards access are essentially clones of “tablets”. The principle of operation of cards is exactly the same as that of magnetic keys. There are few differences: a different design, several additional functions for some models, ease of storage.

This is useful to know about ACS:

For the full operation of many systems (including access control and management), special “electronic keys” are required. These keys have many names: access cards, tablets, key fobs, magnetic cards, identifiers, tags, key fobs, etc. But all of them are designed to recognize the visitor or user.

Identifiers can be used to access the premises, quickly arm (or disarm), confirm entered actions, and launch a specific control scenario.

Typically, the cost of cards and key fobs is not high, since they are easy to manufacture. A special feature of these additional devices is the presence of non-volatile (in rare cases dependent) memory, which contains an electronic (alphanumeric) code. In some cases it can be changed, in some cases additional data about the key owner can be stored in memory.

Please note that electronic key duplicators are located in the "Measuring Instruments" section.

Identifiers are:

Important! Be sure to read the instructions for the device as there are several electronic key formats (TouchMemory, HID, EM-marin, MIFARE and others).

Door opening buttons are:

There are a large number of beautiful design solutions for door opening buttons on the market. Now there are wireless buttons, touch-sensitive, and piezoelectronic. But the most reliable, as always, are buttons with mechanical metal filling. Such buttons are not afraid of temperature changes and moisture. We invite you to view and purchase any door opening buttons (locking, remote, illuminated) in our online store.

What are the opening buttons?

  • Normally open
  • Normally closed
  • Combined (open/closed)
  • With backlight (LED)

The specialists of the ABars systems protection company will be happy to select for you additional equipment for an access control system for any type of facility.

Buy and order delivery of buttons and cards in Moscow:

You can order and buy all these products through the online access control store of our website or order delivery or professional installation in Moscow from the ABars company (when purchasing cards, keys or buttons for an amount over 8 thousand rubles, delivery is free).

If you find it difficult to choose the desired card format or have other questions about the characteristics, call our company.

You've lost your intercom keys and can't make a duplicate. You want to visit a friend, but you don’t have the keys to her entrance. Or you just need to give a shit to your enemy, but you can’t get into his house, then this article is for you.

A few words about the principle of operation...
There is an opinion that there is a magnet in the intercom tablets, and it opens the door. No, it's not. The tablet is a ROM with a key hard-wired into it. This ROM is called Touch Memory, brand DS1990A. DS1990A is a brand of intercom keys. Communicates with the intercom via the one-wire bus (single-wire interface). This bus was developed by Dallas and allows two devices to communicate using just one wire. If the device is passive (as in our case), then it also transmits power to it through this wire. It should also be noted that a common wire is also needed (for the circuit to close), but, as a rule, all the grounds of the devices connected to this bus are connected together. The key contains a 60 picofarad capacitor, which provides short-term power to the key at the time of response. But the master device must constantly (at least every 120 microseconds) generate a one signal to charge this capacitor so that the ROM in the tablet continues to be powered.

Internal structure of the tablet

One-wire bus organization
The One-wire bus works as follows. There is a master device and a slave device, in our case a passive key. The main signals are generated by the master, logical one and zero signals. The slave device can only forcibly generate zero signals (i.e., simply drive the bus to ground through the transistor). A simplified diagram of a master and slave device is shown in the pictures.

Master circuit

If you look at the diagram, it is easy to notice that by default the master is always +5 volts, a la logical unit. To transmit a logical zero, the master closes the bus to ground through a transistor, and to transmit a 1, it simply opens it. This is done to provide power to the slave device. The slave device is made similarly, only it does not generate +5 volts. It can only sag the bus to the ground, thereby transmitting a logical zero. A logical unit is transmitted simply by the “silence” of the device.

Work protocol
You can immediately clearly notice that only the Master rules the parade, the DS1990A key itself either holds the ground (the master himself sets the bus to zero), or simply remains silent; if he wants to transfer a unit, then he simply remains silent. Let's look at the drawing.

An example of an intercom reading a key.

After the PREFERENCE pulse is generated by the key, the master device waits for some time and issues a command to read the ROM, usually this is a family code, in our case 33H. Pay attention to how the transmission of zero and one is done. In any case, the pulse “drops” to the ground, but if one is transmitted, then it is quickly restored (about 1 microsecond), but if there should be zero, then the pulse “hangs” on the ground for some time, then returns to one again. Returning to unity is necessary so that the passive device constantly replenishes the energy of the capacitor, and there is power on it. Next, the intercom waits for some time and begins to generate pulses for receiving information, 64 pulses in total (i.e., it receives 64 bits of information). The key is just to match the durations correctly. If he wants to output zero, then he keeps the bus at zero for some time, but if not, then he simply remains silent. The intercom does the rest for him.

Contents of the DS1990A key.
In intercoms, and simply devices where similar devices are used to open doors, a key of the DS1990A standard is used. This device is an 8-byte ROM with information recorded by a laser.


Key dump diagram.

The low byte contains the family code. For DS1990A it will always be 01h. The next six bytes contain the key serial number. The very secret thing that identifies the key. The last byte is called CRC, this is a parity check that ensures the authenticity of the transmitted data. It is calculated from the previous seven bytes. By the way, note that this is not the only standard. There are rewritable ROMs on which information can be stored, and there are also encryption keys. But the whole variety of Dallas tablets is simply impossible to consider in one article; you can read about them on the disk.

Physical device of the key.
Probably, all of the above has discouraged any desire to work with key emulators, because the key must be read, and this is such a hemorrhoid. It turns out not! The Dallas manufacturers took care of us and placed all the information we needed directly on the key, and in hexadecimal at that! It is engraved on it and can be read, and then later sewn into our wonderful emulator.

Key muzzle

From all this information we are interested in the following:

CC = CRC is the parity byte 7th byte in the firmware
SSSSSSSSSSSS = twelve nibls //nibl = 1/2 byte // serial number, i.e. the key itself in hex codes.
FF = family code, in our case it is equal to 01h - the zero byte of our key.

It turns out that we can simply write a program, put the entire key into it, manually copying the dump visually from the real key, and we will get a ready-made emulator. It is enough to simply take the key from your enemy and rewrite what is written on it. Which I generally did with success. :)

Emulator.
Now we have come to the most delicious thing - an intercom key emulator. First, I found a ready-made emulator on some website, installed it in my AT89C51 and it didn’t work (which is not surprising). But it’s not fun to use other people’s firmware and catch other people’s specially left bugs in the code. Therefore, I started making my own emulators and writing my own programs for them. In general, I tried to make an emulator on 6 different microcontrollers, different architectures, belonging to two families of AVR and i8051, all made by Atmel. Not all of them made money, and a lot of programs were written. At first, the general Napoleonic tasks were set to make a universal emulator with the ability to select a key, but then I abandoned this idea due to its messiness and pointlessness, let other people who would be interested in this article take care of it. But the cost of the emulator, not counting the labor expended, is less than 70-80 rubles, you can even keep it at 30 rubles if you do it, for example, on ATtiny12.

The principle of operation of the emulator.
We have examined in some detail the principle of operation of the intercom, and accordingly it will not be a big problem to describe the algorithm of the DS1990A emulator program. We look carefully at the diagram and think about what needs to be done. And you need to do the following. The leg of the microcontroller hanging in the air (not yet connected to the ground, the reset pulse) will be considered a logical unit by the controller. It means that after supplying power to the controller, we must wait until our leg goes to the ground, and to zero. As we heard zero, we rejoice, wait a while and switch the port from read mode to write mode. Then we drop the bus to zero and hold it for a while - we generate a PRESENCE pulse (see the pulse duration in the datasheet). Then we switch the bus to read mode again, and wait for what the intercom master will tell us. He will tell us a read command consisting of 8 bits. We will not decode it, because... in 99.999% of cases he will tell us the command to give his dump, a la 33H, we just count 8 pulses and don’t worry. We wait further. And the most difficult and interesting part begins - we need to quickly look at what the intercom is telling us and answer it quickly too. We need to output the serial number bit by bit, consisting of the 8 bytes that I mentioned above. I did it in the following way (no matter what microcontroller, the principle will be the same everywhere), loaded a byte into some free register, and shifted it to the right, and looked at the carry bit. As soon as the intercom drops the bus to zero, then if my carry flag is set to one, then I simply remain silent for this impulse and wait for the generation of the next bit reading impulse from the master. If I have a zero in the transfer flag, then after the intercom drops the bus to zero, I switch the microcontroller port to output mode and forcefully hold the bus at zero for a while, then release it and switch the controller port back to read mode. Based on the duration of the pulse in the ground, the device master understands whether a one or a zero was transmitted to it. In principle, that’s it, then the intercom should beep joyfully and open the door.

Practice.

Tester board. Seeing the inscription Dallas.

After a little hesitation and a war with the debugger, the code turned out. Here is an example of the data output code for the intercom on the AT89C2051. (In general, the AT89C2051 is a popular, but outdated controller. One of the first that I programmed. The peripherals are minimal, the memory is also nothing. It can only be sewn with a high-voltage programmer. Although there is a new replacement for it, the AT89S2051, it can already be flashed in-circuit through some kind of AVR ISP, and maybe through AVRDUDE - I haven’t checked. The most interesting thing is that it is compatible with ATTiny2313, so the code can be ported to Tinka. Note: DI HALT)

DI HALT:
We wrote this hellish code with Dlin back in 2006 in his apartment. They were laughing to the point of hiccups over their stupid things. That was the first time I touched AVR. I sat fiddling with a procedure for reading from EEPROM in an assembler that was completely unfamiliar to me, while Dliny was tinkering with a demo board for his future emulator. I especially remember my joke with the watchdog, when my MK was reset while writing to EEPROM and cutting out an i2c memory chip from the board using a cutting wheel. Eh... never mind, I’ll drive you to Moscow and we’ll have a blast again!

;===================================================== ; Serial serialization; in: R0- address where the serial number with the tablet type and CRC8 is located; USES: A,B,R0,R1,R2 ;==================================================== =================== DEMUL_SendSer: mov R2,#8 SS3: mov ACC,@R0 mov R1,#8 SS2: JB TouchFuck,$ ;waiting for the tire to be dropped in zero 1->0 RRC A ;C:=A.0; shift A; mov TouchFuck,C ;TouchFuck:=C; MOV B,#9 DJNZ B,$ ;Delay 20 us setb TouchFuck JNB TouchFuck,$ ;cycle while 0 DJNZ R1,SS2 inc R0 DJNZ R2,SS3 ret ;=============== =======================================================

Results.
As a result, I got a lot of emulators. True, some of them still need to be brought to fruition. Although a few are 100% working. You can see examples of emulators in the photos.



Photos of emulators

The most interesting is the CRC check, which is carried out by the intercom. You will need this if you want to install a Dallas lock on your computer, for example. An example of calculating CRC on the A89C2051 (although this code will work on all microcontrollers of the i8051 family.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 DO_CRC: PUSH ACC ;save accumulator PUSH B ;save the B register PUSH ACC ;save bits to be shifted MOV B,#8 ;set shift = 8 bits ; CRC_LOOP: XRL A,CRC ;calculate CRC RRC A ;move it to the carry MOV A,CRC ;get the last CRC value JNC ZERO ;skip if data = 0 XRL A,#18H ;update the CRC value ; ZERO: RRC A ;position the new CRC MOV CRC,A ;store the new CRC POP ACC ;get the remaining bits RR A ;position the next bit PUSH ACC ;save the remaining bits DJNZ B,CRC_LOOP ;repeat for eight bits POP ACC ;clean up the stack POP B ;restore the B register POP ACC ;restore the accumulator RET

DO_CRC: PUSH ACC ;save accumulator PUSH B ;save the B register PUSH ACC ;save bits to be shifted MOV B,#8 ;set shift = 8 bits ; CRC_LOOP: XRL A,CRC ;calculate CRC RRC A ;move it to the carry MOV A,CRC ;get the last CRC value JNC ZERO ;skip if data = 0 XRL A,#18H ;update the CRC value ; ZERO: RRC A ;position the new CRC MOV CRC,A ;store the new CRC POP ACC ;get the remaining bits RR A ;position the next bit PUSH ACC ;save the remaining bits DJNZ B,CRC_LOOP ;repeat for eight bits POP ACC ;clean up the stack POP B ;restore the B register POP ACC ;restore the accumulator RET

Conclusion.
As you can see, intercom keys are not as simple as they seem. However, they can be emulated by anyone who knows programming and a soldering iron.

DI HALT:
Deeds of bygone days, deep legends... Long - WDR! (will be clear only to the initiated;)))))

Pre-edited version of an article from Hacker magazine

Nowadays, various electronic locks with electronic keys in the form of a “tablet” or “flash drive” are very popular. The key is a storage device in which a certain digital code is stored. And the basis of the lock is a microcomputer, which reads and analyzes this code.

I will not argue about the advantages and disadvantages of such locks; I simply bring to the attention of readers my development of a similar device operating on an analog principle.

The essence of the matter is that in my lock the key is a zener diode for a certain stabilization voltage. If the zener diode in the key matches the stabilization voltage with the zener diode in the lock, the door opens.

Moreover, outwardly everything looks as if it is a digital lock with a digital key. Of course, the number of “code combinations” of my lock is disproportionately less than a digital one, but... who knows that you need to select a zener diode? I can imagine the hysteria of an “advanced” thief trying to guess the digital code to my lock.

The diagram of the first version of the lock is shown in Figure 1. The key is connector X1.1, which is connected to the mating connector X1.2. Ideally, you need to use a housing from a tablet key, such as an iButton, and the corresponding connector for connecting it. But you can make any imitation, or use any two-pin connector pair, for example, from audio equipment.

Fig.1. Schematic diagram of a combination lock for working with an analog tablet.

The key contains a zener diode, in this case, 8.2V, and a 1N4148 diode connected in series with it. When connected to connector X1.2, they and resistor R1 form a stabilized source of constant voltage equal to the sum of the zener diode voltage and the forward voltage of the diode.

A two-threshold comparator is made on the comparators of the A1 LM339 chip. The reference voltage at its inputs is set by a circuit consisting of resistor R2, two diodes VD4, VD5 and a zener diode, the same as in the switch.

When you connect your own key, a voltage is established on pins 4 and 7 of A1, which is greater than the voltage on the pin by the amount of forward voltage on the 1N4148 diode. 6 A1.2 and the same amount less voltage at the pin. 5 A1.1.

Thus, the voltage at pins 4 and 7 of A1 connected together is between the voltages at pins 6 and 5. As a result, the voltage at the direct input of A1.1 will be less than at the inverse input, and at the output it will be unity. In exactly the same way on A1.2, the output is one. The key on transistor VT1 opens and supplies current to relay K1.

If the zener diode in the key is not at the same voltage as in the lock, then at least one of the comparators will be at zero at the output, and the voltage at the base of VT1 will not be enough to open it.

The peculiarity of the LM339 microcircuit is that its outputs are made according to public key circuits, so they can be connected together, but they must be connected to the power positive with a resistor (R3). Of course, the zener diodes do not have to be 8.2V, they can be for any voltage from zero to 10V, but they must be the same.

Capacitor C1 serves to slow down the response to the correct voltage, so that accidental opening does not occur if pulses or some kind of alternating voltage are received at the input. So to speak, protection from accidents.

Fig.2. Diagram of a more complex lock with a double analog key.

The diagram of a more complex lock is shown in Figure 2. A key in the form of a flash drive is used here. It is very similar to a flash drive, it has the same USB connector, but instead of a memory chip inside there are only two zener diodes and two diodes. Now the “secrecy” of the castle is twice as great.

And all comparators of the LM339 chip are used. There are two zener diodes in the key, they can be the same, they can be different, but it is important that VD2 is the same as VD3, and VD7 is the same as VD11.

Relay K1 type KUTS-1M, from an old Soviet TV. This relay has a high-resistance 12V winding, and two closing contact pairs, for a current of up to 2A each at a voltage of 220V. But you can choose an imported analogue, the winding should be 12V and the current should not exceed 30mA.

No setup required. It is very important that all the diodes are the same, and the zener diodes in the key are exactly the same as in the lock, and from the same batch.