Working on SPO2, Bpm and temperature sensors for COVID response

Hello everyone,

First of all, thank you for taking your time helping me. I'm working on a project which gets a bunch of health data and sends it to a web server. I'm stuck trying to have 2 sensors work together.

I'm using MLX90614 for the temperature, and MAX30100 for the oxygen saturation and bpm, and the Arduino Mega 2560. Both sensors offer I2C communication, which I'm using in order to reduce pins (I think that it's compulsory to use I2C for both sensors), because I'll have to add more sensors in the future. I'm using the library for the MAX30100, I looked into it and I think it's way to difficult to use it without the library.

My problem is that I'm not being able to use them together. When I run the script with the Arduino, I get the correct data for the MLX90614, but the MAX30100 return 0.00 for both SPO2 and BPM. I know it has something to do with the begin() of both sensors, because both work fine separately with the same code, but when I begin both sensors I get this error.

I've tried to shutdown and begin the sensors within the loop() , but seems like the sensors will only begin if I use the functiosn begin() in the setup() function.

The code I will attach gives data for MLX90614, but 0.00 for MAX30100. As you will see, I've commented code lines that I thought that would work, but only makes the MLX90614 give 1034 as value, and 0.00 for MAX30100.

So, my cuestion is, ¿How can I make them work together?¿what is the problem with I2C and using 2 sensors with them libraries?¿Is it about the clock for I2C?

I feel like I'm missing something, because some things are not making sense (I have to begin the mlx, if I use delay() in any of the measurment functions, everything fails...etc)

Thank you so so much for you help, any recommendation will be welcomed.

#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_MLX90614.h>
#include "MAX30100_PulseOximeter.h"

Adafruit_MLX90614 mlx = Adafruit_MLX90614();   /Temperature

PulseOximeter pox;   // SPO2 and BPM

#define MLX90614_TOBJ1 0x07

void setup() {

//If Idon't begin mlx here, it won't work even tho I'm not using it in the rest of the code, and the function only does Wire.begin()

uint16_t measure_temperature(){
      float start = millis();
      uint16_t ret=0.0;
                Wire.beginTransmission(90); // start transmission to device
                Wire.write(MLX90614_TOBJ1);                 // sends register address to read from
                Wire.endTransmission(false);   // end transmission
                Wire.requestFrom(90, (size_t)3); // send data n-bytes read
                ret =;                  // receive DATA
                ret |= << 8;            // receive DATA
                uint8_t pec =;
                ret *= .02;
                ret -= 273.15;
        return ret;


float * measure_max30100(){
  float spo2 = .00;
  float bpm = .00;

  static float result[2];

  uint32_t tsLastReport = 0;
  float start = millis();
    spo2 = pox.getSpO2();
    bpm = pox.getHeartRate();
    tsLastReport = millis();
  result[0] = spo2;
  result[1] = bpm;

  return result;

void loop() {
  boolean ready = true;

  float temperature_measurment  = 0.00;
  temperature_measurment  = measure_temperature();    

    //SPO2 y BPM
  float* measurment_spo2_bpm = measure_max30100();
  float spo2 = measurment_spo2_bpm[0];
  float bpm = measurment_spo2_bpm[1;]

  //check errors
  if(temperature_measurment  >60 || temperature_measurment  <25){ Serial.println("¡ERROR TEMPERATURE! " );}
  if(spo2>100&&spo2<85){Serial.println("¡ERROR SPO2!  " );}
  if(bpm>200&&bpm<40){Serial.println("¡ERROR BPM! " );}

  //print Temperature
  Serial.print("Temperature: " );
  Serial.println(temperature_measurment  );

  //print SPO2 y BPM
  Serial.print("SPO2: " );
  Serial.print("BPM: " );





How did you solve this problem?

Hi!Can you tell me please how you solved the problem? I'm having the same problem with a ds18b20 temperature sensor and MAX30100. Thanks!

I try to pass value 0x5A as a argument of Adafruit_MLX90614 method when i initialize object of Modules Mlx90614. i get successful.
My code:
Adafruit_MLX90614 mlx = Adafruit_MLX90614(0x5A);
0x5A = address of i2c device

I tried it but it gave me this error:

error: no matching function for call to 'Adafruit_MLX90614::Adafruit_MLX90614(int)'
   14 | Adafruit_MLX90614 mlx = Adafruit_MLX90614(0x5A);

I'm using the same library as yours, the i2c address of mlx sensors same also

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.