How to use MAX30100 with MLX90614 sensor

I am trying to use the Max30100 heart rate and oxygenation sensor with the MLX90614 sensor.
They are connected to I2C mode on esp32.
The sensors work perfectly in separate projects, but when I mix them the MLX90614 stops working after the Begin of the Max30100.

This is the code I am using:

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

#define I2C_SDA 21
#define I2C_SCL 22
#define REPORTING_PERIOD_MS 1000

uint8_t bm280_address = 0x76;
uint8_t max30100_address = 0x57;
uint8_t irmlx90614_address = 0x5A;
uint32_t tsLastReport = 0;

Adafruit_MLX90614 mlx = Adafruit_MLX90614();
PulseOximeter pox;

void setup() {
Serial.begin(9600);
Wire.begin();
mlx.begin();
pox.begin();
//delay(2000);
Serial.println();
}

void loop() {
//printTemp();
printFreq();
//delay(1000);
}

void printTemp(){
Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempC());
Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C");
}

void printFreq(){
pox.update();

if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
    Serial.print("Heart rate:");
    Serial.print(pox.getHeartRate());
    Serial.print("bpm / SpO2:");
    Serial.print(pox.getSpO2());
    Serial.println("%");
    printTemp();
    tsLastReport = millis();
}

}

Please, does anyone have any idea how to use the two sensors together?

The MAX30100 library sets the I2C bus speed to 400kHz (I2C_BUS_SPEED in MAX30100.h). Try to change that to 100kHz and report results.

4 Likes

Thank you for your comment.

I'm really not finding where to change from 400khz to 100khz in the library's source code.

Should I change the esp32 source code itself?

Great!
Thank you very much, that was it!
You just saved my work!
I changed the I2C_BUS_SPEED from 400000UL to 100000UL in the document MAX30100.h and it worked!

can you tell me how you changed this speed from 400khz to 100khz

Look for the Wire.setclock() line in the code and change the value in the parens.

Or, read reply #2 above.

Hi i am doing a project on these two sensors too but i did it in esp8266 please teach me how to add code to change speed of Max30100 0from 400Khz to 100Khz Thank you

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