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.
Hi.
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:
ESP32 Neopixel Status Indicator and Sensor PCB Shield with Wi-Fi Manager
But there are many different ways to do that.
Regards,
Sara
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
Rui Santos
Complete project details at https://randomnerdtutorials.com/esp8266-dht11dht22-temperature-and-humidity-web-server-with-arduino-ide/
****
Hi.
If you’re passing the time in the HTML text like the humidity and temperature, you don’t need to get the date and time using JavaScript.
And like the temperature and humidity, you also need to add a placeholder.
I hope this helps.
Regards,
Sara
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
Hi.
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.
Regards,
Sara
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
Hi.
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.
Regards,
Sara