Wiznet makers

Girish

Published August 08, 2022 © MIT license (MIT)

0 UCC

0 VAR

1 Contests

0 Followers

0 Following

WizFi360-EVB-Mini Pulse Oximeter Blynk BPM

I'll build a pulse oximeter using MAX30102 and WizFi360-EVB-Mini that will track the Blood Oxygen level and send the data via Wi-Fi.

COMPONENTS Hardware components

WIZnet - WizFi360-EVB-Mini

x 1


DFRobot - Maxim Integrated MAX30102 High-Sensitivity Pulse Oximeter and Heart-Rate Sensor for Wearable Health

x 1


seeed - Grove - Universal 4 Pin Buckled 5cm Cable (5 PCs Pack)

x 10

Software Apps and online services

Arduino - Arduino IDE

x 1


WIZnet - WIZnet WizFi Library

x 1


blynk - Blynk

x 1


PROJECT DESCRIPTION

WizFi360-EVB-Mini Pulse Oximeter Blynk BPM

I'll build a pulse oximeter using MAX30102 and WizFi360-EVB-Mini that will track the Blood Oxygen level and send the data via Wi-Fi.

Story 

WizFi360-EVB-Mini Hardware Overview

Thanks to WIZnet for supporting this project with WizFi360-EVB-Mini Hardware.

WizFi360-EVB-Mini

This document describes WizFi360-EVB-Mini. WizFi360-EVB-Mini is a compact development board for experimenting, testing, and verification of WizFi360. WizFi360-EVB-Mini is the same form factor as the NodeMCU V2. WizFi360 is a low-cost and low-power consumption industrial-grade WiFi module. It is compatible with IEEE802.11 b/g/n standard and supports SoftAP, Station, and SoftAP+Station modes. The serial port baud rate can be up to 2Mbps, which can meet the requirement of various applications.

https://docs.wiznet.io/Product/Wi-Fi-Module/WizFi360/wizfi360_evb_mini

MAX30102

The MAX30102 is an integrated pulse oximeter and heart rate monitor Sensor. It integrates a red LED and an infrared LED, photoelectric detectors, optical devices, and low-noise electronic circuits with ambient light suppression. Standard I2C compatible communication interface can transfer the collected values to the WizFi360-EVB-Mini for heart rate and blood oxygen calculation.

  • Photo-dissolution method
  • Light transmittance is converted into an electrical signal

Wiring up a MAX30102 Module & WizFi360-EVB-Mini to Raspberry Pi Pico

  • Connect the VCC pin to the power supply, GND to GND.
  • Connect the SCL pin to the I2C clock pin and the SDA pin to the I2C data pin on Raspberry Pi Pico.
  • Connect the Vin pin to the power supply, GND to GND.
  • Connect the TXD1 pin to the IO9 pin and the RXD1 pin to the IO8 pin on Raspberry Pi Pico.
Programming MAX30102 Module

It is best to attach the sensor to your finger using a rubber band or Velcro. When you press your finger against the sensor it varies enough to cause the blood in your finger to flow differently which makes the sensor readings unstable.

  • Install the MAX30102 library from Sparkfun
Finger Presence:

We continuously print the delta values to find the difference

void loop()
{
  samplesTaken++;

  Serial.print("IR[");
  Serial.print(particleSensor.getIR());
  Serial.print("] Hz[");
  Serial.print((float)samplesTaken / ((millis() - startTime) / 1000.0), 2);
  Serial.print("]");

  long currentDelta = particleSensor.getIR() - unblockedValue;

  Serial.print(" delta[");
  Serial.print(currentDelta);
  Serial.print("]");

  if (currentDelta > (long)100)
  {
    Serial.print(" Something is there!");
  }

  Serial.println();
}

The Serial output is printed as shown.

Display Heartbeat Waveform

Display heartbeat diagram on the Arduino serial plotter. Click tool->Serial Plotter.

#include <Wire.h>
#include "MAX30105.h"

MAX30105 particleSensor;

void setup()
{
  Serial.begin(115200);
  Serial.println("Initializing...");

  // Initialize sensor
  if (!particleSensor.begin(Wire, I2C_SPEED_FAST)) //Use default I2C port, 400kHz speed
  {
    Serial.println("MAX30105 was not found. Please check wiring/power. ");
    while (1);
  }

  //Setup to sense a nice looking saw tooth on the plotter
  byte ledBrightness = 0x1F; //Options: 0=Off to 255=50mA
  byte sampleAverage = 8; //Options: 1, 2, 4, 8, 16, 32
  byte ledMode = 3; //Options: 1 = Red only, 2 = Red + IR, 3 = Red + IR + Green
  int sampleRate = 100; //Options: 50, 100, 200, 400, 800, 1000, 1600, 3200
  int pulseWidth = 411; //Options: 69, 118, 215, 411
  int adcRange = 4096; //Options: 2048, 4096, 8192, 16384

  particleSensor.setup(ledBrightness, sampleAverage, ledMode, sampleRate, pulseWidth, adcRange); //Configure sensor with these settings

  //Take an average of IR readings at power up
  const byte avgAmount = 64;
  long baseValue = 0;
  for (byte x = 0 ; x < avgAmount ; x++)
  {
    baseValue += particleSensor.getIR(); //Read the IR value
  }
  baseValue /= avgAmount;

  //Pre-populate the plotter so that the Y scale is close to IR values
  for (int x = 0 ; x < 500 ; x++)
    Serial.println(baseValue);
}

void loop()
{
  Serial.println(particleSensor.getIR()); //Send raw data to plotter
}

The waveform is plotted using the Serial plotter.

Heart-rate and SPO2 Measurement

Display the heart rate and SPO2 on Arduino serial monitor. The ideal heart rate(adult): 60~100 beats per minute and the ideal SPO2: 95~100.

{
      while (particleSensor.available() == false) //do we have new data?
        particleSensor.check(); //Check the sensor for new data

      digitalWrite(readLED, !digitalRead(readLED)); //Blink onboard LED with every data read

      redBuffer[i] = particleSensor.getRed();
      irBuffer[i] = particleSensor.getIR();
      particleSensor.nextSample(); //We're finished with this sample so move to next sample

      //send samples and calculation result to terminal program through UART
      Serial.print(F("red="));
      Serial.print(redBuffer[i], DEC);
      Serial.print(F(", ir="));
      Serial.print(irBuffer[i], DEC);

      Serial.print(F(", HR="));
      Serial.print(heartRate, DEC);

      Serial.print(F(", HRvalid="));
      Serial.print(validHeartRate, DEC);

      Serial.print(F(", SPO2="));
      Serial.print(spo2, DEC);

      Serial.print(F(", SPO2Valid="));
      Serial.println(validSPO2, DEC);
    }
Complete codes are added on the code section at the end of the project blog. Do follow till the end to understand this project.

Programming WizFi360-EVB-Mini

We will programming the WizFi360-EVB-Mini using the AT commands. We will be using multiple serial ports to communicate with USB and with WizFi360-EVB-Mini.

Serial2.println("AT\r\n"); //Handshaking with WizFi360-EVB-Mini

The WizFi360-EVB-MIni responds to the AT commands as shown.

Now, we can send AT commands to the WizFi360-EVB-Mini as per the documentation. There are normal transmission mode and transparent mode in WizFi360. In case WizFi360 is Normal Command mode, WizFi360 executes AT command. Confirm Normal Command mode by inputting AT\r\n and returning \r\nOK\r\n. In case transparent mode, WizFi360 doesn't execute AT command. Only transmit and receive data with peer. If input is "+++", switch to normal command mode.

We had installed the WizFi360 and WiFiEsp library from Wiznet that connects the module to the WiFi and then to Blynk.

Setting up Blynk Application for IoT Pulse Oximeter

  • Download the Blynk app (App Store, Google Play)
  • Get the Auth Token from the app
  • Import this library to Arduino IDE

Set the DataStream as shown below

Update SSID, password, Device ID, Auth Token in the sketch and upload it to Arduino. The WizFi360 is now connected to my WiFi router.
Add the elements to the dashboard to make the UI. Now the device is ready to receive the data from Raspberry Pi using WizFi360. The Heart Rate, SpO2 and the finger presence data are sent to the Blynk Console and the devices connected to them.
Final Output
Resources
Documents
  • WizFi360-EVB-Mini_Pulse_Oximeter_Blynk BPM.ino

  • MAX30102.ino

  • Connections

  • Final output

  • Dashboard

Comments Write