Max30100 with MLX90614 not working pulse and oxygenlevel Arduino UNO

I am using two sensors max30100 and mlx90614 (also 16x2 i2c display) all are connected to the common SDA and SCL for communication. When i try max30100 it is working correctly but if i connect with other sensor it is showing as 0 value for both bpm and O2. (if i test max30100 separately then it is working fine) I have also attached the source code and libraries used.

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

#define REPORTING_PERIOD_MS 1000

LiquidCrystal_I2C lcd(0x27, 16, 2);
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
PulseOximeter pox;

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

float temperature;
uint8_t heart_rate;
uint8_t oxygen_level;
int i = 0;

#define T_R_LED 5
#define T_G_LED 4
#define T_B_LED 3

#define O_R_LED 10
#define O_G_LED 9
#define O_B_LED 8

#define BUZZER 13

void onBeatDetected()
{
  Serial.println("Beat!");
}

void setup() {
  Serial.begin(115200);
  pinMode(T_R_LED, OUTPUT);
  pinMode(T_G_LED, OUTPUT);
  pinMode(T_B_LED, OUTPUT);
  pinMode(O_R_LED, OUTPUT);
  pinMode(O_G_LED, OUTPUT);
  pinMode(O_B_LED, OUTPUT);
  pinMode(BUZZER, OUTPUT);

  Serial.println("Initalize Contactless - Temperature Sensor");
  if (!mlx.begin()) {
    Serial.println("Failed");
  }
  else {
    Serial.println("Success");
  }
  Serial.println("Initalize Oximeter Sensor");
  if (!pox.begin()) {
    Serial.println("Failed");
  }
  else {
    Serial.println("Success");
  }
  pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);
  pox.setOnBeatDetectedCallback(onBeatDetected);
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("System is Ready");
  Serial.println("System is ready to read values");
  digitalWrite(T_G_LED, HIGH);
  digitalWrite(O_R_LED, HIGH);
}

void loop() {
  delay(2000);
  temperature = mlx.readObjectTempC();
  if (temperature >= 31.0) {
    Serial.print(temperature);
    Serial.println(" C");
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print(temperature);
    lcd.setCursor(0, 1);
    lcd.print("Not Normal");
    digitalWrite(BUZZER, HIGH);
    delay(5000);
    digitalWrite(BUZZER, LOW);
    readOxiValues();
  }
  else
  {
    Serial.print(temperature);
    Serial.print(" C");
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print(temperature);
    lcd.setCursor(0, 1);
    lcd.print("Normal");
  }
}

void readOxiValues()
{
  delay(5000);
  Serial.println("Reading Oximeter Values");
  digitalWrite(T_G_LED, LOW);
  digitalWrite(T_R_LED, HIGH);
  digitalWrite(O_R_LED, LOW);
  digitalWrite(O_G_LED, HIGH);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Keep Hand");
  lcd.setCursor(0, 1);
  lcd.print("for 15 Seconds");
  digitalWrite(BUZZER, LOW);
  while (i < 1500)
  {
    pox.update();
    heart_rate = pox.getHeartRate();
    oxygen_level = pox.getSpO2();
    Serial.print("Heart Rate ");
    Serial.print(pox.getHeartRate());
    Serial.print(" bpm / SPO2 ");
    Serial.print(pox.getSpO2());
    Serial.print(" %");
    i = i + 1;
  }
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print(String("Heart Beat: ") + String(heart_rate));
  lcd.setCursor(0, 1);
  lcd.print(String("SPo2: ") + String(oxygen_level));
  if (heart_rate > 60 and oxygen_level >= 95)
  {
    Serial.println("Person Allowed");
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Allowed");
  }
  else
  {
    Serial.println("Person Not Allowed");
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Not Allowed");
    digitalWrite(BUZZER, HIGH);
    delay(4000);
    digitalWrite(BUZZER, LOW);
  }
  digitalWrite(T_G_LED, HIGH);
  digitalWrite(T_R_LED, LOW);
  digitalWrite(O_R_LED, HIGH);
  digitalWrite(O_G_LED, LOW);
}

I also followed the steps given in the url but that also not working.

Kindly help me.

When you ran the I2C scanner were the 2 devices at the same address?

1 Like

@Idahowalker

This is the output of I2C scanner

16:28:45.324 -> I2C device found at address 0x27 !
16:28:45.371 -> I2C device found at address 0x57 !
16:28:45.424 -> I2C device found at address 0x5A !

Cool 3 devices 3 address.

Have you tried pullup resistors?

Post a few images of you wiring. Which MCU are you using?

@Idahowalker yes bro i have used pullup resistors 4.7 resistor

UNO

SDA - 5
SCL - 4
VIN - 5v
GND - gnd

Did you try without the pull ups? Does 2 sensors work or only one at a time? Can you get 2 at a time working?

1 Like

Oh, you have 4 I2C devices and only 3 show up. Might have an address conflict.

@Idahowalker sir that bm i don’t what device it is. I have mlx and max30100 and lcd i2c kindly help me

@Idahowalker #Reply3 we have 3 devices and it shows all connected based on the address given.

Then why does your code you wrote setup to use a BM280?

Have you tried without the pullups? Can you get 2 devices working at the same time?

@Idahowalker i tried checking sensors individually by that time I used pull up resistors. Ok I will try without pull resistors.

Sir I have mentioned one url in that post whether it has any link with resistors.

Did you try to get 2 devices working at the same time?

@Idahowalker no it is not working that’s the problem temperature value I able to get but max30100 not working

Why is 5 seconds of delay needed?

Did you confirm a temp of >=31 is reached by doing a serial print of the temp?

Why is 2 seconds of delay needed?

Delay added just to show information in the lcd screen

In your readOxiValues() function
you have
Serial.println("Reading Oximeter Values");

Do you get that confirmation in SerialMonitor ?

@runaway_pancake yes I get only print function values not sensor values

What if you change your while() to a do while()

  do
  {
    pox.update();
    heart_rate = pox.getHeartRate();
    oxygen_level = pox.getSpO2();
    Serial.print("Heart Rate ");
    Serial.print(pox.getHeartRate());
    Serial.print(" bpm / SPO2 ");
    Serial.print(pox.getSpO2());
    Serial.print(" %");
    i++;
  }while (i < 1500);

[You can call the readOxiValues() function whenever you like.]

@runaway_pancake whatever I use I am not getting values. Usually when we keep hand on beat function will be called that also it is not calling I don’t know why

I'm reading that the MAX30100 is a 3.3V device.
Introduction to MAX30100 - The Engineering Projects