• Medium One

Biometric Face Detection with Feather Huzzah ESP8266 + Omron B5T-007001-010

Updated: May 15, 2020

This tutorial demonstrates how Medium One cloud connects and communicates with the Omron B5T-007001-010 device through the Feather Huzzah ESP8266 WiFi device in order to detect faces.

Communication between the Omron B5T-007001-010 and the Medium One cloud is established via MQTT. Medium One has a comprehensive MQTT library.

In this tutorial, we’ll demonstrate simple workflows to request data from the device. 

In this tutorial, you will:

  1. Set up an Arduino environment.

  2. Program the Feather HUZZAH ESP8266 WiFi board as an MQTT client.

  3. Create workflow to interpret Omron facial data.

Here's what you need to get started:

  1. OmronB5T-007001-010 + Feather Huzzah ESP8266 + Medium One Sandbox Prototyping Account [Buy]

  2. 4 Multicolored Pins to connect Omron Kit to Feather HUZZAH ESP8266 WiFi board.

  3. 1 Micro USB cable.

  4. MacOS or Windows OS (Note: This tutorial is tested on MacOS). 

  5. Arduino IDE [Download]

  6. PuTTY (if using Windows) [Download]

  7. 2.4GHz Wifi Internet access.

  8. CP2104 USB driver. [Download]

Step 1. Set up your Arduino Environment

Open Arduino. A new sketch will open.

Open Preferences to make some changes to the settings.

For mac: On the taskbar, go to Arduino -> Preferences.

For windows: On the taskbar, go to File -> Preferences.

Paste in the Additional Board Manager URLs section (under Settings).

Press OK.

On the taskbar, select Tools -> Board -> Boards Manager.

Search for esp8266 and install the board.

Go to Tools -> Board -> select Adafruit Feather Huzzah ESP8266.

Go to Sketch -> Include Library -> Manage Libraries.

Install PubSubClient, ArduinoJson, SoftwareSerial, and ESP8266WiFi libraries.

Step 2. Configure the Firmware Code with MQTT and WiFi credentials

  1. Download or clone the firmware code from

  2. Save the project inside Arduino.

For mac: Go to Documents -> Arduino, and paste the firmware code’s folder inside that.

For windows: Go to drive C -> Documents -> Arduino, and paste the firmware code’s folder inside that.

  1. Open the downloaded firmware code.

  2. Select File -> Open -> Arduino -> omron_esp8266_m1_cloud ->

  3. Update the credential values of wifi_ssid, wifi_password, project_mqtt, api_key, username, password with your WiFi SSID, WiFi password, Project MQTT ID, API Key, User MQTT ID, and User password respectively.

  4. Save the code.

Your MQTT Connection info can be found in the following places in your Medium One account:

  • Project MQTT: Setup > MQTT

  • API Key: Setup > Manage API Keys > Add New API Key (if there are none listed)

  • User MQTT ID and Password: Setup > Manage Users > Add New User

Step 3. Program Feather HUZZAH ESP8266 WiFi Board as an MQTT Client

Connect Feather HUZZAH ESP8266 WiFi device to your computer via micro USB cable.

On Arduino’s taskbar, go to Tools -> Port.

For mac: Select dev/cu.SLAB_USBtoUART port

For windows:

1. Open Device Manager -> Ports. Remember the COM# port number.

2. Open PuTTY. Select Connection Type as Serial. Enter the COM# port under Serial line and speed as 9600 (baud rate).

3. Select COM# port.

Compile the code by clicking the checkmark in the top left corner.

Your screen should look similar to the following after successful compilation.

After successful compilation, click on the upload arrow (next to the compilation checkmark) to upload the code.

You will see a blinking blue LED and solid red LED while uploading the firmware onto the device.

Your screen should look similar to the following after a successful upload.

Step 4. Set up the Kit

Connect Omron B5T-007001-010 to Feather Huzzah ESP8266 through 4 multicolored pins:

Connect your kit to some power. You can connect the micro USB cable to Feather HUZZAH ESP8266 board to supply power to the Omron board.

Observe the green light on the back of the Omron board.

In Arduino, go to Tools -> Serial Monitor.

First you may see some garbage data, then you will see output similar to the following:

The board will try to connect to Medium One cloud through MQTT.

Note: If the board failed to connect to Medium One cloud, you will observe the message MQTT connect failed.

Wait to get Connected to MQTT broker. If you get the failed message for a long time, then go back to the firmware code, check your credentials, and then follow the uploading process again.

On successful connection with the MQTT broker, the Omron device sends some values every 30 seconds.

On your Medium One dashboard, you can add a Real Time Events Stream widget, select the username of the device, and watch the data coming from the Omron board.

Click the Floppy Disk "Save" icon in the top right to save this Dashboard for later use.

Place the Omron lens in front of your face to detect its features.

Note: Make sure there must be enough light around you.

Next time the Omron board sends data, it will detect your face and send back the data to the ESP8266 device. You can observe that data on serial monitor as well as on the Medium One dashboard.

Step 5. Create Workflow to Process Omron data

On the left of your Medium One account, select Config → Data Streams, click Edit for the raw Data Stream.

Activate ‘raw:omron_response’ tag by selecting Active checkbox for it.

Click Save Data Stream.

On the left, select Workflow Studio and click Create to create a new workflow.

Give your workflow a name like “Process_face”.

Click the Tags & Triggers pane in the right toolbar.

Under the raw drop-down, drag and drop the omron_response tag onto the main canvas.

This is a trigger that defines the workflow execution.

Next, from the Modules pane, click on the Foundation dropdown and drag and drop the Base Python module onto the canvas.

Base Python allows you to write Python in order to process your data.

Connect the omron_response module to the input of Base Python.

Double click on the Base Python module box, and replace the default script.

Enter the following in the script text area:

import Store

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

last_command = Store.get("last_command")
age = 0;
happy = 0;
surprise = 0;
anger = 0;
sadness = 0;
degree = 0;
gender = "";

if omron_response[0] != 0xFE:  # check sync code
    message = "error, expecting 0xFE sync";
elif omron_response[1] != 0x00: # check response code
    message = "error, expecting normal response 0x00"
    if (last_command == "1"):
        message = "[Get Model] "
        for x in range(6, 18):
            message += chr(omron_response[x])
        message += " Major: "+str(omron_response[19])
        message += " Minor: "+str(omron_response[20])
        message += " Release Version: "+str(omron_response[21])
    elif (last_command == "2"):
        message = "[Face Detection A] "
        num_faces = omron_response[8];
        message += " Faces: "+str(omron_response[8])+";"
        # process 1 face
        message += " X-Coord: "+str(omron_response[10]+omron_response[11]*256)+";"
        message += " Y-Coord: "+str(omron_response[12]+omron_response[13]*256)+";"
        message += " Size: "+str(omron_response[14]+omron_response[15]*256)+";"
        message += " Co: "+str(omron_response[16]+omron_response[17]*256)+";"
        age = omron_response[18];
        message += " Age: "+str(omron_response[18])+";"
        message += " Age Co: "+str(omron_response[19]+omron_response[20]*256)+";"
        if (omron_response[21] == 1):
            gender = "male";
            message += " Gender: Male;"
            gender = "female";
            message += " Gender: Female;"
        message += " Gender Co: "+str(omron_response[22]+omron_response[23]*256)+";"
        message += " Neutral: "+str(omron_response[24])+";"
        happy = omron_response[25]
        message += " Happiness: "+str(omron_response[25])+";"
        surprise = omron_response[26]
        message += " Surprise: "+str(omron_response[26])+";"
        anger = omron_response[27]
        message += " Anger: "+str(omron_response[27])+";"
        sadness = omron_response[28]
        message += " Sadness: "+str(omron_response[28])+";"
        degree = omron_response[29]
        message += " Degree: "+str(omron_response[29])+";"
IONode.set_output('out1', {"message": message, "age":age, "happy":happy, 
                           "surprise":surprise, "anger":anger, "sadness":sadness,
                           "degree":degree, "gender":gender})

Click Save and Activate.

Click the Outputs pane on the right toolbar.

Under the Output drop-down, drag and drop the Processed Stream - Single output onto the main canvas.

Connect the Base Python module to the input of Processed Stream - Single.

Double click Processed Stream - Single and click Save and Activate.

Click on the Workflow menu, you will observe a new activated workflow.

Now press the reset button on the ESP8266 WiFi board and repeat the face recognition process.

This time you will observe some data from Omron board as same as earlier on serial monitor.

Switch to the dashboard to observe the processed data of your face.

The event generated will contain various measures of your face including age, anger, degree, gender, happy, sadness, surprise, and co-ordinates.

Congratulations! You have successfully completed the 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        


  • YouTube - White Circle