Search
  • Medium One

Build a Fingerprint Reader with Adafruit Feather HUZZAH w/ESP8266

Updated: May 15

This tutorial uses the Medium One IoT Prototyping Sandbox to control a fingerprint reader.


Prerequisites:

  1. ESP8266 Quick Start Guide


In this tutorial, you will:

  1. Set up fingerprint reader and Adafruit ESP8266 Feather

  2. Set up the IoT Controller app.

  3. Set up and program the ESP8266 board.

  4. Write workflows to control the LEDs on the board, process fingerprints, and get the results of the fingerprint scan on the IoT Controller app

Here’s what you need to get started:

  1. Medium One IoT Prototyping Sandbox [Buy]

  2. Feather HUZZAH w/ESP8266 [Buy]

  3. CP2104 USB Driver [Download]

  4. Windows PC or Mac OS (Note, this tutorial is based on Window PC)

  5. 4 GHz WiFi Internet Access

  6. Medium One IoT Controller App

  7. Arduino IDE [Download]

  8. Parallax Optical Sensor Development Tools Fingerprint Reader [Buy]

Step 1. Set up Fingerprint Reader and Adafruit ESP8266 Feather (Schematic)

Note: The Parallax Fingerprint Reader Module is supplied by a +5V AC to DC adapter (the connector jack in the upper left corner. This device works best at VCC=5.0V. The placement of the finger on the scanner and the lighting of the surrounding can be critical factors in how well the scan works.

Step 2. Set up the IoT Controller App

Note: These instructions are for the Android app, but the IOS app is similar.

Open the IoT Controller app and click on the plus sign in the bottom right corner.

Now you can give your project a name and input your Username, Password, and API Key from the account setup. Select "Pro" and save.

If you entered everything correctly, you should see two blue circular icons on the bottom.  If you entered something incorrectly, the color of the plus circular icon will be red instead of blue.

Next, press “+Add New Widget”.

Select “Switch”.  Swipe the whole “switch” block to the right to access the settings. (iOS: press the switch icon to access the settings)

The stream field is represented by the two-arrow icon.  The tag field is represented by a price tag icon. The delete button is represented by a trash can icon.

Press each icon to enter the appropriate information.  Type “raw” for the stream, and “redledsw” for the tag.

Press “+ Add New Widget” again and create 3 more switches with the stream "raw" and the tags "greenledsw", "add_user_mode", and "del_user_mode".


Your screen should look like the following:

Next, press “+Add New Widget”.

Select “Notification”.  Open the settings.


Type “notifications” for the stream, and “message” for the tag.

There should be four “switch” blocks and one “notification” block.  The tag name will appear on each widget. (note: the tag will not appear on the notification widget for iOS)

Checkpoint

Go to your Medium One account and go to the “Dashboard” from the left-hand sidebar.  Click “Single User Real Time Events Stream”.

Select your user in the right hand corner of the widget.

Now, on the app, click on the “redledsw” switch to turn it on.

You should see an event show up on the widget.

Click the save icon (floppy disk) in the top right corner of the dashboard.

Step 3. Set up the ESP8266 Board

Go to Tools > Board > Boards Manager...

Search for “esp8266” and install the board.


Go to Tools -> Board:”Adafruit HUZZAH ESP8266”

Download the firmware by clicking this link. https://github.com/Medium-One/esp8266_labs/tree/master/Parallax_Fingerprint_Scanner/Huzzah_ESP8266_Feather_arduino_c_code


Fill in your Medium One and Wifi credentials where necessary near the top portion code.


For more information on MQTT credentials, view our documentation here.

For example, it will look something like this:

Step 4. Program the Board

Connect your board to your PC via USB.

Next, go to Tools -> Port.  Select the correct com port.

Then click on the upload arrow in the top left corner to compile and flash the board; this may take a few minutes.

Note the output log during this step to see when it’s completed.

Once complete, go back to your Medium One Dashboard, where the Real Time Events Stream should be open. You should eventually receive an event from your board within a minute.

Go to Tools -> Serial Monitor to see print statements from the board, so that you can see when the board connects to the WiFi.

Set the baud rate to 115200.

You will also receive a heartbeat event from the board every minute.

Unplug your board.

Step 5. Write Workflow 1: LED Control

Press these two switches to send event data to Medium One.

Events will appear on the dashboard.

Go to “Config” on the left-hand sidebar in your Medium One account and click “Data Streams”.

Click “raw” and then click the active checkbox next to “redledsw” and “greenledsw”. Then click “Save Data Stream”.

Now go to your Workflow Studio and click “Create”.

Give your workflow a name. We named ours “LED Control”.

Click the “Tags and Triggers” icon, which is the first icon on the right-hand sidebar.

Click “raw” and drag the “redledsw” and “greenledsw” tags into the main area of the workflow.

Now click on the “Modules” icon (the second icon in the sidebar), click on “Foundation” and drag a “Base Python” module into the workflow.

Double click on the base python block.  Click "Add Input" to add a 2nd input called in2.   Then press “Save”.

Connect the bottom end of the switch tags to the “in1” and “in2” circles on the Base Python module.

Double-click on the Base Python module and copy and paste the following code into the Script section, replacing any code that is originally there.


'''
This workflow will turn on or off the leds.
Last Updated: June 19, 2018
Author: Medium One
'''

import MQTT
if IONode.is_trigger('in1'):
    redledlevel = IONode.get_input('in1')['event_data']['value']
    if (redledlevel == "on"):
        MQTT.publish_event_to_client('esp32', 'G1:1')
    else:
        MQTT.publish_event_to_client('esp32', 'G1:0')
    log("red led level: " + str(redledlevel))

elif IONode.is_trigger('in2'):   
    greenledlevel = IONode.get_input('in2')['event_data']['value']
    if (greenledlevel == "on"):
        MQTT.publish_event_to_client('esp32', 'G2:1')
    else:
        MQTT.publish_event_to_client('esp32', 'G2:0')    
    log("green led level: " + str(greenledlevel)) 

Now click “Save and Activate”.

Checkpoint

Plug the board in and open the IoT Controller app.

The board will enter the initial setup (both green and yellow LEDs are turned on.)   Wait for all the LEDs to be turned off.

After the board is done setting up (within a minute), turn the app switch on and off. You should see the LEDs on the board turn on and off.

Note: Blue LED is enabled by the greenledsw switch.

The events are displayed on the dashboard.

Step 6. Write Workflow 2: Set Fingerprint Processing Mode (Add, Delete, Verify)

This workflow waits to get the user’s selection of the fingerprint operation mode from the Medium One Mobile IoT app. Upon receiving the user’s selected mode, the workflow sends a confirmation message back to the app that the mode is set. The message also includes an instruction about what the user needs to do such as placing your finger on the scanner for the add or verify mode.  

At the same time, the mode (add, delete, or verify) is sent to ESP8266.  ESP8266 will process the mode by sending the actual command to the fingerprint module.  The blue led is turned on to show that the operation is in progress and is turned off when the operation is done.

Below are the instructions to create this workflow.

Press these three switches to send event data to the sandbox.

The events will appear.

Go to “Config” from the left-hand sidebar on your Medium One account and click “Data Streams”.

Click “raw” and then click the active checkbox next to “add_user_mode” and “del_user_mode”, and “vfy_user_mode”. Then click “Save Data Stream”.

Create a new stream called notification.  Click on “Create New Stream”.

Enter “notifications” for the Name field.  Choose “Never Expire.” Click “Save Data Stream.”

The new data stream is created.

Create a new workflow, name it, and drag the raw “add_user_mode” and “del_user_mode”, and “vfy_user_mode” tags into the workflow.

Drag a Base Python module into the workflow.

Double click on the Base Python block.  Click "Add Input" add the 2nd input called in2 and the 3rd input called in3.  Then press “Save”.

Click the “Outputs” icon (third icon on sidebar) and drag one “Processed Stream – Single” output into the workflow.

Double click “Processed Stream – Single” output block.

Choose “notifications” for the Datastreams field. Click “Save.”

Connect the blocks as shown below.

Copy and paste the following code into the Script area of the Base Python module, replacing any code that was previously there. Then click “Save and Activate”.

'''
This workflow sets the operation mode: Add/Delete/Verify mode for the fingerprint reader
Last Updated: July 20, 2018
Author: Medium One
'''

import MQTT
import Store

adduser = IONode.get_input('in1')['event_data']['value']
deluser = IONode.get_input('in2')['event_data']['value']
vfyuser = IONode.get_input('in3')['event_data']['value']

mode = Store.get("fingerprint_mode")          # Get the stored fingerprint scan mode.
if mode is None:
    Store.set_data("fingerprint_mode", "idle", -1)    
    mode = "idle"

if (mode == "idle"):
    if (adduser == 'on'):  
        new_value = "add"
        msg = "Add mode: Please place your finger on reader."
        MQTT.publish_event_to_client('esp32', 'C1') 
    elif (deluser == 'on'):
        new_value = "delete"
        msg = "Delete mode: Delete now."
        MQTT.publish_event_to_client('esp32', 'C2') 
    elif (vfyuser == 'on'):                  
        new_value = "verify"  
        msg = "Verify mode: Please place your finger on reader."
        MQTT.publish_event_to_client('esp32', 'C3') 
elif (mode == "add"): 
    if (adduser == 'off'):  
        new_value = "idle"  
        msg = "Back to Idle Mode."
elif (mode == "delete"): 
    if (deluser == 'off'):  
        new_value = "idle"  
        msg = "Back to Idle Mode."
elif (mode == "verify"): 
    if (deluser == 'off'):  
        new_value = "idle"  
        msg = "Back to Idle Mode."

Store.set_data("fingerprint_mode", new_value, -1)

# push (bool) to send this notification to push (iOS or Android)
IONode.set_output('out1', {"message": msg, "sms":False,"email":False,"push":True})

# for debug purpose
log('new value =' )
log(new_value)
log('new message =' )
log(msg) 

Step 7. Write Workflow 3: Get the Operation Result Status on Your IoT app

This workflow displays a message on the Medium One Mobile IoT App to indicate whether the operation is successful or unsuccessful.


First, add a JSON widget on the app.

Open the settings.

Set the stream to "raw" and the tag to "operation_status". Save the settings.


Enter “Pass” and press the POST button.

The data will appear on the dashboard.

Go to “Config” from the left-hand sidebar on your Medium One account and click “Data Streams”.

Click “raw” and then click the active checkbox next to “operation_status.” Then click “Save Data Stream”.

Create a new workflow, name it, and drag the raw “operation_status” tags into the workflow.

Drag a Base Python module into the workflow.

Click the “Outputs” icon (third icon on sidebar) and drag one “Processed Stream – Single” output into the workflow.

Double click “Processed Stream – Single” output block. Choose “notifications” for Datastreams field. Click “Save.”

Connect the blocks as shown below.

Copy and paste the following code into the Script area, replacing any code that was previously there. Then click “Save and Activate”.

''
This workflow sends the status of the completed fingerprint operation to the mobile IoT app.
Last Updated: July 20, 2018
Author: Medium One
'''
import MQTT
import Store

status = IONode.get_input('in1')['event_data']['value']

if (status == "pass"):
    msg = "The operation is successful."
else:   
    msg = "The operation is not successful."

# push (bool) to send this notification to push (iOS or Android)
IONode.set_output('out1', {"message": msg, "sms":False,"email":False,"push":True}) 


Now this widget can be removed since creating the workflow is done.

Open the settings and delete the widget.


Checkpoint

Go to your Mobile App.


Add a new user’s fingerprint:

Click the “add_user_mode” switch to change the state from OFF to ON.  A message will appear to indicate that the scanner is ready to scan your fingerprint.  When the blue LED on ESP8266 board is turned on, place your fingerprint on the scanner.  Keep your fingerprint on the scanner until the blue LED is disabled.

Adding a new user’s fingerprint is a long process that may take a few minutes.

If the operation is successful, a message below will be displayed.

If the operation is unsuccessful, a different message will be displayed and the red LED will turn on.

Click the “add_user_mode” switch to change the state from ON to OFF.  A message will appear to indicate that it is back to idle mode.

If the serial monitor is open, it shows that the fingerprint is making three scans for adding a new user’s fingerprint.  If all three scans succeed, then the firmware will send “pass” to Medium One.  This is how the status is displayed on the mobile IoT app.

Verify a user’s fingerprint against the stored fingerprint:

Click the “vfy_user_mode” switch to change the state from OFF to ON.  A message will appear to indicate that the scanner is ready to scan your fingerprint. When the blue LED on ESP8266 board is turned on, place your fingerprint on the scanner.  Keep your fingerprint on the scanner until the blue LED is disabled.

If the operation is successful, a message below will be displayed.

If the operation is unsuccessful, a different message will be displayed and the red LED will turn on.

Click the “vfy_user_mode” switch to change the state from ON to OFF.  A message will appear to indicate that it is back to idle mode.

The serial monitor window displays information throughout the process.  The verification scan is usually a quicker scan than the new user scan.

Delete the existing user’s fingerprint:

Click the “del_user_mode” switch to change the state from OFF to ON.  A message will appear to indicate that the stored fingerprint data is being deleted. When the blue LED on ESP8266 board is turned on, wait until the blue LED is disabled.  In this mode, it is not required to place your finger on the scanner.

If the operation is successful, a message below will be displayed.  Deleting a stored fingerprint data is usually successful.

But, if there isn’t a stored fingerprint data in the scanner’s memory or you have already removed it, then the operation will be unsuccessful this time and the red LED will turn on.

The serial monitor window also displays information throughout this process.

Congratulations!  You have successfully completed the Fingerprint Reader tutorial! 


Want to learn more about what Medium One can do?

Check out our documentation and tutorials & get started on your next IoT project!

© 2018 Medium One   All Rights Reserved

4633 Old Ironsides Dr. #280, Santa Clara, CA  95054                

info@mediumone.com

|

  • YouTube - White Circle