Skip to content

Instantly share code, notes, and snippets.

@vivekanandRdhakane
Created May 20, 2020 09:20
Show Gist options
  • Save vivekanandRdhakane/64a1c716c94a5c505733e791de99a960 to your computer and use it in GitHub Desktop.
Save vivekanandRdhakane/64a1c716c94a5c505733e791de99a960 to your computer and use it in GitHub Desktop.
/*Author: Vivekanand Dhakane
* updated on: 16 May 2020
*/
#include "FirebaseESP8266.h"
#include <ESP8266WiFi.h>
#define FIREBASE_HOST "data-logger-5684b.firebaseio.com" //Without http:// or https:// schemes
#define FIREBASE_AUTH "28fVOXd3EYLKAWCVMEcZ121NvSvRo5USOkssEcoi"
#define WIFI_SSID "Internet"
#define WIFI_PASSWORD "41450200"
#define safty_time 10000
//Define Firebase Data object
FirebaseData firebaseData;
void setup()
{
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED)
{
delay(300);
//if wifi is not availaible then put module in sleep
if(millis()> safty_time)
{
ESP.deepSleep(300e6);
}
}
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
Firebase.reconnectWiFi(true);
String path = "Data_Logger/";
/**********Get timeStamp***********/
if (Firebase.setTimestamp(firebaseData, path + "Set/Timestamp"))
{
// firebaseData.payload()will return timeStamp in milliseconds
String inst_path = path + "SenseData/" + firebaseData.payload();
/**********Upload data with timeStamp***********/
if (Firebase.setInt(firebaseData,inst_path,analogRead(A0)))
{
//data uploaded
}
else
{
//error
}
}
else
{
//error
}
ESP.deepSleep(300e6);
}
void loop()
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment