-1

I'm using a ESP32 30 pin board, MAX30100 pulse sensor for my project. I can interface this sensor to ESP32's different i2c pins i.e. not default pins(21,22).

But I don't know how to read data from the MAX30100 if it connected to different pins - (Let's say 32, 33)

This is the program I used for default i2c pins to read data from MAX30100

#include <Wire.h>
#include "MAX30100_PulseOximeter.h"
#define BLYNK_PRINT Serial
#include <Blynk.h>
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>

#define REPORTING_PERIOD_MS 1000

char auth[] = "*******************";             // You should get Auth Token in the Blynk App.

// Connections : SCL PIN - D1 , SDA PIN - D2 , INT PIN - D0
PulseOximeter pox;

float BPM, SpO2;
uint32_t tsLastReport = 0;


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

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

    pinMode(19, OUTPUT);
    Blynk.begin(auth,"************", "**********");

    Serial.print("Initializing Pulse Oximeter..");

if (!pox.begin()) {
    Serial.println("FAILED");
    for(;;);
}     
else
{
    Serial.println("SUCCESS");
    pox.setOnBeatDetectedCallback(onBeatDetected);
}

    // The default current for the IR LED is 50mA and it could be changed by uncommenting the following line.
    pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);

}

void loop()
{
    pox.update();
    Blynk.run();

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

        Blynk.virtualWrite(V3, BPM);
        Blynk.virtualWrite(V4, SpO2);

        tsLastReport = millis();
    }
}

How do I interface MAX30100 to other pins? What should be the instructions?

PulseOximeter pox;

What does this instruction mean?

Sylvester Kruin
  • 3,294
  • 5
  • 16
  • 39
Ravi Kumar
  • 11
  • 1
  • 7
  • 1
    Why can't you use the default pins? I'm asking this because many people seem not to realize that you can connect multiple I2C devices to one pair of I2C pins. If this is your concern, it's probably not a real problem. – romkey Oct 19 '21 at 14:40

1 Answers1

0

You should change direction in library:

Link to library file in github

Line 29: change that for

Wire.begin(SDA_PIN, SCL_PIN);

Where SDA_PIN and SCL_PIN are defines of your own routing.

NOTE: if you change the library you will need always to use that pins for all of your developments so maybe is better if you import that library locally or even better if you change library so if you don't pass any pin at argument it default normally I2C pins but, if defined use the defined ones.

Luis Reyes
  • 11
  • 3