Arduino fingerprint lock stepping on the pit



I believe many electronics enthusiasts want to do something like electronic development board at the beginning. There are many development board platforms: STM32 series, esp series, FPGA series, and of course, today’s protagonist – Arduino series. Many people may have started to drum up these tiktok devices to achieve some automation equipment, and I started to do it when I saw someone making fingerprint locks on the shaking. Although this thing is specialized in electronics, it’s not difficult to listen to the introduction, so I also want to be a non professional. Who makes me very interested in this thing. Don’t talk much, be talented! (it’s actually a rollover record) woo woo~

Step on the pit

  • Hardware

  1. Try to buy the steering gear with all metal movement.The steering gear of mg996r is cheap (more than ten yuan) and more expensive (more than twenty yuan). Before buying, be sure to ask the store owner whether the steering gear movement is pure metal. Because the gears outside some steering gear are metal, but the disassembled gear sets are all plastic. In this way, something with a heavy load may slip the wire (at that time, I thought the steering gear was the same as an ordinary motor, and the movement and external gear were straight through. There was no power to turn the steering gear forcibly, just listen to a click, and the wire slipped). After the wire slipped, it was equivalent to directly scrapping.
  2. Don’t buy 360 ° version of steering gear.The 360 ° version is controlled by changing the steering gear speed through PWM, which will be very troublesome to control unlocking. The version below 180 ° uses PWM to change the rotation angle of the steering gear, which is very convenient.
  3. The load motor of the development board shall be added with relay module or motor drive module as far as possible, and the steering gear shall not be directly connected to the development board.When the board loads such pure electric energy conversion components, the current is generally large. If the intermediate relay is not added, the most intuitive phenomenon is that the on-board LED will darken as soon as the steering gear is started. At this time, you will obviously feel that it is difficult to drive the steering gear. After the program runs several times, it will get stuck inexplicably. More seriously, in other projects, it is possible to burn the development board directly.
  4. The relay has high-level trigger, low-level trigger and compound trigger

    Low level triggered relay

    Composite trigger relay

    These relays are connected to the in end of the relay with the development board, and control the opening and closing of the relay by changing its high and low levels (I just bought a low-level trigger, just bought it, and accidentally contacted all the VCC, GND and in of the relay. The relay snapped, but then it didn’t sound. I thought it was broken, so I simply ignored it(Remove)The peripheral circuit is directly connected to the blue part and used as a high-level trigger. Later, I learned that there are two trigger modes – both caused by not looking at the instructions carefully)
  5. If you want to connect the IIC screen, the two pins of SCL and SDA can be directly connected to the corresponding pins on the board. In the routines of some purchased components, you can connect them to A0, A1 or A4 and A5. Sometimes, the screen may not light up, which should be caused by the absence of positive pins in the library.
  • Software aspect

  1. Use of the Arduino library.When the Arduino ide was first downloaded and installed, several libraries came with itFor example。 These libraries are all there\Under the software installation directory \ LibrariesIn this folder, don’t bother to find it. Just reference it directly.
  2. The serial port monitor cannot be opened in two software at the same time.For example, if you want to upload a program and find an upload error, you can see whether the upload port is occupied. If two serial port programs are opened at the same time, it is likely that a serial port program will crash and cause unnecessary trouble.
  3. When uploading the program, unplug the connection between port 0 and port 1 of the board.Because the upload program occupies these two ports. You can change part of the code that needs serial communication into soft serial port, so you don’t have to worry about these two ports when downloading.
  4. When a group of hard serial ports and a group of soft serial ports appear in the program, it is necessary to distinguish the corresponding serial port baud rate.for exampleInstance code in LibraryFingerprint
#include SoftwareSerial mySerial(2, 3);
// On Leonardo/M0/etc, others with hardware serial, use hardware serial!
// #0 is green wire, #1 is white
#define mySerial Serial

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

void setup()
  while (!Serial);  // For Yun/Leo/Micro/Zero/...
  Serial.println("\n\nAdafruit finger detect test");

  // set the data rate for the sensor serial port
  if (finger.verifyPassword()) {
    Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor :(");
    while (1) { delay(1); }
  • There are two serial port initialization in the code.
    • Hard serial port——On line 13Serial.begin(9600);It corresponds to the serial name defined by myserial in line 6, and myserial is defined by the keyword software material in line 2 – this corresponds to the serial port between MCU and computer.
    • Soft mouth——On line 19finger.begin(57600);Corresponding toThe serial port defined in this library is used to communicate between fingerprint module and MCU.
  • Because the baud rate of the soft serial port is not set correctly, it often leads to the failure of communication between the board and the fingerprint module. For example, the baud rate in line 19 of the above code is set to 57600, while the default of the general fingerprint module is 9600. As a result, the fingerprint module cannot be identified.

In the follow-up, you can add a display screen, voice prompt, audible and visual alarm to the fingerprint lock, and write it later!

Recommended Today

Elasticsearch Foundation

1、 Basic concepts of ES 1.1 index An index is a collection of documents with somewhat similar characteristics. An index is identified by a name (required)It must be all lowercase letters), and we should use this name when we want to index, search, update and delete the documents in this index. Any number of indexes […]