Arduino MAX 2560 and pulseoxometer MAX30102 not initialising

So I'm trying to connect a MAX30102 pulseoxometer to an arduino MEGA2560 using the code below:

#include <Wire.h>
#include "MAX30105.h"

MAX30105 particleSensor; // initialize MAX30102 with I2C

void setup()
{
  Serial.begin(115200);
  while(!Serial); //We must wait for Teensy to come online
  delay(100);
  Serial.println("");
  Serial.println("MAX30102");
  Serial.println("");
  delay(100);
  // Initialize sensor
  if (particleSensor.begin(Wire, I2C_SPEED_FAST) == false) //Use default I2C port, 400kHz speed
  {
    Serial.println("MAX30105 was not found. Please check wiring/power. ");
    while (1);
  }

  byte ledBrightness = 70; //Options: 0=Off to 255=50mA
  byte sampleAverage = 1; //Options: 1, 2, 4, 8, 16, 32
  byte ledMode = 2; //Options: 1 = Red only, 2 = Red + IR, 3 = Red + IR + Green
  int sampleRate = 400; //Options: 50, 100, 200, 400, 800, 1000, 1600, 3200
  int pulseWidth = 69; //Options: 69, 118, 215, 411
  int adcRange = 16384; //Options: 2048, 4096, 8192, 16384

  particleSensor.setup(ledBrightness, sampleAverage, ledMode, sampleRate, pulseWidth, adcRange); //Configure sensor with these settings
}

void loop() {
  particleSensor.check(); //Check the sensor
  while (particleSensor.available()) {
      // read stored IR
      Serial.print(particleSensor.getFIFOIR());
      Serial.print(",");
      // read stored red
      Serial.println(particleSensor.getFIFORed());
      // read next set of samples
      particleSensor.nextSample();      
  }
}

but when running it and looking at my COM monitor I only see this


or other random characters.

The connections are as such (with no additional components in-between):

  • VIN - 3,3V

  • SDA - A0

  • SCL - A1

  • GND - GND

I tried the same on an Arduino UNO with the same program and schematic but to no avail.
The boards themselves seem to be fine as they run all my other programs for different projects.

Your serial monitor needs to be set to 115200 baud.

I set it to 9600 and it works
EDIT: I'm an idiot and only now did I realise how to change the monitor rate...

Great!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.