#include <WiFi.h>
#include <HTTPClient.h>
#include <FirebaseESP32.h>
#define WIFI_SSID "Wokwi-GUEST"
#define WIFI_PASSWORD ""
const char* Profile = "test/";
FirebaseData firebaseData;
#define FIREBASE_HOST "https://smart-station-d1c4a-default-rtdb.firebaseio.com"
#define FIREBASE_AUTH "AIzaSyAZSl2rzM-YssMLd9BKy03CSw8PWhjE5Uw"
String messageTemp;
unsigned int count;
void setup_wifi(void)
{
pinMode(LED_BUILTIN, OUTPUT);
Serial.println();
Serial.print("Connecting to ");
Serial.println(WIFI_SSID);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
//***********************************************************
void firebase_config(void)
{
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
//Enable auto reconnect the WiFi when connection lost
Firebase.reconnectWiFi(true);
if (Firebase.getString(firebaseData, Profile)) //Success
{
messageTemp = firebaseData.stringData();
Serial.print("messageTemp = ");
Serial.println(messageTemp);
} else {
Serial.print("Error in getInt, ");
Serial.println(firebaseData.errorReason());
}
}
//***********************************************************
void setup()
{
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT);
setup_wifi();
firebase_config();
count=0;
}
//**********************************************************
void loop()
{
if( Firebase.setString(firebaseData, Profile, String(count)) )
{
Serial.print("message "+String(count)+" sent");
}
else {
Serial.print("Error in getString, ");
Serial.println(firebaseData.errorReason());
}
if (Firebase.getString(firebaseData, Profile))
{
messageTemp = firebaseData.stringData();
Serial.print("messageTemp = ");
Serial.println(messageTemp);
}
else {
Serial.print("Error in getInt, ");
Serial.println(firebaseData.errorReason());
}
count++;
delay(2000);
}
esp:VIN
esp:GND.2
esp:D13
esp:D12
esp:D14
esp:D27
esp:D26
esp:D25
esp:D33
esp:D32
esp:D35
esp:D34
esp:VN
esp:VP
esp:EN
esp:3V3
esp:GND.1
esp:D15
esp:D2
esp:D4
esp:RX2
esp:TX2
esp:D5
esp:D18
esp:D19
esp:D21
esp:RX0
esp:TX0
esp:D22
esp:D23