HELP! MAX30100 sensor not working with other sensors (GSR)

Hello friends,
I'm currently working on my final project wherein I'm going to use MAX30100 sensor (pulse oximeter sensor), LCD 16x2 display, Arduino UNO, and Galvanic Skin Response sensor (sweating indicator) for patient monitoring.

I have purchased my components here:
MAX30100 sensor:
https://shopee.ph/Pulse-Oximeter-Heart-Rate-Sensor-Module-Max30100-i.20469516.2759028370?sp_atk=be392a23-cf2d-46a4-a0b2-a91974b3fb6e&xptdk=be392a23-cf2d-46a4-a0b2-a91974b3fb6e

GSR sensor:
https://shopee.ph/SeeedStudio-Grove-GSR-sensor-module-i.18252381.256911379?sp_atk=2d5ac527-bb5b-46e6-b437-4f4b599c6bb1&xptdk=2d5ac527-bb5b-46e6-b437-4f4b599c6bb1

LCD 16x2 display:
https://shopee.ph/16x2-LCD-Display-White-on-Blue-i.18252381.820003396?sp_atk=a3871c7c-62c3-434d-a894-442f84406480&xptdk=a3871c7c-62c3-434d-a894-442f84406480

with following Library:
Max30100:

LCD:

GSR has no library and can run with the simple code provided below:

const int GSR=A0;
int sensorValue=0;
int gsr_average=0;
 
void setup(){
  Serial.begin(9600);
}
 
void loop(){
  long sum=0;
  for(int i=0;i<10;i++)           //Average the 10 measurements to remove the glitch
      {
      sensorValue=analogRead(GSR);
      sum += sensorValue;
      delay(5);
      }
   gsr_average = sum/10;
   Serial.println(gsr_average);
}

Project Context:
I want to collect Heart rate (HR) and Oxygen Saturation (Sp02) and Resistance Values such provided by GSR sensor to monitor the end-user with an alarm system wherein when HR, Sp02 and resistance values such as (Threshold resistance and continuous resistance values) reaches certain condition it will light and LED and sound the buzzer.

Issue encountered:
Both sensors work smoothly when run separately however the moment I merge the codes and apply the conditions I set, MAX30100 sensor will not provide HR and Sp02 values. It will only give 0 for both. From that I don't know if my alarm system is working.

Merge Code provided below:

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

#define REPORTING_PERIOD_MS     1000
// Setup
PulseOximeter pox;
const int gsrPin = A0;
const int ledPin = 13;
const int buzzerPin = 12;

// Setup Values for GSR
int gsrValue;
int gsrSum = 0;
int gsrAverage = 0;
int gsrAverageSum = 0;
int gsrMean = 0;

LiquidCrystal_I2C lcd(0x27,16,2);

uint32_t tsLastReport = 0;
void onBeatDetected()
{

  Serial.println("Beat!!!");

}

void setup() {
  Serial.begin(115200);

  // Initialize the LCD
  lcd.init();
  lcd.backlight();

  // Set up the GSR sensor
  pinMode(gsrPin, INPUT);

  // Set up the LED and buzzer
  pinMode(ledPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);



  // Initialize the MAX30100 sensor
  if (!pox.begin()) {
    Serial.println("FAILED");
    for (;;);
  } else {
    Serial.println("SUCCESS");
  }
  pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);

  pox.setOnBeatDetectedCallback(onBeatDetected);

  // To prevent glitching
  for (int i = 0; i < 10; i++) {
    gsrValue = analogRead(gsrPin);
    gsrSum += gsrValue;
    delay(500);
  }
  // to collect the 10 skin resistance for thresholding 
  gsrAverage = gsrSum / 10.0;

// to obtain threshold resistance by collecting 10 samples of skin resistance
  for (int i = 0; i < 10; i++){
    gsrAverageSum += gsrAverage;
    delay (1000);
  }
  gsrMean = gsrAverageSum / 10.0;

  
}

void loop() {

  // Read data from the MAX30100 sensor
  pox.update();
  float heartRate = pox.getHeartRate();
  float oxygenSaturation = pox.getSpO2();

  // Read data from the GSR sensor
  gsrValue = analogRead(gsrPin);


  // Check if all the conditions are met
  if (heartRate == 110 && oxygenSaturation == 95 && gsrValue > gsrAverage) {
    digitalWrite(ledPin, HIGH);
    digitalWrite(buzzerPin, HIGH);
    delay(500);
    digitalWrite(ledPin, LOW);
    digitalWrite(buzzerPin, LOW);
    delay(500);
  }

  // Print the data to the LCD
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("HR:");
  lcd.print(heartRate);
  
  
  lcd.setCursor(0, 1);
  lcd.print("OS:");
  lcd.print(oxygenSaturation);
  

  lcd.setCursor(10, 0);
  lcd.print("TR:");
  lcd.print(gsrAverage);
  

  lcd.setCursor(10, 1);
  lcd.print("SR:");
  lcd.print(gsrValue);
  

  // Print the data to the serial port
  Serial.print("Heart rate: ");
  Serial.print(heartRate);
  Serial.println(" bpm");
  
  Serial.print("Oxygen saturation: ");
  Serial.print(oxygenSaturation);
  Serial.println("%");

  Serial.print("GSR Average: ");
  Serial.print(gsrAverage);
  Serial.println("ohms");

  Serial.print("GSR conductance: ");
  Serial.print(gsrValue);
  Serial.println("ohms");

  Serial.println();
  

  delay(500);
}

For the connection/ wiring diagram (Ill provide a pic below):
Ill add a picture below:

MAX30100:
Vin -> 3.3V pin
GND -> GND pin
SCL -> SCL pin
SDA -> SDA pin

GSR:
Vin -> 5V
GND -> GND
Signal -> AO

LCD:
Vin -> 5V
GND -> 5V
SCL -> A5
SDA -> A4

Can anyone help me? looking around the forum they have mentioned about the bus speed?
I really appreciate help for this one. Thank you in Advance! More power to you!


Wiring Diagram:
Im not using the battery yet since the implementation of hardware and code is still in the process!

Try putting lcd.init and lcd.backlight at the very end of setup

Greetings sir!
I followed what you said sir and still the same

void setup() {
  Serial.begin(115200);

  // Set up the GSR sensor
  pinMode(gsrPin, INPUT);

  // Set up the LED and buzzer
  pinMode(ledPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);



  // Initialize the MAX30100 sensor
  if (!pox.begin()) {
    Serial.println("FAILED");
    for (;;);
  } else {
    Serial.println("SUCCESS");
  }
  pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);

  pox.setOnBeatDetectedCallback(onBeatDetected);

  // To prevent glitching
  for (int i = 0; i < 10; i++) {
    gsrValue = analogRead(gsrPin);
    gsrSum += gsrValue;
    delay(500);
  }
  // to collect the 10 skin resistance for thresholding 
  gsrAverage = gsrSum / 10.0;

// to obtain threshold resistance by collecting 10 samples of skin resistance
  for (int i = 0; i < 10; i++){
    gsrAverageSum += gsrAverage;
    delay (1000);
  }
  gsrMean = gsrAverageSum / 10.0;

  // Initialize the LCD
  lcd.init();
  lcd.backlight();  
}

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