Sending date from arduino code to firebase

Greetings all,

I am storing sensors data to firebase which is working fine but I want to add the time with each value.
I did a lot of research and I tried using json and other methods but nothing is working .
I get the time printing in the serial monitor but when I try to store it in firebase some methods give error or no error but the time wont upload .

The following is one of the codes I have been trying but its missing the lines to store date in firebase since that is my question.
I am using arduino wifi rev2 .
`
#include <WiFiNINA.h>
#include <Firebase_Arduino_WiFiNINA.h>
#include <Firebase_Arduino_WiFiNINA_HTTPClient.h>
#include <NTPClient.h>
#include <WiFiUdp.h>

#define FIREBASE_HOST "............"
#define FIREBASE_AUTH "................."
#define WIFI_SSID "......."
#define WIFI_PASSWORD "......."

const long utcOffsetInSeconds = 14400;

WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP,utcOffsetInSeconds);

FirebaseData firebaseData;
bool state = false;
double currentTimestamp ;

void setup()
{

Serial.begin(115200);
delay(100);
Serial.println();
Serial.print("Connecting to Wi-Fi");
int status = WL_IDLE_STATUS;
while (status != WL_CONNECTED)
{
status = WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print(".");
delay(300);
timeClient.begin();

}
Serial.println();
Serial.print("Connected with IP: ");

Serial.println(WiFi.localIP());
Serial.println();

//Provide the authentication data
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH, WIFI_SSID, WIFI_PASSWORD);
Firebase.reconnectWiFi(true);

}

void loop()
{

//---------------------------------

timeClient.update();

/Serial.print(timeClient.getHours());
/Serial.print(":");
/Serial.print(timeClient.getMinutes());
/Serial.print(":");
/Serial.println(timeClient.getSeconds());

/String TimeNow = timeClient.getFormattedTime();
/ Serial.println(TimeNow);

}`

Show the code trying to append date, time....

Thank you for responding.
Just to let you know I am a beginner in this which probably show from the code, anyway these are some lines that i tried . I couldn't find the exact lines since I kept editing the code and changing thing multiple times but the following to give you an idea and if you let me know what I am doing wrong .

Firebase.setString(TimeNow);

Firebase.setJSON ()

I also tries using pushString which i don't know if it a thing .

Thanks. Sorry but I don't know the details of using Firebase, how it works.
You already manage to transfer a lot of data so adding date/time ought to be "not too difficult" as I thought.
What does the other transferring code look like?
Could You post the entire code?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.