CLOSED

I am trying to read data from the MAX30102 V2 Dfrobot PPG sensor SEN0344 using an Arduino Mega, using I2C, however; I am having no success so far. I really appreciate any help you can give, and even your time just looking at this, thanks so much in advance.
I have wired it as shown below(left MAX30102, Right Arduino Mega)
3V3 → 3.3V
GND → GND
SCL → SCL
SDA → SDA
When I try to run the following code on the Arduino Mega(taken from the examples page on the DFRobot github) it simply outputs: MAX30102 was not found.
n.b. Question Continued after code
/*!
* @file basicRead.ino
* @brief Output readings of red light and IR
* @n This library supports mainboards: ESP8266, FireBeetle-M0, UNO, ESP32, Leonardo, Mega2560
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
* @licence The MIT License (MIT)
* @author [YeHangYu]([email protected])
* @version V0.1
* @date 2020-05-29
* @url https://github.com/DFRobot/DFRobot_MAX30102
*/
#include <DFRobot_MAX30102.h>
DFRobot_MAX30102 particleSensor;
/*
Macro definition opions in sensor configuration
sampleAverage: SAMPLEAVG_1 SAMPLEAVG_2 SAMPLEAVG_4
SAMPLEAVG_8 SAMPLEAVG_16 SAMPLEAVG_32
ledMode: MODE_REDONLY MODE_RED_IR MODE_MULTILED
sampleRate: PULSEWIDTH_69 PULSEWIDTH_118 PULSEWIDTH_215 PULSEWIDTH_411
pulseWidth: SAMPLERATE_50 SAMPLERATE_100 SAMPLERATE_200 SAMPLERATE_400
SAMPLERATE_800 SAMPLERATE_1000 SAMPLERATE_1600 SAMPLERATE_3200
adcRange: ADCRANGE_2048 ADCRANGE_4096 ADCRANGE_8192 ADCRANGE_16384
*/
void setup()
{
//Init serial
Serial.begin(115200);
/*!
*@brief Init sensor
*@param pWire IIC bus pointer object and construction device, can both pass or not pass parameters (Wire in default)
*@param i2cAddr Chip IIC address (0x57 in default)
*@return true or false
*/
while (!particleSensor.begin()) {
Serial.println("MAX30102 was not found");
delay(1000);
}
/*!
*@brief Use macro definition to configure sensor
*@param ledBrightness LED brightness, default value: 0x1F(6.4mA), Range: 0~255(0=Off, 255=50mA)
*@param sampleAverage Average multiple samples then draw once, reduce data throughput, default 4 samples average
*@param ledMode LED mode, default to use red light and IR at the same time
*@param sampleRate Sampling rate, default 400 samples every second
*@param pulseWidth Pulse width: the longer the pulse width, the wider the detection range. Default to be Max range
*@param adcRange Measurement Range, default 4096 (nA), 15.63(pA) per LSB
*/
particleSensor.sensorConfiguration(/*ledBrightness=*/0x1F, /*sampleAverage=*/SAMPLEAVG_4, \
/*ledMode=*/MODE_MULTILED, /*sampleRate=*/SAMPLERATE_400, \
/*pulseWidth=*/PULSEWIDTH_411, /*adcRange=*/ADCRANGE_4096);
}
void loop()
{
//Print result
Serial.print("R=");
/*!
*@brief Get red value
*@return Red light reading
*/
Serial.print(particleSensor.getRed());
Serial.print(" IR=");
/*!
*@brief Get IR value
*@return IR reading
*/
Serial.print(particleSensor.getIR());
Serial.println();
delay(100);
}
Since this was not working I tried running simple I2C scanner code, recieving the result: Scanning I2C bus...
I2C device found at 0x57 !
Scan complete
#include <Wire.h>
void setup() {
Serial.begin(115200);
Wire.begin(); // Join I2C bus as master
delay(1000); // Wait for serial monitor to open
Serial.println("Scanning I2C bus...");
}
void loop() {
byte error, address;
int nDevices = 0;
for(address = 1; address < 127; address++ ) {
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0) {
Serial.print("I2C device found at 0x");
if (address < 16) Serial.print("0");
Serial.print(address, HEX);
Serial.println(" !");
nDevices++;
}
else if (error == 4) {
Serial.print("Unknown error at address 0x");
if (address < 16) Serial.print("0");
Serial.println(address, HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("Scan complete\n");
delay(2000); // Wait 2 seconds before next scan
}
Since I had found the I2C address was available I tried to find the part ID to verify that the sensor was functioning. The result I got was:
Testing MAX30102 Part ID...
Read register 0xFF = 0xFF
As the result should be 0x15, does this mean there is something wrong with the PPG sensor, have I wired it wrong? I'm very happy to give more information and I really appreciate any help of any kind.