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?