-1

我正在为我的项目使用 ESP32 30 针板、MAX30100 脉冲传感器。我可以将此传感器连接到 ESP32 的不同 i2c 引脚,即不是默认引脚(21,22)。

但我不知道如何从 MAX30100 读取数据,如果它连接到不同的引脚 - (比如说 32、33)

这是我用于默认 i2c 引脚从 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();
    }
}

如何将 MAX30100 连接到其他引脚?指令应该是什么?

PulseOximeter pox;

这个指令是什么意思?

4

1 回答 1

0

你应该改变图书馆的方向:

链接到 github 中的库文件

第 29 行:将其更改为

Wire.begin(SDA_PIN, SCL_PIN);

其中 SDA_PIN 和 SCL_PIN 是您自己的路由定义。

注意:如果您更改库,您将需要始终使用该引脚进行所有开发,因此如果您在本地导入该库可能会更好,或者如果您更改库甚至更好,因此如果您在参数中不传递任何引脚,则默认通常是 I2C 引脚,但如果已定义,则使用已定义的引脚。

于 2021-12-02T11:51:46.800 回答