I am sending the temperature and humidity on an internal website using example DHT11/DHT22 Asynchronous
Web Server from Home_Automation_Using_ESP8266. I was able to add the date/time but it will not update. I do not understand how to use sensor data as an example for time data.
How are you getting the time and how are you sending the time to the web page?
In the following project, we display the last time update on the web page:
But there are many different ways to do that.
Hi Sara, thank you for the reply. I am studying the example you referred me too. I knew I was not passing the datetime data for an update. Serial time and date are perfect so my internet clock was fine. I will just post my code and try to show my additions. I have tried so many times there may be some useless code in here.
Start your code here
/********* ORIGINAL – ADD NTPCLIENT – TIME ON SERVER NOT UPDATING
Complete project details at https://randomnerdtutorials.com/esp8266-dht11dht22-temperature-and-humidity-web-server-with-arduino-ide/
And like the temperature and humidity, you also need to add a placeholder.
I hope this helps.
Not helping Sara. I put exactly what you said in my notes in the code above. I added all the code like the temperature uses but changing temperature names to a date time name that was a guess because I do not understand where to get it. If I new how to pass the datetime I would be doing it. I am guessing this is just plain simple because only one person has ever ask for help passing the datetime var. All the example code for the NTP Library writes to the serial port. I can do that.
I will put the page back the way I had it and post again, Maybe someone else can point me in the right direction
Can you share your current code? So that I can take a look and test it?
To share a code please use a link to Github Gist, Google Drive, or pastebin.
Hi Sara, I just do not understand passing date and time update to server. 1st two lines below script are givving me date and time then using spam id on webpage. Please help me out, Temperature and humidity are fine, https://pastebin.com/xtCNKqtJ
When page loads Date Time show up, 10 seconds later (update) it is replaced by garbage. I have had it update to 0 and 0.00 trying different things. Manually refresh and time is back
You create the variable datetime, and you pass that variable to the processor function, but you never save anything in that variable.
You need to save date and time in that variable. In the loop(), you’re just printing the time and not actually saving the time. So, add something like the line below to actually save the time:
datetime = timeClient.getEpochTime();
I hope this helps.