element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Design For A Cause 2021
  • Challenges & Projects
  • Design Challenges
  • Design For A Cause 2021
  • More
  • Cancel
Design For A Cause 2021
Blog Vital Care - 03 Temperature
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: sunnyiut
  • Date Created: 27 May 2021 9:49 PM Date Created
  • Views 953 views
  • Likes 3 likes
  • Comments 0 comments
  • design for a cause 2021
  • temperature sensor
  • nano 33 iot
  • max30102
Related
Recommended

Vital Care - 03 Temperature

sunnyiut
sunnyiut
27 May 2021

Title: Vital Care

By: Md. Kamrul Hussain

Project Category: Design Challenge

Project Name: Design For A Cause 2021

Blog post: 04

 

Previous Blogs:

image

Blog No.

Title

01

Introduction

02.a

SpO2 basics [PPG]

02.bSpO2 [MAX30102]

 

The MAX30102 has an on-chip temperature sensor for

calibrating the temperature dependence of the SpO2 subsystem.

The temperature sensor has an inherent resolution

of 0.0625°C.

I would like to use it for body temperature detection. But it seemed to be slow. Temperature rises up to around 34'C but it does not rise up or get down rapidly. However, that will be fine as the body temperature does not change too fast.

 

Temperature Data (0x1F–0x21)

image

Temperature Integer

The on-board temperature ADC output is split into two registers, one to store the integer temperature and one to store the fraction. Both should be read when reading the temperature data, and the equation below shows how to add the two registers together:

 

TMEASURED = TINTEGER + TFRACTION

This register stores the integer temperature data in 2’s complement format, where each bit corresponds to 1°C.

 

image

Temperature Fraction

This register stores the fractional temperature data in increments of 0.0625°C.

 

Output:

 

{gallery} Max30102 Temperature

image

Serial Terminal: MAX30102 gives RED and IR PPG and temperature value. NANO 33 IOT calculates the Heart Rate and SpO2. serial terminal shows these output along with Temperature.

image

Plotting output: Heart Rate, SpO2 and Temperature are plotted together for the time being.

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


MAX30105 particleSensor;


#define MAX_BRIGHTNESS 255


#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__)
//Arduino Uno doesn't have enough SRAM to store 100 samples of IR led data and red led data in 32-bit format
//To solve this problem, 16-bit MSB of the sampled data will be truncated. Samples become 16-bit data.
uint16_t irBuffer[50]; //infrared LED sensor data
uint16_t redBuffer[50];  //red LED sensor data
#else
uint32_t irBuffer[50]; //infrared LED sensor data
uint32_t redBuffer[50];  //red LED sensor data
#endif


int32_t bufferLength; //data length
int32_t spo2; //SPO2 value
int8_t validSPO2; //indicator to show if the SPO2 calculation is valid
int32_t heartRate; //heart rate value
int8_t validHeartRate; //indicator to show if the heart rate calculation is valid


byte pulseLED = 9; //Must be on PWM pin
byte readLED = 13; //Blinks with each data read


void setup()
{
  Serial.begin(115200); // initialize serial communication at 115200 bits per second:
  while (!Serial);
  
  pinMode(pulseLED, OUTPUT);
  pinMode(readLED, OUTPUT);


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


  Serial.println(F("Attach sensor to finger with rubber band. Press any key to start conversion"));
  while (Serial.available() == 0) ; //wait until user presses a key
  Serial.read();


  float temperature;
  
  byte ledBrightness = 27; //Options: 0=Off to 255=50mA
  byte sampleAverage = 4; //Options: 1, 2, 4, 8, 16, 32
  byte ledMode = 2; //Options: 1 = Red only, 2 = Red + IR, 3 = Red + IR + Green
  byte 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
  
  particleSensor.enableDIETEMPRDY(); //Enable the temp ready interrupt. This is required.
}


void loop()
{
  bufferLength = 50; //buffer length of 50 stores 2 seconds of samples running at 25sps


  //read the first 100 samples, and determine the signal range
  for (byte i = 0 ; i < bufferLength ; i++)
  {
    while (particleSensor.available() == false) //do we have new data?
      particleSensor.check(); //Check the sensor for new data


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


    Serial.print(F("red="));
    Serial.print(redBuffer[i], DEC);
    Serial.print(F(", ir="));
    Serial.println(irBuffer[i], DEC);
  }


  //calculate heart rate and SpO2 after first 50 samples (first 2 seconds of samples)
  maxim_heart_rate_and_oxygen_saturation(irBuffer, bufferLength, redBuffer, &spo2, &validSPO2, &heartRate, &validHeartRate);


  //Continuously taking samples from MAX30102.  Heart rate and SpO2 are calculated every 1 second
  while (1)
  {
    //dumping the first 15 sets of samples in the memory and shift the last 15 sets of samples to the top
    for (byte i = 15; i < 50; i++)
    {
      redBuffer[i - 15] = redBuffer[i];
      irBuffer[i - 15] = irBuffer[i];
    }


    heartRate = heartRate * 0.5;
    //spo2 = spo2 * 1000;
    
    //take 15 sets of samples before calculating the heart rate.
    for (byte i = 35; i < 50; i++)
    {
      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('\t');
      
      Serial.print(F("IR= "));
      Serial.print(irBuffer[i], DEC);
      Serial.print('\t');


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


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


      Serial.print(F("SPO2= "));
      Serial.print(spo2, DEC);
      Serial.print('\t');
      
      //Serial.print(F(", SPO2Valid="));
      //Serial.print(validSPO2, DEC);
      
      float temperature = particleSensor.readTemperature();
      Serial.print(F("temperatureC= "));
      Serial.println(temperature, 4);
    }


    //After gathering 15 new samples recalculate HR and SP02
    maxim_heart_rate_and_oxygen_saturation(irBuffer, bufferLength, redBuffer, &spo2, &validSPO2, &heartRate, &validHeartRate);
  }
}

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube