Easy IoT is a simplest IoT Solution presented by DFRobot
#42412
Hi, I have been working on the project using the heart rate monitor sensor with nodemcu esp 32. I have tested it on the digital mode and it works perfectly but when I try to push the data to firebase, it just keeping showing zero BPM and I wonder why. Anyone could help with this problem, please?

Code:
Code: Select all
#define heartratePin 32
#include "DFRobot_Heartrate.h"
#include <WiFi.h>  //1. Include WiFi.h
#include "FirebaseESP32.h"  //2. Include Firebase ESP32 library (this library)



// Set these to run example.
#define FIREBASE_HOST "test.firebaseio.com"  
#define FIREBASE_AUTH "hW8qlM48dGkxxxxxxxx1Pq5UD21YgPq2E0c"
#define WIFI_SSID "Gummya"
#define WIFI_PASSWORD "testtest1"

DFRobot_Heartrate heartrate(DIGITAL_MODE); ///< ANALOG_MODE or DIGITAL_MODE
FirebaseData firebaseData;  //3. Declare the Firebase Data object in the global scope



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

void loop() {
  uint8_t rateValue;
  heartrate.getValue(heartratePin); ///< A1 foot sampled values
  rateValue = heartrate.getRate(); ///< Get heart rate value
    if(Firebase.setInt(firebaseData,"HeartBeat/BPM_data", rateValue)){
    //if (firebaseData.dataType()== "Int")
    Serial.println(rateValue);
  }

  delay(20);
}

 void initWifi(){
    WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  Serial.print("Connecting to Wi-Fi");
  while (WiFi.status() != WL_CONNECTED)
  {
    Serial.print(".");
    delay(300);
  }
  Serial.println();
  Serial.print("Connected with IP: ");
  Serial.println(WiFi.localIP());
  Serial.println();

  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
  Firebase.reconnectWiFi(true);
  
  //Set database read timeout to 1 minute (max 15 minutes)
  Firebase.setReadTimeout(firebaseData, 1000 * 60);
  //tiny, small, medium, large and unlimited.
  //Size and its write timeout e.g. tiny (1s), small (10s), medium (30s) and large (60s).
  Firebase.setwriteSizeLimit(firebaseData, "tiny");
 }

Serial Monitor output:
Image


Got the FirebaseESP32.h library from --> https://github.com/mobizt/Firebase-ESP32

I've searched for quite awhile but ended up with nothing, Im fairly new to arduino and programming so please help me. I will be grateful to you.
Any help will be highly appreciated. Thanks !