Introduction

In this blog, I'll demonstrate how I connected a Heart Rate Sensor to the Avnet MT3620 kit. The Beats Per Minute are calculated and displayed on an attached OLED Display. The RED LED will indicate the users heart beat..

 

 

 

Beats Per Minutes

 

 

 

Required Hardware (Bill of Materials)

 

• Avnet Azure Sphere MT3620 Starter Kit

Product Link:  https://www.element14.com/community/view-product.jspa?fsku=&nsku=02AH9206&COM=noscript

• Heart Sensor

Product Link: https://pulsesensor.com/products/pulse-sensor-amped

• 128x64 Yellow Blue SSD1306 I2C OLED Display

    eg. this one for $6.99 from Amazon...

Product Link: https://www.amazon.com/gp/product/B072Q2X2LL/

 

Table Of Contents

 

Hardware Configuration

 

Connecting the Pulse Sensor

 

Since we're using the Avnet Azure Sphere Starter Kit, We will be putting the 3 leads from the Heart Sensor into boards headers on the Click Socket #1.

The  sensor is very simple with three legs:

 

 

Heart Rate Sensor

• BLACK: Ground

• RED: Input: +3V or +5V

• PURPLE: Signal

 

The  Click Socket #1 and the color of the Sensor lead connected to it

• PIN AN - PURPLE lead

• PIN +5V - RED  lead

• PIN GND - BLACK lead

 

.

See the pinout table below.  For Pin AN the Name used in code is GPIO42_ADC1

 

 

Connecting the OLED Display

 

You will need to solder a header to the board. This is how I did mine using a 4 pin header I had lying around.

 

Solder a 4 pin header to the  OLED Display  interface on the board

 

 

Code

 

The code for this project s located  on a GitHub repository located here:

     https://github.com/skruglewicz/MyBPM)

This is built on the 20.04 Sphere SDK and is running Azure Sphere OS version 20.04 Update 2.

 

Some of the Heart sensor code was ported from a Raspberry PI project that I used to learn about the sensor.

I describe some details along with project links in the following document:

https://www.element14.com/community/docs/DOC-94898/l/sphere-adc-document#jive_content_id_RasPI_Project

The Github repo is here:

https://github.com/WorldFamousElectronics/Raspberry_Pi/tree/master/PulseSensor_C_Pi

This  project is working great for me on a Raspberry PI . Here  is the link to the project from the vendor of the Heart Pulse sensor.

https://github.com/WorldFamousElectronics/Raspberry_Pi/blob/master/PulseSensor_C_Pi/PulseSensor_C_Pi.md

 

For the ADC coding I used the

Microsoft High Level ADC Example

https://www.element14.com/community/external-link.jspa?url=https%3A%2F%2Fgithub.com%2FAzure%2Fazure-sphere-samples%2Ftree%2Fmaster%2FSamples%2FADC%2FADC_HighLevelApp

 

 

For OLED Code I used the codebase from the blog post

Avnet Azure Sphere Starter-Kit: Advanced Tutorial

https://www.element14.com/community/groups/azuresphere/blog/2019/08/01/azure-sphere-starter-kit-advanced-tutorial

 

 

Build and Run the project

See the following Azure Sphere Quickstarts to learn how to build and deploy this sample:

 

   -  with Visual Studio     https://docs.microsoft.com/azure-sphere/install/qs-blink-application

   -  with VS Code          https://docs.microsoft.com/azure-sphere/install/qs-blink-vscode

   -  on the Windows command line      https://docs.microsoft.com/azure-sphere/install/qs-blink-cli

   -  on the Linux command line     https://docs.microsoft.com/azure-sphere/install/qs-blink-linux-cli

 

List of Potential Improvements

There is certainly many improvements to be made to this project. Heare are a few of my intentions of features I will be adding.

 

  • Adding a Relay click that will use a buzzer to indicate when a BPM goes over a given BPM's . I was planning on getting this in but ran out of time.
  • Add a Mikroe Heart Rate 4 click https://www.mikroe.com/uv-4-click
  • Add MongoDB Atlas Dstbase support
      • Use the MongoDB C driver
      • connect to  an Atlas  server
      • Write the DATA to a cluster .
  • Add support for Azure IoT Hub, the Device Twin and Azure Time Series Insights
    (Hands-on exercise creating an IoT Hub, manipulating the Device Twin and viewing sensor data using Azure Time Series Insights) using the following project by Posted by Brian Willesselement14 Team in Azure Sphere

          http://avnet.me/mt3620-kit-OOB-ref-design-blog-p2

 

 

Conclusion

This was an interesting journey to learn more about the Azure Sphere mt3620.

  • It was a challenge, porting the C code from the Raspberry PI Project.
    • I needed to understand and lean about The ADC on the mt3620. The RasPi project had a ADC that was part of the Project Circuit..
    • I still need to tune up the signal and compare it to the data transmitted by the Raspberry pi project.
      • I'm not getting the same numbers for BPM on the MT3620 as on the RasPi project?
        • I believe it might be a signal or timing issue.
          • The RasPI output is closer to my average BPM of 83 bpm's then the MT3620

 

            •  

              As you can see the BPM is Lower on the MT3260?

              the Jitter is way higher?

               

            • I have included the RasPI source code and the Data from the RasPI and the MT3260
  • One of the sticking points was, How to connect the Heart sensor leads to the board.
    • It tuned out to be pretty straight forward. But wasn't easy for me to figure out how to map the GPIO on the Rasberry Pi to the GPIO mapping of the MT3620
  • Another Hurdle was getting a the OLED display to work.
    • I used the 3 objects olded.c, ,i2c.c,  and sd1306.c
    • Thanks to Peter Fenn and Brian Willess at Avnet, This is very feature rich example that helped me to figure out how to do most of my code.