(Total beginner)How to wire a cabin lock and esp32, shopping list?

Sensacell

Joined Jun 19, 2012
3,432
Step 1 is to determine the electrical specifications of the lock mechanism.

Step 2 is develop a simple interface circuit between the logic output of the ESP32 (3.3v) and the lock.
This could typically be a MOSFET or Transistor, or a relay.

Waiting for you to finish step 1.
 

Thread Starter

RealBlackKnight

Joined Jan 5, 2023
5
From the website description it seems 12 V

"3. There are red and black control input lines behind the lock of the electric control cabinet: the red and black lines are the electric lock power lines (DC12V and GND), and the positive and negative poles are not distinguished."
 

Ya’akov

Joined Jan 27, 2019
9,070
Welcome to AAC.

Your question is a bit light on detail to get a good answer. The lock you are looking at required 12V@2A to operate. An ESP32-based development board will, on its own, only have a maximum output of 5V at a few tens of mA. They are not directly compatible.

The MCU (MicroController Unit, that is, your ESP32-based dev board) with control the power supply that operates the lock, it won‘t operate the lock itself.

But, you are quite ahead of yourself. The specification of “an ESP32” is very much cart-before-the-horse stuff. There are many, many options for an MCU/development board and choosing one will depend on your application.

”Read data from somewhere” is so vague as to be useless in helping you specify the parts involved. Please step back and describe the problem the locking system is intended to solve, not the solution to that problem, which the parts are supposed to be. That way, instead of your guess at what might work we can help you design something that solves the problem.

One of the best ways to do this is with “user stories”. If you could explain what is happening both from the point of view of the user securing the cabinet and the user accessing the cabinet it will provide a very good starting point.

Something like:

“…we have a cabinet full of inventory controlled supplies and we need to secure it so that a person removing them from it first has to fill out a request web form and get approval…”,

and;

“…the user goes to the website and fills out the form, they are notified when it is approved and provided with a link that gives them a one-time unlock button they use from their phone when they are at the cabinet…”.

Of course that is completely fabricated only as an example.

What you want to do should not be hard, but unless you start out correctly it will turn out to be.
 

MisterBill2

Joined Jan 23, 2018
18,176
If the concept is to prevent access to an electrical controls enclosure , (cabinet), I suggest that an electrically operated lock may not be a best choice, because if there is an electrical fault that requires access to the enclosure, there may not be power available to release the lock.
Of course, we are missing all of the details about the application so this is just a general consideration.
 

Thread Starter

RealBlackKnight

Joined Jan 5, 2023
5
That make sense, here is the background story, TLDR is we are trying to build sth similar to the package locker we see today. but for the brick and mortar retailer.

Not sure if you guys noticed/heard, nowadays US retailer especially in CA are forced to lock their expensive product in their shelf because the so called "shrinkage" problem, this create a really bad customer experience. (the issue pretty common, for 1 in 3 stores I visited for feedback during that trip, I witnessed a shrinkage happening in front of me. it's crazy)

So our idea is to create a app and smart lock, so good customers can open the locked case via an app without need to push a button and have store employee to help.

I am wondering if ESP32 could be good fit(recommended by ppl I talked online) for our use case, as I image the most common case can be,
customer open the app, scan a QR code printed on the case, then the app will make a network call, the backend server then receive the call. and the control board either make a pull or listen to the callback from the backend server, and then open the lock once

The another use case I can think is, if user open the lock in the app, but didn't open the case, the lock should be reset somehow by itself?
 

MisterBill2

Joined Jan 23, 2018
18,176
AN Interesting problem indeed. That is a reason why counter service makes more sense. Talk to a human who can deliver the item as negotiated. And the bad actors are asked to leave, with their images being already logged on the video system. Still a brick and mortar store, but not a browsing place any more. One more reason why I would not visit that state.
The challenge is how to detect the good customer wanting the product, without a whole lot of sensors such as video cameras, and the associated system smarts. That gets complex and expensive rapidly. And the unlock hardware becomes a big cost burden rapidly, as more individual compartments are added.
 

Thread Starter

RealBlackKnight

Joined Jan 5, 2023
5
Indeed, we are entertaining different ideas how to evaluate customer, we do have ppl who are software veterans on that front, on the other hand the blocker for us right now is, suppose the software for that exist, we don't know how to control the lock as none of us know anything about hardware.

My current collected info seems like may be we use pc or a pi board as a central controller unit per store, which can receive command from the backend server, then somehow the central unit can magically talk to different smaller controller unit (or directly to the lock) to perform the action?
 

MisterBill2

Joined Jan 23, 2018
18,176
The big deal with controlling the lock is that the wires need to be secure also. As well as the portion that does the switching of the lock power. The commercially made locks I have seen all work on 24 volts AC, so no shock hazard, but beware of the bad actors coming in with a 20 volt power tool battery to trick the lock. And YES, that could work quite easily.
 

Ya’akov

Joined Jan 27, 2019
9,070
So, what you want to do is not very difficult. Building a proof of concept prototype is easy. There will be a lit of refinement required from lessons learned as you try to actually implement it, though.

First, the role of the MCU in your case is a trivial one. There is no reason to spend the money on an ESP32-based solution. Something as cheap and an ESP-01 (ESP8266-based, dirt cheap) module can do the job.

The idea is to have the ESP-01 connected to a private, secured, 2.4GHz WiFi network, one per lock. The ESP-01 will listen for an unlock signal from whatever is doing Comnand & Control—this could be a PC or Raspberry Pi—but practically speaking RPis are currently effectively unavailable since the price of one will buy a small SBC (Single Board Computer) of the conventional PC type.

The unlock signal will cause the ESP-01 to pulse the lock for a fixed internal, say, 1 second to give the user time to open the door. After that, the lock will re-engage.

A variation on the lock you linked to includes a sensor to determine if the door is open, though a separate switch can be used as a sensor as well. This can be used to “close the loop” and ensure the door had been opened, allowing the user to activate the unlocking again if they didn’t open the door, for example.

If can also be used as a pilfer alarm, signaling to the C&C device if the door is opened without authorization (forced, or otherwise bypassed).

The ESP-01 would have on GPIO pin connected to a switching device (MOSFET, relay, etc.) that would connect the power supply to the lock. Note that this would occur in a secured place (e.g. inside the box, in a separate secured box, etc.).

The only wired going into the box would be a constant supply sufficient to operate the lock. This would also be used to derive the power supply for the ESP-01 with a suitable DC-DC converter.

With this configuration it would not be possible to influence the lock from outside with signals on the wires going in.

As far as direct manipulation of the ESP-01 over the network, a simple cryptographic scheme using ordinary PKI encryption would prevent all but the most determined attackers from such manipulation. Additionally, supervision (polling the lock controllers) and reporting of any activations to the fixed C&C device would alert the system of any breaches.

So, to start, it’s a cheap and cheerful ESP-01 board, the lock, a C&C computer of some kind, a 2.4GHz secured network, and a 12V ~3A power supply will get you a prototype.
 
Top