MAX30100 sensor does not work with Arduino Cloud

I am trying to interface the MAX30100 and MAX30102 sensors with my Arduino Nano 33 IOT board. I am using the Arduino IOT Cloud for visualising my data. I am not getting any HR or spo2 values on the serial monitor, it always returns zero, except for a few instances when it randomly returns a few beats. The example I am using is “MAX30100_minimal” and it works perfectly with the Arduino IDE. I have attached the code I am uploading while using it with the cloud.

// MAX30100lib - Version: Latest 
//#include <CircularBuffer.h>
//#include <MAX30100.h>
//#include <MAX30100_BeatDetector.h>
//#include <MAX30100_Filters.h>
#include <MAX30100_PulseOximeter.h>
//#include <MAX30100_Registers.h>
//#include <MAX30100_SpO2Calculator.h>

#include <Wire.h>

#define REPORTING_PERIOD_MS     1000
// Arduino Cloud Provider Examples - Version: 1.2.0
#include <ArduinoCloudProviderExamples.h>

  Sketch generated by the Arduino IoT Cloud Thing "Untitled" 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  CloudPercentage spo2;
  CloudHeartRate heartBeat;
  CloudTemperature temperature;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.

#include "thingProperties.h"

PulseOximeter pox;
//MAX30100 sensor;

uint32_t tsLastReport = 0;

// Callback (registered below) fired when a pulse is detected
void onBeatDetected()

void setup() {
  // Initialize serial and wait for port to open:
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  // Defined in thingProperties.h

  // Connect to Arduino IoT Cloud
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4

  Serial.print("Initializing pulse oximeter..");

  // Initialize the PulseOximeter instance
  // Failures are generally due to an improper I2C wiring, missing power supply
  // or wrong target chip
  if (!pox.begin()) {
  } else {

  // The default current for the IR LED is 50mA and it could be changed
  //   by uncommenting the following line. Check MAX30100_Registers.h for all the
  //   available options.
  // pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);

  // Register a callback for the beat detection

void loop() {
  // Your code here 
  // Make sure to call update as fast as possible
  if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
      heartBeat = pox.getHeartRate();
      spo2 = pox.getSpO2();
      temperature = 32;
      Serial.print("Heart rate:");
      Serial.print("bpm / SpO2:");
      Serial.print("% / temperature:");

      tsLastReport = millis();
  heartBeat = random(300,600);
  spo2 = random(94,98);
  temperature = random(25,35);

I tried printing random values for the variables and they were correctly printed on the serial monitor as well as on the cloud. There is some issue with the onBeatDetected() function, it is not getting called for some reason. Please Guide.

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