Turbidity Data wont Send in Firebase realtime database

I am creating a water monitoring system. I want to monitor the PH, Temperate and Turbidity in it. My problem is My Turbidity Data wont send in my firebase realtime database. My Turbidity wont give a data If I want to send the data in the database. But If I remove the firebase code, it works properly.

#include <OneWire.h>
#include <DallasTemperature.h>
#include "DFRobot_ESP_PH.h"
#include "EEPROM.h"
#include <WiFi.h>
#include <Firebase_ESP_Client.h>

#define WIFI_SSID "ESP_32"
#define WIFI_PASSWORD "12345678"

#define API_KEY "****"

#define DATABASE_URL "****" 

#define USER_EMAIL "****"
#define USER_PASSWORD "****"

// Define Firebase Data object
FirebaseData fbdo;

FirebaseAuth auth;
FirebaseConfig config;

DFRobot_ESP_PH ph;
#define ESPADC 4096.0   //the esp Analog Digital Convertion value
#define ESPVOLTAGE 3300 //the esp voltage supply value
#define PH_PIN 35  
float phvoltage, phValue, temperature = 25;

#define SENSOR_PIN  19

OneWire oneWire(SENSOR_PIN);
DallasTemperature DS18B20(&oneWire);

float tempC; // temperature in Celsius
float tempF; // temperature in Fahrenheit
float tVoltage;
float turbidityValue;

#define BUTTON_PIN 15
#define LED_PIN 17
#define TURBIDITY_PIN 13

bool buttonState = false;

#include <ThreeWire.h>  
#include <RtcDS1302.h>

ThreeWire myWire(27,25,12); // IO, SCLK, CE
RtcDS1302<ThreeWire> Rtc(myWire);

/* SENSORS USED */

void setup()
{
  Serial.begin(9600);
  DS18B20.begin();
  EEPROM.begin(32);
  ph.begin();
  Rtc.Begin();
  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();

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

  /* Assign the user sign-in credentials */
  auth.user.email = USER_EMAIL;
  auth.user.password = USER_PASSWORD;

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

  // Comment or pass false value when WiFi reconnection will control by your code or third party library e.g. WiFiManager
  Firebase.reconnectNetwork(true);
 read timeout can be occurred.
  fbdo.setBSSLBufferSize(4096 /* Rx buffer size in bytes from 512 - 16384 */, 1024 /* Tx buffer size in bytes from 512 - 16384 */);

  // Limit the size of response payload to be collected in FirebaseData
  fbdo.setResponseSize(2048);

  Firebase.begin(&config, &auth);

  Firebase.setDoubleDigits(5);

  config.timeout.serverResponse = 10 * 1000;

  // Setup button and LED pins
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  pinMode(LED_PIN, OUTPUT);
}

void loop()
{
  // Read button state
  bool newButtonState = digitalRead(BUTTON_PIN);
  
  // Check if button state has changed
  if (newButtonState != buttonState) {
    delay(50); // Debounce
    if (newButtonState == LOW) { // Button is pressed
      sendDataToFirebase();
    }
  }
  buttonState = newButtonState;

  // Blink LED if data is being sent
  if (Firebase.ready() && newButtonState == LOW) {
    digitalWrite(LED_PIN, !digitalRead(LED_PIN)); // Toggle LED
    delay(500); // Blink interval
  } else {
    digitalWrite(LED_PIN, HIGH); // Turn off LED
  }

  delay(100); // Adjust delay as needed
}

void sendDataToFirebase() {

  tVoltage = analogRead(TURBIDITY_PIN);
  turbidityValue = tVoltage * (5.0 / 1024.0);
  
  DS18B20.requestTemperatures();       // send the command to get temperatures
  tempC = DS18B20.getTempCByIndex(0);  // read temperature in °C
  tempF = tempC * 9 / 5 + 32; // convert °C to °F 
  
  phvoltage = analogRead(PH_PIN) / ESPADC * ESPVOLTAGE;
  phValue = ph.readPH(phvoltage, temperature);

  RtcDateTime now = Rtc.GetDateTime();
  char dateTimeString[20];
  printDateTime(now, dateTimeString); // Get date and time string

  // Print sensor data to serial monitor for debugging
  Serial.print("Temperature (C): ");
  Serial.println(tempC);
  Serial.print("PH Value: ");
  Serial.println(phValue);
  Serial.print("Turbidity: ");
  Serial.println(turbidityValue);

  // Firebase.ready() should be called repeatedly to handle authentication tasks.
  if (Firebase.ready())
  {
    String firebasePath = "/SensorData/" + String(dateTimeString) + "/";

    Firebase.RTDB.setFloat(&fbdo, firebasePath + "Temperature", tempC);
    Firebase.RTDB.setFloat(&fbdo, firebasePath + "PH Value", phValue);
    Firebase.RTDB.setFloat(&fbdo, firebasePath + "Turbidity", turbidityValue);
   
  }
  delay(2000); // Delay for 2 seconds after sending data
}

#define countof(a) (sizeof(a) / sizeof(a[0]))

void printDateTime(const RtcDateTime& dt, char* dateString)
{
    snprintf_P(dateString, 
            20,
            PSTR("%02u-%02u-%04u %02u:%02u:%02u"),
            dt.Day(),
            dt.Month(),
            dt.Year(),
            dt.Hour(),
            dt.Minute(),
            dt.Second() );
}

 In this part of the code I Get all the sensors data analyze it and send it to the firebase database I've search on internet how to fix it. But I havent found any. I hope someone will help me fix it. 

New contributor

john paul Anud is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật