Silicon ChipMake it with Micromite - December 2022 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Subscriptions: PE Subscription
  4. Subscriptions
  5. Back Issues: Hare & Forbes Machineryhouse
  6. Publisher's Letter: Soldering surface-mount devices
  7. Feature: Giant Boost for Batteries by Mark Nelson
  8. Feature: From virtual reality to virtue signalling by Barry Fox
  9. Feature: Net Work by Alan Winstanley
  10. Project: The Hummingbird Audio Amplifier by Phil Prosser
  11. Project: USB CABLE TESTER by Tim Blythman
  12. Project: SMD Trainer Board by Tim Blythman
  13. Project: SMD Soldering Tips & Tricks by Tim Blythman
  14. Feature: AUDIO OUT by Jake Rothman
  15. Feature: Circuit Surgery by Ian Bell
  16. Feature: Make it with Micromite by Phil Boyce
  17. Feature: Max’s Cool Beans by Max the Magnificent
  18. PCB Order Form
  19. Advertising Index

This is only a preview of the December 2022 issue of Practical Electronics.

You can view 0 of the 72 pages in the full issue.

Articles in this series:
  • (November 2020)
  • Techno Talk (December 2020)
  • Techno Talk (January 2021)
  • Techno Talk (February 2021)
  • Techno Talk (March 2021)
  • Techno Talk (April 2021)
  • Techno Talk (May 2021)
  • Techno Talk (June 2021)
  • Techno Talk (July 2021)
  • Techno Talk (August 2021)
  • Techno Talk (September 2021)
  • Techno Talk (October 2021)
  • Techno Talk (November 2021)
  • Techno Talk (December 2021)
  • Communing with nature (January 2022)
  • Should we be worried? (February 2022)
  • How resilient is your lifeline? (March 2022)
  • Go eco, get ethical! (April 2022)
  • From nano to bio (May 2022)
  • Positivity follows the gloom (June 2022)
  • Mixed menu (July 2022)
  • Time for a total rethink? (August 2022)
  • What’s in a name? (September 2022)
  • Forget leaves on the line! (October 2022)
  • Giant Boost for Batteries (December 2022)
  • Raudive Voices Revisited (January 2023)
  • A thousand words (February 2023)
  • It’s handover time (March 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • Prophecy can be perplexing (May 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • How long until we’re all out of work? (August 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • Holy Spheres, Batman! (October 2023)
  • Where’s my pneumatic car? (November 2023)
  • Good grief! (December 2023)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (February 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk (July 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk (November 2024)
  • Techno Talk (December 2024)
  • Techno Talk (January 2025)
  • Techno Talk (February 2025)
  • Techno Talk (March 2025)
  • Techno Talk (April 2025)
  • Techno Talk (May 2025)
  • Techno Talk (June 2025)
Make it with Micromite Phil Boyce – hands on with the mighty PIC-powered, BASIC microcontroller Part 42: PicoMite Fingerprint Reader – Part 1 Fig.1. Various fingerprint modules are readily available online, priced from £15 upwards. We are using the R503 model (top left) in this article, which costs around £22. B eing able to recognise different fingerprints is a useful biometric feature to add to an electronics project, especially one that involves an element of security. By identifying different people from their unique fingerprint, it becomes possible to distinguish between authorised and unauthorised users, thus allowing a specific action to be performed (or not). Real-life examples of how fingerprint readers are used include: controlling access to a locked door (via a solenoid or electromagnet), turning on a device such as a computer, or even triggering a cashless payment. 58 So, how could we have fun with a fingerprint reader in a project closer to home? Perhaps the classic Electronic Combination Lock project (PE, December 2019) could be updated, or maybe you could switch your home-security system on and off. Whatever the application, a fingerprint reader must primarily be capable of reading a fingerprint, and then determining who it belongs to, and hence if it belongs to an authorised user, or not. Fingerprint modules If you search online, you will see that there are many fingerprint modules readily available – see Fig.1 for some examples. They start from around £15 for something basic that a hobbyist might use, to units costing many hundreds of pounds which are designed for commercial use. Even the cheaper fingerprint modules pack an impressive number of features and capabilities. For example, they typically contain either an optical or capacitive sensor, which feeds image data to an onboard microcontroller for converting any detected finger into a ‘template’ pattern. Some fingerprint modules include other elements such as LEDs, a sounder, or a vibration-motor for tactile feedback. Practical Electronics | December | 2022 It must be stressed that the main element of a fingerprint module is the sensor that can detect a finger, and subsequently generate ‘image data’ from the fingerprint placed on the sensor. Typically, a fingerprint module needs to be connected to some form of intelligence to create a complete fingerprint reader unit that can decide what to do with captured image data. Generally, the cheaper fingerprint modules are connected to something like an Arduino, or Raspberry Pi, for which some basic example software (or experimental code) is available for download. However, the datasheets for these cheaper fingerprint modules tend to contain errors, and hence any downloadable software is often incomplete, or simply won’t work at all; but occasionally you might come across some application software with functionality that actually does what it is meant to do! I was recently sent a low-cost fingerprint module in error(!), so I set myself the challenge of hooking it up to a PicoMite (instead of the usual Arduino or RPi). Armed with a couple of different (contradictory) versions of the datasheet, I was determined to get it working. After connecting it up, I started writing some simple MMBASIC code to see if I could get a response. Remember that a fingerprint module contains an onboard microcontroller, so the PicoMite needs to send valid commands that the fingerprint module recognises for it to do anything. After a short while I had successful communication, and from that point on, all I had to do was work through the steps outlined (very poorly) in the datasheet with the aim of creating a standalone PicoMite fingerprint reader; and there – thanks to the poor documentation – is where the real fun started! With patience, I made progress, and this month we will show you how to connect a low-cost fingerprint module to the PicoMite. We will then look at the structure of any message that is either sent to, or returned from, the fingerprint module. And by using a simple program we have written, you will be able to send any valid command that the fingerprint module recognises, and also know how to interpret the response it sends back. B e f o r e w e s t a r t , h e r e ’s s o m e terminology which will help clarify how to use a fingerprint module. Fingerprint module vs fingerprint reader A fingerprint module comprises a sensor, and an onboard microcontroller. By sending any valid command to its Practical Electronics | December | 2022 microcontroller, the module can be made to perform a specific task. Two main tasks that the module can perform are detecting a finger placed on the sensor and extracting image data from a fingerprint placed on the sensor. Another capability (for the module we’ll be using) includes controlling a built-in ring LED located around the sensor. Note that the module needs to be told what task to perform by an external intelligent controller. When a fingerprint module is connected to an intelligent controller, the result is a complete fingerprint reader unit that can do something useful. The controller sends commands to the module and the module performs the necessary task. On completion of the task, a response is sent back to the controller. By sending a precise sequence of tasks to the module, specific actions can be performed, resulting in a functional reader. Image data vs template pattern Once a finger has been detected, the intelligent controller sends a command to the module (ie, a task request) to generate image data of the fingerprint located on the sensor. Generally, two images are taken and these are ‘averaged’ to create a template pattern. This new template pattern is compared with stored template patterns when determining a user’s identity. Each template pattern is stored alongside a unique ID number, and any matched template pattern returns the corresponding unique ID number in the response back to the intelligent controller (more on this next month). Note that we will often refer to a template pattern simply as a ‘template’. Templates are essential for successful operation of a fingerprint reader; without stored templates it is not possible to determine who the user is, and hence whether they are authorised. The template pattern generated is either stored internally in the module’s memory (along with any other templates) or it can be uploaded to the attached intelligent controller to be stored elsewhere. Note that we don’t need to upload templates to the PicoMite as the fingerprint module we are using has enough memory to store up to 200 templates. Enrolment vs Searching To register a new user (ie, store a lookup template for them), a process called ‘enrolment’ is performed. Enrolment means that their template is generated (from two sets of image data) and then stored against a unique ID number. A precise sequence of specific tasks sent by the intelligent controller results in enrolment being performed. ‘Searching’ is simply the action of comparing a fingerprint with stored templates. A response back to the intelligent controller will confirm whether a match was found (or not). If a match is found, then the user is identified, and the intelligent controller can decide if the user is authorised (or not), followed by appropriate action. The R503 module We will now look at the specific fingerprint module that we will be using, the R503. The choice was a simple one – it was the model sent to me in error when ordering a GPS module! Checking the datasheet (available for download from the December 2022 page of the PE website), it appeared to be an excellent module, offering some nice features, with the bonus of a low price – around £22. The R503 is built into a rugged metal body which makes it very easy to panel mount; something a lot of modules overlook. It inserts into a 24mm-diameter hole, affixed with an included nut. It is based on a capacitive sensor, which is generally regarded as performing better than an optical sensor. There is a builtin digital signal processor (DSP) chip which simplifies overall use since it performs all the algorithms normally associated with fingerprint processing. This mean that we won’t get involved with any of the ‘complex stuff’. The R503 module is a serial device that communicates with an external controller, in our case, the PicoMite. Serial data is sent at a default baud rate of 57,600 (which can be changed if needed). It can operate at 3.3V, which is perfect for us since the PicoMite has a maximum input voltage on any I/O pin of 3.6V. Operational current consumption is low at 20mA, and it has an average sleep current of 2µA should it need to be powered from a battery. It can store up to 200 fingerprint templates in its own Flash memory, and it also has a built in bi-colour LED which provides a nice ring effect around the sensor. On the module sent to me, there is a red/blue bi-colour LED, so purple can also be generated. However, while researching this project, I read that other colour LEDs may be supplied instead. Note that most operational features of this fingerprint module (including the bi-colour LED) are controlled by commands that are sent to it from the attached intelligent controller (ie, the PicoMite). For testing purposes, we will use the LED as a visual confirmation to ensure we are communicating correctly with the module – see later. 59 Red 3V3 Black GND Yellow Tx Green Rx Bue Finger detect White Induction power 3V3 0V GP1 GP0 GP2 3V3 Fig.2. There are six wires coming from the back of the R503 fingerprint module. All six connections need to be made. Connecting the module There are six cables from the module that are terminated in a 6-pin, 1mm-pitch connector. To make it easy to connect to the PicoMite, I recommend this connector is cut off, and six short female DuPont leads are soldered in its place. All six cables need to be connected to the PicoMite, as shown in Fig.2. The red and white cable are both connected to 3.3V, and the black cable to 0V. The serial connection is on the yellow and green cables. Yellow is the transmit (Tx) output from the module that needs to connect to a receive (Rx) COM pin on the PicoMite – here we will use GP1. Green is the receive (Rx) pin on the module that connects to a transmit (Tx) COM pin on the PicoMite (GP0 in this case). This leaves one more connection, which is referred to in the datasheet as the ‘WAKEUP’ pin. However, I like to refer to it as the ‘Finger Detect’ pin. It is an output pin from the module that connects to an input on the PicoMite (in this case we will use GP2). When no finger is present on the sensor, the output will be at 3.3V, but when a finger is detected the output goes low. We could use this output signal from the fingerprint module to either wakeup the PicoMite via an interrupt (useful if we were to put the module and PicoMite to sleep), or we could simply monitor the state of GP2 to determine if a finger is currently on the sensor, or not (this latter method is what we will be using). Now carefully make the six connections. Once completed, we will need to test things out. But first, let’s understand the format of any message sent between the PicoMite and the R503. Message structure The structure of any message (to or from the fingerprint module) is best shown diagrammatically. Fig.3 shows there are always six parts to any message, as explained below. 1. HEADER – These are the first two bytes, and they need to contain the hexadecimal (hex) values of EF and 01 respectively. These are fixed in value and represent ‘start-of-message’. 2. ADDRESS – These are the next four bytes, and by default all contain the hex value FF. Note that these bytes can be changed to contain a new address value, but we won’t be altering this value in our application. 3. IDENTIFIER – This seventh message byte is just a single byte which identifies the type of message being sent. Four values are valid: 01 means the message is a ‘Command’. A command message is sent from the PicoMite to the module. Micromite code There is no project code this month, but where applicable, code is available for download from the PE website. 60 02 means the message is ‘Data’: this message could be in either direction and always follows a 01 or 07 message. 07 means the message is an ‘Acknowledge’, meaning it’s a response message from the module to the PicoMite. 08 means the message is the ‘End of Data’. It can follow any of the above messages whenever sending the last chunk of data that in total is more than 255 bytes in length. 4. LENGTH – The next two bytes (byte 8 and 9) indicate the number of bytes remaining in the message; ie, the number of bytes in the next two sections (‘PACKAGE DATA’ and ‘CHECKSUM’) 5. PACKAGE DATA – This will always be at least one byte long, and can be up to a maximum of 254 bytes long (depending on which data sheet you believe!). For a Command message, it contains the specific command number (referred to as the ‘instruction code’ in the datasheet). It also contains any parameters relevant to the specific command. For an Acknowledge message, it contains a response result (referred to as a ‘confirmation code’ in the datasheet) along with any response data. It should be under 253 bytes in length (but if there is more response data, then that is wrapped into either a ‘Data’ message or an ‘End of Data’ message). For either a ‘Data’ or an ‘End of Data’ message, it simply contains the data required to be sent. 6. CHECKSUM – These are always the last two bytes in a message and can be used for error checking. The value contained in these two bytes is the arithmetic sum of all byte values in the IDENTIFIER, LENGTH and PACKAGE DATA. Any overflow is simply ignored. Puting the structure to work To help make the above a little clearer, we will now work through the construction of a simple command message that is sent from the PicoMite to the fingerprint module. This example message will use the command to turn on the blue ring-LED. For completeness, we will also look at how to interpret the response (the ‘Acknowledge’ message) that is sent back to the PicoMite. Note that an Acknowledge message from the fingerprint module will only be sent after receiving a correct Command message. If the Command message contains an incorrect Checksum value, then no Acknowledge will be sent. Constructing a Command message Referring to Fig.3, we will now look at the six sections of the command message to turn on the blue ring-LED. The critical section is the PACKAGE DATA, which contains the actual command number, plus any associated parameters. According to the datasheet, the command to control the ring-LED is ‘Aura Control’, or more specifically ‘AuraLedConfig’. The command number (ie, instruction code) is the hex value 35. It has four parameters that are associated with this command; these are as follows (taken from the datasheet): 1. Control Code – the LED mode: Breath (01), Flash (02), On (03), Off (04), Fade-On (05), Fade-Off (06) 2. Speed (00-FF) – the speed applied to either the Breath, Flash, Fade-On, or Fade-Off function 3. Colour Index – the colour of the ring-LED: Red (01 ), Blue (02), Purple (03) 4. Times – the number of cycles: 00 = infinite, otherwise 01-FF. Applies only to Breath or Flash modes Now that we know the above values, let’s construct the Command message: Practical Electronics | December | 2022 different colour, and then change the speed of the flashing. Also, try other parameter settings. HEADER [2] ADDRESS [4] IDENTIFIER [1] LENGTH [2] PACKAGE DATA [PD_Qty] CHECKSUM [2] Note that you do not need to calculate 3 4 5 6 7 8 9 PD(1) PD(PD_Qty) 10 11 MFB(x) 1 2 the two-byte CHECKSUM values as these are calculated automatically by EF 01 FF FF FF FF 01 Command the program. All you need to do is set (Fixed) (Default) 02 Data the value for PD_Qty to the number 07 Acknowledge of bytes being sent in the PACKAGE 08 End of data DATA, and then set these values in the TxPD() array, starting with the Sum of byte values = Checksum value first byte in TxPD(1). The two-byte LENGTH values are also calculated Fig.3. The structure of the message contains six elements as shown here. See text for full for you, making this program very details of how the contents are calculated and interpreted. Note that all byte values are easy to use. shown as a hexadecimal number. Once you have mastered controlling the LED, have a look at some other commands from the datasheet. There is even a random HEADER = EF 01 (fixed value) number generator (GetRandomCode which is instruction ADDRESS = FF FF FF FF (default value) code 14 (hex)) IDENTIFIER = 01 (a Command message) LENGTH = 07 (5-bytes in Package-Data plus 2-bytes in Checksum) Next time PACKAGE DATA = 35 03 00 02 00 (from the above Now that we have a working fingerprint module that we  e xplanation where values are know how to control, in Part 2 we will look at the commands highlighted in bold) that are used to perform a fingerprint enrolment, and also CHECKSUM = 00 42 (sum of byte values 01 + 07 + 35 the commands to perform a search of stored fingerprint + 03 + 00 + 02 + 00 (in hex)) templates. We will conclude with software for a standalone PicoMite fingerprint reader that brings everything together. Until then, stay safe, and have FUN! Interpreting the Acknowledge response Referring to the datasheet, you will see that the PACKAGE DATA in the Acknowledge response simply contains a single Questions? Please email Phil at: byte which is the confirmation-code. The value of this is contactus<at>micromite.org either 00 (for success), or 01 (for failure). So, the response message we expect to see back is as follows: Length = Quantity of bytes in PACKAGE DATA and CHECKSUM HEADER = EF 01 (fixed value) ADDRESS = FF FF FF FF (default value) IDENTIFIER = 07 (an Acknowledge message) LENGTH = 03 (1 byte in Package Data plus 2 bytes in Checksum) PACKAGE DATA = 00 (if successful) CHECKSUM = 00 0A (sum of byte values 07 + 03 + 00 (in hex)) Note that if an error occurred, the Package Data would contain the value 01, and the Checksum would contain 00 0B. Message demo Now that we have seen how to construct the bytes for a message that is sent to the fingerprint module, and also understood what the response should look like, let’s now send the actual Command message to see if it does indeed turn on the blue ring-LED as we expect. We will also check the values returned in the Acknowledge response message. Performing this simple test will also check that we have connected the fingerprint module correctly. Download the file FP_MessageDemo1.txt from the December 2022 page of the PE website and install the program into the PicoMite. When you RUN the program you should see the blue ring-LED turn on. If not, check the six connections. A common error with serial devices is getting the Tx and Rx connections reversed – remember, Tx from the fingerprint reader goes to Rx on the PicoMite, and Tx from the PicoMite goes to Rx on the fingerprint module. Challenge If you examine the program code, you will see that it is well commented, allowing you to try other parameter values to make the LED behave differently. Why not make it flash a Practical Electronics | December | 2022 JTAG Connector Plugs Directly into PCB!! No Header! No Brainer! Our patented range of Plug-of-Nails™ spring-pin cables plug directly into a tiny footprint of pads and locating holes in your PCB, eliminating the need for a mating header. Save Cost & Space on Every PCB!! Solutions for: PIC . dsPIC . ARM . MSP430 . Atmel . Generic JTAG . Altera Xilinx . BDM . C2000 . SPY-BI-WIRE . SPI / IIC . Altium Mini-HDMI . & More www.PlugOfNails.com Tag-Connector footprints as small as 0.02 sq. inch (0.13 sq cm) 61