Hello everyone!
I am using GY-MAX30100 sensor to measure HeartRate and spo2. I am getting proper readings from the sensor when I am not sending my readings to firebase but when I start sending my readings to firebase, my sensor stops measuring heart rate and spo2 reading and only sending 0 bpm and 0 spo2 readings to firebase and even to my serial monitor.
Here is my code, when I am sending my readings to Firebase:
#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
// Set these to run example.
#define FIREBASE_HOST "test-8bc5c.firebaseio.com"
#define FIREBASE_AUTH "JATYiyaws143Yd68A12wjlG38MBa3UjFAn4BZ2Rv"
#define WIFI_SSID "TP-LINK_8D8E"
#define WIFI_PASSWORD "qwerty1234"
#include <Wire.h>
#include "MAX30100_PulseOximeter.h"
float bpm = 0.0;
float oxygen = 0.0;
#define REPORTING_PERIOD_MS 1000
// PulseOximeter is the higher level interface to the sensor
// it offers:
// * beat detection reporting
// * heart rate calculation
// * SpO2 (oxidation level) calculation
PulseOximeter pox;
uint32_t tsLastReport = 0;
// Callback (registered below) fired when a pulse is detected
void onBeatDetected()
{
Serial.println("Beat!");
}
void setup()
{
Serial.begin(230400);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
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()) {
Serial.println("FAILED");
for(;;);
} else {
Serial.println("SUCCESS");
}
// 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
pox.setOnBeatDetectedCallback(onBeatDetected);
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
}
void loop()
{
// Make sure to call update as fast as possible
pox.update();
// Asynchronously dump heart rate and oxidation levels to the serial
// For both, a value of 0 means "invalid"
if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
bpm = pox.getHeartRate();
oxygen = pox.getSpO2();
Serial.print("Heart rate:");
Serial.print(bpm);
Serial.print("bpm / SpO2:");
Serial.print(oxygen);
Serial.println("%");
delay(100);
tsLastReport = millis();
}
Firebase.setInt("/heartbeat", bpm);
Firebase.setInt("/oxygen", oxygen);
}
Here are my readings when I am trying to send data to Firebase:
Heart rate:0.00bpm / SpO2:0.00%
Heart rate:0.00bpm / SpO2:0.00%
Heart rate:0.00bpm / SpO2:0.00%
Heart rate:0.00bpm / SpO2:0.00%
Heart rate:0.00bpm / SpO2:0.00%
Heart rate:0.00bpm / SpO2:0.00%
Heart rate:0.00bpm / SpO2:0.00%
I will be very thankful to you if you will look into my problem.
Thank You!
PS: I have also attached my sensor’s picture: