# Hooking up deadbolt motor to TB6612FNG Stepper Motor Controller

#### StealthRT

Sep 4, 2010
138
Alright so I finally got around to testing out the limit switch. Seems the Left pin is Gnd and the middle pen is voltage and the right pin is na.

Measuring the limit switch its 0vdc when not engaged and 3.3v when it is engaged.

So knowing that, wouldn't it be best to use an Analog input for measuring the voltage?
Code:
floatvoltage=limitSwitchValue*(3.3/1023.0); //Using 3.3v for max limit switch voltage

What would be the best resistor to use to make sure it pulls all the way down to 0vdc?

#### hevans1944

##### Hop - AC8NS
Jun 21, 2012
4,739
It's a switch, either open or closed, and that means there are only two states to sense: 0 or 1. A digital input is designed to accommodate this.

If one terminal of the switch is Gnd (or circuit common) you connect that to your microprocessor digital common. Connect the other input to a microprocessor digital input. You may need to pull it up to Vcc with a 10 kΩ resistor. Or use the internal pull-up resistor that many microprocessors provide for digital I/O. Read the datasheet to see if one is provided.

Do not
apply power supply voltage to the switch terminal you describe as "the middle pen is voltage" without using a resistor between the power supply and the switch terminal. If you read a voltage there when the switch is engaged, and the switch is still connected to the original circuitry, then power is being provided by the original circuit. In that case there is nothing for you to do: this middle pin is your digital signal. It will be at logic 0 when the switch is closed, and pulled up to logic 1 with a resistor to Vcc when the switch is open. Detect these two states by using a digital input port on your microprocessor.

Go back and read my post #20.

#### StealthRT

Sep 4, 2010
138
I failed to mention that I will be using a ESP8266 esp-12F so I'm not sure that has the pull up?

#### StealthRT

Sep 4, 2010
138
is this the correct way of doing it? of course it would be an esp8266 and not an Arduino board and using 3.3v instead of 5v:

#### bashNinja

Aug 25, 2018
2
Ah it seems to be working now. YAY!

Just need to tweak the code a little and hook up the limit switches to the analog inputs and see if i get readings from them. That would just consist of grounding one side and running the other to the arduino analog pin, correct?

I know this is almost 2 years later, but did you ever happen to get this code working? And what did you do differently to get your up and going?

I've purchased the very same lock and am going down the path you've gone here. If you've got any more detail on your setup with your Esp8266, I would really appreciate it.

#### hevans1944

##### Hop - AC8NS
Jun 21, 2012
4,739
I know this is almost 2 years later, but did you ever happen to get this code working? And what did you do differently to get your up and going?

I've purchased the very same lock and am going down the path you've gone here. If you've got any more detail on your setup with your Esp8266, I would really appreciate it.
You (or a Moderator) should start a NEW THREAD for this. Note that the original title of THIS THREAD is "Hooking up deadbolt motor to TB6612FNG Stepper Motor Controller". There is NO MENTION of the ESP8266 ESP-12E WiFi Module until @StealthRT's posts #23 and #24, and then nothing more until your recent post #25.

So... please start a new thread and tell us WTF you are trying to DO with your motorized dead-bolt lock. Do you need a WiFi connection to the lock? Are you trying to control the lock from your cell phone perhaps? Are you trying to eliminate battery operation (not a good idea if there is a power failure that would lock you out!), or control your lock from an Arduino or other microcontroller or microprocessor?

#### bashNinja

Aug 25, 2018
2
I appreciate your feedback @hevans1944. I was rather hoping that @StealthRT would return to this thread. He has been active on this forum, even up until this current month, so I hoped he would be willing to detail the results of his project for me or anyone else that might be interested.

It would be very helpful for me to read about the experiences and methods used by someone who had attempted a project using this lock previously (as we have the very same hardware/lock) so that I can use that knowledge to guide my own personal project.

You are right, I have my own set of desires and goals with my project. I am currently in the design and research phase, trying to decide what method I'm going to use to accomplish my goals. I have not yet gotten to the point of where I wanted to ask for direct help. When I do and if I am unable to solve it on my own, I will certainly follow your guidance, starting a new thread, and detailing the requirements of my project. Again, I appreciate your post and your feedback on my previous comment.

#### hevans1944

##### Hop - AC8NS
Jun 21, 2012
4,739
Good luck getting any information from @StealthRT. I have read some of the threads to which he posted and noticed that most ended rather abruptly without any significant feedback from him. He is what I call a "drive by" poster, lingering only long enough to get whatever information he needs from us without informing the community of his results (if any). He then goes on to his next "project" a few weeks or a few months later. I suppose there is nothing wrong with that because, after all, we are here to help those who help themselves. I just sometimes wish the successful ones would come back and tell us how they did it, with or without our help.

I have a somewhat limited experience with electrically actuated locks, dating back to the 1980s when I was actively working with the intelligence and reconnaissance community. The entry doors to our facility used electrically actuated, commercial, dead-bolt latches, programmed with (IIRC) a set of four or five center-off, two-position, rocker switches that had to be pressed in the correct order for the mechanism to momentarily energize. Over the next twenty or so years I witnessed several ingenious schemes used to actuate the lock mechanisms while preserving the "security" of the system against un-authorized entry.

Later, I became the facility manager for a small club that initially issued physical door keys to current members whose dues were paid up. Keeping track of, and preventing unauthorized duplication, of those keys became a logistical nightmare. So, I recommended to our board of directors, of which I was just one voting member, that electronic latches be installed on the entrance doors. After several meetings and tedious discussions my suggestion was approved. This required no changes to the lock mechanism, just the installation of a striker plate with a solenoid release mechanism that allowed the door to be pulled open when actuated with a card key. Again, this was a standard commercial, off-the-shelf, system.

The doors were then re-keyed by the locksmith who installed the new striker plates so that none of the previously issued keys would open the doors, but a limited set of the new keys would. This worked fine initially, and AFAIK it still does. But it has the same deficiency as the original setup: unless strict control of the new keys is enforced, unauthorized duplication of those keys compromises the security of the building. I left my elected position as a member of the board of directors when my term expired, deciding not to pursue election to another position. The politics involved in getting anything done was simply too frustrating! And it seemed that every single board member had a "need" to be issued one of the "master" keys that by-passed the electronic locking mechanism.

Another locking mechanism that is quite effective in an institutional setting is the electromagnetic locking plate that prevents a door from opening until the electromagnetic field is de-energized. Not much current is required to maintain the magnetic field, which is applied across a fairly large area, and no moving parts are required. It has the "advantage" that the locks may de-energize to allow the doors to open when power fails, or during an emergency evacuation situation, such as a fire. I have seen these extensively used in hospitals to control admission to restricted areas.

Replies
3
Views
711
Replies
1
Views
1K
Replies
2
Views
823
Replies
12
Views
854
Replies
1
Views
877