Hi, I'm already trying to connect these 3 sensors using ESP32, but the result is data from MAX30102 won't come out. Even though they are successfully initializing. So first i tried GY-906 with MPU6050, GY-906 with MAX30102, and the last MPU6050 with MAX30102. from the 3 of the succeed one is the first one GY-906 with MPU6050 and the rest the data won't change
did you test each module using a separate program to check it was working?
give links to the specific modules?
upload a schematic showing the modules are connected and powered?
possibly one of the sensors is not correctly tri-stating it's output to high-impedance when not enabled
possibly use the second I2C interface Wire1 with the MAX30102?
i make initialization sensors in the part of my program, this is the program that i used to checked MAX30102 and MPU6050. using AdafruitMPU6050 and Sparkfun Max3010x library
#include <Wire.h>
#include "MAX30105.h"
#include "heartRate.h"
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
MAX30105 particleSensor;
Adafruit_MPU6050 mpu;
const byte RATE_SIZE = 4; // Increase this for more averaging. 4 is good.
byte rates[RATE_SIZE]; // Array of heart rates
byte rateSpot = 0;
long lastBeat = 0; // Time at which the last beat occurred
float beatsPerMinute;
int beatAvg;
float initialGyroX, initialGyroY, initialGyroZ;
float initialAccelerometerX, initialAccelerometerY, initialAccelerometerZ;
void setup() {
Serial.begin(115200);
while (!Serial)
delay(10);
Serial.println("Initializing...");
// Initialize MAX30105 sensor
if (!particleSensor.begin(Wire, I2C_SPEED_FAST)) { // Use default I2C port, 400kHz speed
Serial.println("MAX30105 was not found. Please check wiring/power.");
while (1);
}
Serial.println("Place your index finger on the sensor with steady pressure.");
particleSensor.setup(); // Configure sensor with default settings
particleSensor.setPulseAmplitudeRed(0x0A); // Turn Red LED to low to indicate sensor is running
particleSensor.setPulseAmplitudeGreen(0); // Turn off Green LED
// Initialize MPU6050 sensor
if (!mpu.begin()) {
Serial.println("Failed to find MPU6050 chip");
while (1) {
delay(10);
}
}
Serial.println("MPU6050 Found!");
mpu.setAccelerometerRange(MPU6050_RANGE_16_G);
mpu.setGyroRange(MPU6050_RANGE_500_DEG);
mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);
// Get initial gyroscope and accelerometer readings for calibration
sensors_event_t accelEvent, gyroEvent;
mpu.getAccelerometerSensor()->getEvent(&accelEvent);
mpu.getGyroSensor()->getEvent(&gyroEvent);
// Store initial values for calibration
initialGyroX = gyroEvent.gyro.x;
initialGyroY = gyroEvent.gyro.y;
initialGyroZ = gyroEvent.gyro.z;
initialAccelerometerX = accelEvent.acceleration.x;
initialAccelerometerY = accelEvent.acceleration.y;
initialAccelerometerZ = accelEvent.acceleration.z;
}
void loop() {
// Heart rate measurement
long irValue = particleSensor.getIR();
if (checkForBeat(irValue) == true) {
// We sensed a beat!
long delta = millis() - lastBeat;
lastBeat = millis();
beatsPerMinute = 60 / (delta / 1000.0);
if (beatsPerMinute < 255 && beatsPerMinute > 20) {
rates[rateSpot++] = (byte)beatsPerMinute; // Store this reading in the array
rateSpot %= RATE_SIZE; // Wrap variable
// Take average of readings
beatAvg = 0;
for (byte x = 0 ; x < RATE_SIZE ; x++)
beatAvg += rates[x];
beatAvg /= RATE_SIZE;
}
}
Serial.print("IR=");
Serial.print(irValue);
Serial.print(", BPM=");
Serial.print(beatsPerMinute);
Serial.print(", Avg BPM=");
Serial.print(beatAvg);
if (irValue < 50000)
Serial.print(" No finger?");
Serial.println();
// MPU6050 measurement
sensors_event_t accelEvent, gyroEvent;
mpu.getAccelerometerSensor()->getEvent(&accelEvent);
mpu.getGyroSensor()->getEvent(&gyroEvent);
// Calculate corrected accelerometer values
float correctedAccelX = accelEvent.acceleration.x - initialAccelerometerX;
float correctedAccelY = accelEvent.acceleration.y - initialAccelerometerY;
float correctedAccelZ = accelEvent.acceleration.z - initialAccelerometerZ;
// Remove negative sign for near-zero values (for accelerometer)
if (abs(correctedAccelX) < 0.06) correctedAccelX = 0.0;
if (abs(correctedAccelY) < 0.05) correctedAccelY = 0.0;
if (abs(correctedAccelZ) < 0.05) correctedAccelZ = 0.0;
Serial.print("Acceleration X: ");
Serial.print(correctedAccelX);
Serial.print(", Y: ");
Serial.print(correctedAccelY);
Serial.print(", Z: ");
Serial.print(correctedAccelZ);
Serial.println(" m/s^2");
// Calculate corrected gyro values
float correctedGyroX = gyroEvent.gyro.x - initialGyroX;
float correctedGyroY = gyroEvent.gyro.y - initialGyroY;
float correctedGyroZ = gyroEvent.gyro.z - initialGyroZ;
// Remove negative sign for near-zero values (for gyroscope)
if (abs(correctedGyroX) < 0.06) correctedGyroX = 0.0;
if (abs(correctedGyroY) < 0.06) correctedGyroY = 0.0;
if (abs(correctedGyroZ) < 0.06) correctedGyroZ = 0.0;
Serial.print("Rotation X: ");
Serial.print(correctedGyroX);
Serial.print(", Y: ");
Serial.print(correctedGyroY);
Serial.print(", Z: ");
Serial.print(correctedGyroZ);
Serial.println(" rad/s");
Serial.println("");
delay(500);
}
I suspect it's yet another Adafruit library conflict, especially since you are using a Sparkfun library for the MAX30102. I'm not a big fan of the Adafruit Sensor library system and people seem to always have problems with them.
Use different libraries for the GY-906 and the MPU6050
Try using the Sparkfun MLX90614 (GY906) library with the MAX 30102
I've already tried using the second I2C interface Wire 1 with the max30102 and the output still like the first one and i tried to use pull up resistor 2k2, because my lecturer said it. the outcome still the same