Biometric face detection by connecting Feather Huzzah ESP8266 and Omron B5T-007001-010 to Medium One cloud

Level: Beginner

This tutorial is all about biometric face detection. This also demonstrates how Medium One cloud connects and communicates with OmronB5T-007001-010 device through Feather Huzzah ESP8266 WiFi device which will leads to facial detection.

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. 

Primary steps of this tutorial:

  1. Setup Arduino environment.
  2. Configure the firmware code with MQTT  and WiFi credentials.
  3. Program Feather HUZZAH ESP8266 WiFi board as a MQTT client.
  4. Set up the kit.
  5. Create Workflow to process Omron data.

What you need to get started?

  • Medium One Prototyping Sandbox Account [Buy Kit]
  • Omron B5T-007001-010 kit [Buy Kit]
  • Adafruit Feather HUZZAH ESP8266 WiFi device[Buy Kit]
  • 4 Multicolored Pin to connect Omron Kit to Feather HUZZAH ESP8266 WiFi board
  • 1 Micro USB cable
  • MacOS or Windows OS.

Note: This tutorial is tested on MacOS

For mac: Install from here.

Check point: Security settings of you mac may need to change

For windows: USB driver installed by default.

  • 2.4GHz Wifi Internet access

Prerequisites:

  • This tutorial assumes you have properly install Arduino on your system.
  • Medium One sandbox account and required credentials (Username, User Password, Api Key, Project MQTT  ID, User MQTT ID) in hand. If you are new to Medium One, you can refer Getting started with Medium One sandbox tutorial, to create and set up your Medium One sandbox account.

Step 1. Setup Arduino environment

  • Open Arduino. A new sketch will open.

 

  • Open Preferences, to make some changes in Arduino settings.

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

 

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

 

  • Paste http://arduino.esp8266.com/stable/package_esp8266com_index.json in the Additional Board Manager URLs section (under Settings).

 

  • Press OK.
  • On 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 library.

 

  • Install ArduinoJsonSoftwareSerial, and ESP8266WiFi library as same as above.

 

 

 

Step 2. Configure the firmware code with MQTT  and WiFi credentials

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.

  • Open the downloaded firmware code.

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

  • 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, User password respectively, in the code.

 

  • Save the code.

Step 3. Program Feather HUZZAH ESP8266 WiFi board as a 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. Make sure the port on which device is plugged in should be selected.

  • Compile the code by selecting the tick on top left corner.

 

 

  • You will observe the following after successful compilation.

 

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

 

 

  • You will see the blinking blue led and solid red led while uploading the firmware on the device. Solid red led represents the power status of the device.

 

  • After successful uploading, you will find the result at bottom same as below

 

  • After successful uploading. Go to tools -> Serial Monitor.

Step 4. Set up the kit

  • Connect Omron B5T-007001-010 to Feather Huzzah ESP8266 through 4 multicolored pin, same as below:

 

 

  • Connect your kit to some power.

Note: Connect the micro USB cable to Feather HUZZAH ESP8266 board, that will also supply power to Omron board.

 

  • You will observe the green light on back of the Omron board.

 

  • After successful uploading. Go to tools -> Serial Monitor.

 

 

  • First you may see some garbage data, then you can see a statement like….

 

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

 

 

  • Switch to your Medium One sandbox dashboard.
  • You will observe the connect message first.

 

Note: If the board fail 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 so long, then go back to the firmware code and check your sandbox credentials and then follow the uploading process again.

 

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

 

  • Observe the data on dashboard coming from Omron board.

 

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

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

  • You will observe that Omroan board detect your face on next 30th second and send back the data to ESP8266 device.
  • You can observe that data on serial monitor and as well as on Sandbox dashboard.

 

 

Step 5. Create Workflow to process Omron data

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

 

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

 

  • Click Save Data Stream.
  • On the left, select Workflow Studio → Click Create to create a new workflow.

 

 

  • Give your workflow, a name like “Process_face”.

 

  • Click the Tags & Triggers pane on the right toolbar.

Under the raw drop-down, drag and drop 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 then drag and drop the Base Python module onto the canvas.

Base Python is a programmatic module that you can code in Python 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:

 

  • Click Save and Activate.

 

  • Click the Outputs pane on the right toolbar.

Under the Output drop-down, drag and drop Processes Stream -Single tag onto the main canvas.

 

  • Connect theBase Python module to the input of Processes Stream -Single.

 

  • Click Processes Stream -Single.
  • Save and Activate Processes Stream -Single.

 

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

 

  • Now press reset button on 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 dashboard, you will now observe the processed data of your face.
  • The event generated will contain various measures your face like age, anger, degree, gender, happy, sadness, surprise, and co-ordinates of your face.

 

Congratulations! You have successfully completed the tutorial.

Feel free to experiment further with the workflows and envision new interesting IOT use cases with Feather Huzzah ESP8266 device. This tutorial is just a starting point for your custom cloud based application.

For more tutorials on other boards and devices, please visit: https://blog.mediumone.com/category/tutorials/.

somya.bansal@medium.one'

Author: Somya Bansal