Problem to upload max30100 & mlx90614 at same time to firebase with esp32

the 2 sensors is working good without firebase additional code but when i applied the firebase code
one of them is working and upload data to firebase and the other is ( 0 )
i am working with
1- esp 32
2- max30100 spo2 & heart rate
3- mlx90614 tempreature

#include <Wire.h>
#include <Arduino.h>
#include "MAX30100_PulseOximeter.h"
#include <Adafruit_MLX90614.h>
#include <Firebase_ESP_Client.h>

//Provide the token generation process info.
#include "addons/TokenHelper.h"
//Provide the RTDB payload printing info and other helper functions.
#include "addons/RTDBHelper.h"

// Insert your network credentials
#define WIFI_SSID ""
#define WIFI_PASSWORD ""

// Insert Firebase project API Key
#define API_KEY ""

// Insert RTDB URLefine the RTDB URL */
#define DATABASE_URL "" 
//Define Firebase Data object
FirebaseData fbdo;

FirebaseAuth auth;
FirebaseConfig config;

unsigned long sendDataPrevMillis = 0;
int count = 0;
bool signupOK = false;

#define I2C_SDA 21
#define I2C_SCL 22
#define REPORTING_PERIOD_MS 1000

uint8_t max30100_address = 0x57;
uint8_t irmlx90614_address = 0x5A;
uint32_t tsLastReport = 0;

Adafruit_MLX90614 mlx = Adafruit_MLX90614();
PulseOximeter pox;

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

  /* Assign the api key (required) */
  config.api_key = API_KEY;

  /* Assign the RTDB URL (required) */
  config.database_url = DATABASE_URL;

  /* Sign up */
  if (Firebase.signUp(&config, &auth, "", "")){
    Serial.println("ok");
    signupOK = true;
  }
  else{
    Serial.printf("%s\n", config.signer.signupError.message.c_str());
  }

  /* Assign the callback function for the long running token generation task */
  config.token_status_callback = tokenStatusCallback; //see addons/TokenHelper.h
  
  Firebase.begin(&config, &auth);
  Firebase.reconnectWiFi(true);
}

void loop() {
//printTemp();
printFreq();
//delay(1000);
   if (Firebase.ready() && signupOK && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0))
   {
    sendDataPrevMillis = millis();
  
    if (Firebase.RTDB.setInt(&fbdo, "sensors/Temp", mlx.readObjectTempC()))
    {
      Serial.println("PASSED");
      Serial.println("PATH: " + fbdo.dataPath());
      Serial.println("TYPE: " + fbdo.dataType());
    }
    else {
      Serial.println("FAILED");
      Serial.println("REASON: " + fbdo.errorReason());
    }
    count++;
    
   
    if (Firebase.RTDB.setInt(&fbdo, "sensors/spo2 & heart",pox.getHeartRate()))
    {
      Serial.println("PASSED");
      Serial.println("PATH: " + fbdo.dataPath());
      Serial.println("TYPE: " + fbdo.dataType());
    }
    else 
    {
      Serial.println("FAILED");
      Serial.println("REASON: " + fbdo.errorReason());
    }
    
}
}
void printTemp()
{
Serial.print(mlx.readObjectTempC()); Serial.println("C");
}

void printFreq()
{
pox.update();

if (millis() - tsLastReport > REPORTING_PERIOD_MS) 
{
    Serial.print("Heart rate:");
    Serial.print(pox.getHeartRate());
    Serial.print("bpm / SpO2:");
    Serial.print(pox.getSpO2());
    Serial.println("%");
    printTemp();
    tsLastReport = millis();
}
}

That does not sound like an Arduino Nano ESP32 and hence your topic has been moved. The Nano ESP32 section is specific for the Arduino Nano ESP32.

there is no much diffrence in the coding process

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