Go Down

Topic: ESP8266 --Internet Weather Datalogger and Dynamic Web Server (Read 7811 times) previous topic - next topic

Techno500

@ zoomx

How often can 0 seconds be detected by NTP server?  I have been observing Serial output of your "SoftRtcAndNTPusingTimezoneTimeout.ino" and do not see 0 seconds being detected.  If there is no repeatability of 0 seconds; what happens is multiple sets of data gets logged and gets sent to "ThingSpeak.com"  until the next minute occurs.  Solution?

Your code:

Code: [Select]
//Write Data at 15 minute interval  
     if ((minute) % 15 == 0){


This code had to be changed:

Code: [Select]
//Write Data at 15 minute interval  
     if (((minute) % 15 == 0) && ((second) == 0)){



William

zoomx

I don't check for seconds because there is the possibility that at second zero the server is busy. If it is not busy it will send data to thinghspeak at seconds zero. If it is busy, seconds will be not zero but, for example 20. If I check for senconds == 0 and in this second the server is busy, the data will not be sended to thingspeak because when the server will be free the seconds will be not zero.
So when
Code: [Select]
((minute1) % 15 == 0)
data is sended to thingspeak.

Then there is a flag, AcquisitionDone, that became true after sending the data to thingspeak.
The next time, if minute is still ==0, this 
Code: [Select]
((minute1) % 15 == 0)

is true but this

Code: [Select]
(AcquisitionDone == false)

is false because now AcquisitionDone is true.
So no data is sended to thingspeak again.
When

Code: [Select]
((minute1) % 15 == 0)
became false, AcquisitionDone became false too so the next time that

Code: [Select]
((minute1) % 15 == 0)
will be true, AcquisitionDone is false and data is sended to thingspeak.
I wroted this some months ago for an SD datalogger because I have some of them and I want to have all data synchronized.
This send data only every 15 minutes and synchronize RTC with NTP only every 15 minutes too




Techno500

@ zoomx

Thank you.

Testing your "Observations_SPIFFS_20170704.ino" I have been unable to open web pages; /Weather, /SdBrowse, or /Graphs.  Have you experience this in your testing?  Is there a conflicting library?  

"Observations_SPIFFS.ino" uses ESP8266Wifi library for both client and server, without your modifications; /Weather, /SdBrowse, and /Graphs web pages open.  I even tried with just listen function in loop; still your version does not open web pages.  

Do you have a later version for testing?

William

zoomx

You have to add the FAVICON.ICO file into SPIFFS. Without this file you can't reach any other page. You can see this in the serial debug.
Just tested, I can see all pages.


I have to add the last update that you wrote.

Techno500

#34
Jul 19, 2017, 08:46 pm Last Edit: Jul 19, 2017, 09:58 pm by Techno500 Reason: Removed bolding code from code block.
@ zoomx

All is well...  added delay(500); before listen function call in loop; may need tweaking.

Unzipped your "Observations_SPIFFS_20170704.zip" file; made local port, 123. 

All web pages opening as you stated.  Thank you zoomx.


William

Techno500

Testing modded  "Observations_SPIFFS_20170704.zip" with my latest update;  Serial output attached, check out between 7/19/2017 @ 23:00 and 7/19/2017 @ 23:15. packet was received; however, "Seconds since Jan 1 1900 = 0"   Should this condition be tested?  Causes timestamp to be wrong for log file.

William

zoomx

Message received, I have to check what happens if you don't get response from NTP or get an invalid response to avoid to set the RTC to a wrong time.
Looking at code, if no packet is received there is no update time. I have to add another check to the packet length, it must be 48.
In Wikipedia
https://en.wikipedia.org/wiki/User_Datagram_Protocol#Checksum_computation
I read that UDP packet has a checksum so I believe that the packet received should be correct. If packet is not correct it should be discarded and it's like not receiving any packet.
Maybe it can happen that the server is wrong or something happens. Long time ago it happened that GPS went wrong and an automatic GPS data collection didn't start because of this strange error.
If you vave frequent NTP errors it's better that you mantain the DS3231 RTC, as you can see it's only a line different.


Anyway Thingspeak uses it's time server and you can download data from it. In my opinion Thingspeak is great since you can build your own server using a PC or a little RaspberryPI so if they change idea (pachube, cosmic now Xively changed idea!) you can have your server.
Roberto

Techno500

#37
Jul 24, 2017, 03:41 am Last Edit: Jul 26, 2017, 02:49 am by Techno500 Reason: Removed attachment
Thank you zoomx of Arduino.cc Forum for implementing NTP with Timezone for the project!  Tested for two days; time intervals , logging and ThingSpeak are close to working correctly.  Perhaps some small tweaking remains.  Well done zoomx.

Project web page

William

zoomx

Thanks but I made only a small contriubution!
I thought to use NTP because I am lazy and I prefer a clock that regulate itself. Two time a year I have to regulate many clock when there is the switch to the Daylight Saving Time!

Techno500

Two days of testing NTP with Timezones, I am convinced it is not redy for prime time.  Not sure if it is a library or NTP, or a hardware issue.  Server randomly losses track of NTP timing interval.  I am reverting back to using a DS3231 RTC.

Wondering if it could be the ESP8266 going into a sleep mode and not getting NTP packets.

Returned to Real Time Clock version; attached file is current running the Wemos D1 server.

Four-Graphs from Wemos D1 server

William

zoomx

Testing. Data will be here
https://thingspeak.com/channels/306806
Since it is at work I cannot have a public access to the server. I will have it when I will move it to my home.
This is  just a test for RTC and logging.

Techno500

Good morning,

Re-visited zoomx's application of "NTP with Timezones  and have a successful working sketch, "NTP_Observations_SPIFFS.ino"

Included in the attachment are the sketch, "LOG.TXT (portion actually logging during testing) and output of the Serial Monitor (during testing.)

Note:  Time keeping is now accomplished with software using NTP time server.

William

Techno500

#42
Aug 04, 2017, 05:57 am Last Edit: Aug 04, 2017, 06:37 am by Techno500 Reason: Trying to insert image.
Server and sensor running "NTP_Observations_SPIFFS.ino" with No Real Time Clock!

Server has been online since 7/29/2017; all time keeping functions are handled by NTP time server.
Thank you "zoomx" for applying NTP and Timezones to project!

Check out thefour graphs from "ThingSpeak.com;" let mouse hover over data point on graph to reveal value and time of data entry:  Four Graphs

William

zoomx

I read that UDP packet has a checksum so I believe that the packet received should be correct. If packet is not correct it should be discarded and it's like not receiving any packet.
I am wrong and this assumption seems false.

In Serial output --modded file.tx
Code: [Select]

packet received, length=12
Seconds since Jan 1 1900 = 0
Unix time = 2085978496


Data written to log  02/07/2036 , 01:30:00

there was a packet that was long 12 bytes instead of 48.
So packet with lenght different from 48 must be discarded.

I apologize William, you wrote this already.

Techno500

#44
Aug 11, 2017, 10:20 pm Last Edit: Aug 13, 2017, 06:26 am by Techno500 Reason: Made modification to "NTP_Observations_SPIFFS.ino"
@ Zoomx

No need to apologize zoomx.  Thank you for all your time, coding, and community participation.

Logging of Data now has priority after too many missed 15 -minute intervals.

This version has been tested over three days; much improved, over previous versions.  All time keeping is  NTP based; no Real Time Clock!

Project web link --Graphed Observations

William

Go Up