#include <WiFi.h>
#include <FirebaseESP32.h>
// Replace with your network credentials
#define WIFI_SSID "your-SSID"
#define WIFI_PASSWORD ""
// Firebase project credentials
#define FIREBASE_HOST "esp-8266-7c7e0.firebaseio.com"
#define FIREBASE_AUTH "your-database-secret"
// Firebase Storage Bucket
#define FIREBASE_STORAGE_BUCKET "esp-8266-7c7e0.appspot.com"
FirebaseData fbdo;
void setup() {
Serial.begin(115200);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
Firebase.reconnectWiFi(true);
}
void loop() {
String filePath = "/text folder/transfer.txt"; // Adjust the file path
String fileContent;
if (Firebase.Storage.download(&fbdo, FIREBASE_STORAGE_BUCKET, filePath, "")) {
Serial.println("File downloaded successfully");
// Read the file content from the downloaded file
int len = fbdo.payloadLength();
char data[len + 1];
fbdo.download(&data[0], len + 1);
fileContent = String(data);
Serial.println("File Content: ");
Serial.println(fileContent);
} else {
Serial.println("Failed to download file");
Serial.println("REASON: " + fbdo.errorReason());
}
delay(10000); // Adjust delay as needed
}