how to lower MAX30102 clock speed ?

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
LLAMAFTW01
 
Posts: 10
Joined: Wed Nov 30, 2022 8:05 am

how to lower MAX30102 clock speed ?

Post by LLAMAFTW01 »

Hi I wanted to ask if anyone knows how to lower the clock speed of this MAX30102 Sensor using the source file ?

The image below the the library I'm using for this sensor.
image.png
image.png (4.86 KiB) Viewed 67 times

User avatar
adafruit_support_bill
 
Posts: 88136
Joined: Sat Feb 07, 2009 10:11 am

Re: how to lower MAX30102 clock speed ?

Post by adafruit_support_bill »

There are not modifiable clocks in that device. The ADC clock speed is fixed @ 10.48Mz: https://datasheets.maximintegrated.com/ ... X30105.pdf
The i2c clock speed is controlled externally by the i2c bus master.

User avatar
LLAMAFTW01
 
Posts: 10
Joined: Wed Nov 30, 2022 8:05 am

Re: how to lower MAX30102 clock speed ?

Post by LLAMAFTW01 »

Hi thanks for the reply so does that mean I cannot change the clock speed of the sensor MAX30102 sensor even if I use the source file? cause I am using 3 sensors right now MAX30102, MPU6050, MLX90614 and planning to add a fourth NEO-6M GPS Module do you think with a esp32 i am able to use all these sensors together ? Due to the fact that the sensors MPU6050, MLX90614 are working together now but the MAX30102 doesn't show data as shown below and the code I'm using.

Code: Select all

#include <Wire.h>
#include "MAX30105.h"
#include "heartRate.h"
#include <Adafruit_MLX90614.h>
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#define REPORTING_PERIOD_MS     1000

Adafruit_MLX90614 mlx = Adafruit_MLX90614(); //0x5A
Adafruit_MPU6050 mpu;                        //0x68                          
MAX30105 particleSensor;                                

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;

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

    particleSensor.begin(Wire, I2C_SPEED_FAST);
    particleSensor.setup();
    particleSensor.setPulseAmplitudeRed(0x0A); //Turn Red LED to low to indicate sensor is running
    particleSensor.setPulseAmplitudeGreen(0); //Turn off Green LED
    mlx.begin();
    mpu.begin(); 
        mpu.setAccelerometerRange(MPU6050_RANGE_8_G);
        Serial.print("Accelerometer range set to: ");
        switch (mpu.getAccelerometerRange()) {
        case MPU6050_RANGE_2_G:
          Serial.println("+-2G");
          break;
        case MPU6050_RANGE_4_G:
          Serial.println("+-4G");
          break;
        case MPU6050_RANGE_8_G:
          Serial.println("+-8G");
          break;
        case MPU6050_RANGE_16_G:
          Serial.println("+-16G");
          break; 
        }
        mpu.setGyroRange(MPU6050_RANGE_500_DEG);
        Serial.print("Gyro range set to: ");
        switch (mpu.getGyroRange()) {
        case MPU6050_RANGE_250_DEG:
          Serial.println("+- 250 deg/s");
          break;
        case MPU6050_RANGE_500_DEG:
          Serial.println("+- 500 deg/s");
          break;
        case MPU6050_RANGE_1000_DEG:
          Serial.println("+- 1000 deg/s");
          break;
        case MPU6050_RANGE_2000_DEG:
          Serial.println("+- 2000 deg/s");
          break;
        }
      
        mpu.setFilterBandwidth(MPU6050_BAND_5_HZ);
        Serial.print("Filter bandwidth set to: ");
        switch (mpu.getFilterBandwidth()) {
        case MPU6050_BAND_260_HZ:
          Serial.println("260 Hz");
          break;
        case MPU6050_BAND_184_HZ:
          Serial.println("184 Hz");
          break;
        case MPU6050_BAND_94_HZ:
          Serial.println("94 Hz");
          break;
        case MPU6050_BAND_44_HZ:
          Serial.println("44 Hz");
          break;
        case MPU6050_BAND_21_HZ:
          Serial.println("21 Hz");
          break;
        case MPU6050_BAND_10_HZ:
          Serial.println("10 Hz");
          break;
        case MPU6050_BAND_5_HZ:
          Serial.println("5 Hz");
          break;
        }
    Serial.println();
}

void loop() {
  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.println(" No finger? ");
      
    sensors_event_t a, g, temp;
    mpu.getEvent(&a, &g, &temp);
    
    Serial.println(" ");
    Serial.println("Accelerometer ");
    Serial.print("X: ");
    Serial.print(a.acceleration.x, 1);
    Serial.print(" m/s^2, ");
    Serial.print("Y: ");
    Serial.print(a.acceleration.y, 1);
    Serial.print(" m/s^2, ");
    Serial.print("Z: ");
    Serial.print(a.acceleration.z, 1);
    Serial.println(" m/s^2");
 
    Serial.print("Gyroscope ");
    Serial.print("X: ");
    Serial.print(g.gyro.x, 1);
    Serial.print(" rps, ");
    Serial.print("Y: ");
    Serial.print(g.gyro.y, 1);
    Serial.print(" rps, ");
    Serial.print("Z: ");
    Serial.print(g.gyro.z, 1);
    Serial.println(" rps");
    delay(500);

    Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempC());
    Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C");
    Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempF());
    Serial.print("*F\tObject = "); Serial.print(mlx.readObjectTempF()); Serial.println("*F");

    Serial.println("-----------------------------------------------------------------");
    Serial.println(" ");

    delay(1000);
}
image_2022-12-04_214838468.png
image_2022-12-04_214838468.png (4.94 KiB) Viewed 63 times

User avatar
adafruit_support_bill
 
Posts: 88136
Joined: Sat Feb 07, 2009 10:11 am

Re: how to lower MAX30102 clock speed ?

Post by adafruit_support_bill »

the MAX30102 doesn't show data as shown below and the code I'm using.
The MAX30102 is a pulse oximeter. Your code is using a library for a MAX30105 which is a particle sensor.

Neither device has a controllable clock.

User avatar
LLAMAFTW01
 
Posts: 10
Joined: Wed Nov 30, 2022 8:05 am

Re: how to lower MAX30102 clock speed ?

Post by LLAMAFTW01 »

ahh okay thank you, I have another question does the MPU6050 have a controllable clock ?

User avatar
adafruit_support_bill
 
Posts: 88136
Joined: Sat Feb 07, 2009 10:11 am

Re: how to lower MAX30102 clock speed ?

Post by adafruit_support_bill »

It can use either the internal clock or an external clock. Regardless of the clock source however, it looks like the accelerometer sample rate is fixed and there are 2 possible speeds for the gyro.
See page 17 of the datasheet:
https://invensense.tdk.com/wp-content/u ... sheet1.pdf

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”