Go Down

Topic: Problem to store my data to firebase using Nodemcu esp32 and DFrobot heart rate  (Read 128 times) previous topic - next topic

yys100

Hi, im trying to send and store the value of my DFRobot Heartrate sensor to the real time firebase. I used it together with nodemcu esp 32. Unfortunately, I have read up alot online and I have no idea how to push the data to firebase. What I got are compilation error as i stated here.  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. Thanks!


Code: [Select]

#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");
 }
  
 }



UPDATE: I managed to get the code works but I cannot get the heart beat bpm, it just shows ''wait for valid data" and 0 (I will attach it ) AND I am able to push the data into it.

Current problem: Heart beat BPM shows 0




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


Any help will be highly appreciated. Thanks !

Go Up