This is my code. I want to save the data get by sensors to the firebase database. I dont know what function causes the error coz the errors only says Ping Timeout
This is my code. I want to save the data get by sensors to the firebase database. I dont know what function causes the error coz the errors only says Ping Timeout
#include <OneWire.h>
#include <DallasTemperature.h>
#include "DFRobot_ESP_PH.h"
#include "EEPROM.h"
#include <WiFi.h>
#include <FirebaseESP32.h>
#define WIFI_SSID "ESP_32"
#define WIFI_PASSWORD "12345678"
#define FIREBASE_HOST "https://fishmanagement-1ab6e-default-rtdb.firebaseio.com/"
#define FIREBASE_AUTH "24e050c622e0e3f4f373e84277730da5b57186bd"
FirebaseConfig firebaseConfig;
FirebaseAuth firebaseAuth;
FirebaseData firebaseData;
DFRobot_ESP_PH ph;
#define ESPADC 4096.0
#define ESPVOLTAGE 3300
#define PH_PIN 35
float phvoltage, phValue, temperature = 25;
#define SENSOR_PIN 19
OneWire oneWire(SENSOR_PIN);
DallasTemperature DS18B20(&oneWire);
float tempC;
float tempF;
void setup() {
Serial.begin(9600);
DS18B20.begin();
EEPROM.begin(32);
ph.begin();
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("Connecting to Wi-Fi");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.print("Connected to Wi-Fi, IP address: ");
Serial.println(WiFi.localIP());
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
}
void loop() {
int sensorValue = analogRead(13);
float voltage = sensorValue * (5.0 / 1024.0);
DS18B20.requestTemperatures();
tempC = DS18B20.getTempCByIndex(0);
tempF = tempC * 9 / 5 + 32; // convert °C to °F
phvoltage = analogRead(PH_PIN)
phValue = ph.readPH(phvoltage, temperature);
Serial.print("pH:");
Serial.println(phValue, 4);
Serial.print("Turbidity: ");
Serial.print(voltage);
Serial.println("Temperature: ");
Serial.print(tempC);
Serial.print("°C");
Serial.print(" ~ ");
Serial.print(tempF);
Serial.println("°F");
Firebase.pushFloat(firebaseData, "/pH", phValue);
Firebase.pushFloat(firebaseData, "/Turbidity", voltage);
Firebase.pushFloat(firebaseData, "/Temperature_C", tempC);
Firebase.pushFloat(firebaseData, "/Temperature_F", tempF);
delay(1000);
}
``
I have searched in internet but I havent found ways on how to fix that is why I am asking here. Hopefully somebody can 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.