logo elektroda
logo elektroda
X
logo elektroda
Dostępna jest polska wersja

Czy wolisz polską wersję strony elektroda?

Nie, dziękuję Przekieruj mnie tam

NTP time server in ASCII via HTML - I am looking for a simple solution

Duch__ 2727 10
Best answers

How can I get the current time from a server in a simple text format that a microcontroller can read without processing a full HTML page?

Use standard NTP or SNTP directly instead of trying to scrape a full HTML page, because NTP is a standalone protocol and is lighter on RAM/CPU than HTTP; SNTP is even simpler to implement [#15591742][#15591590][#15591682][#15596916] If you really need an ASCII response over web access, create your own minimal server-side script, for example a short PHP file that echoes only the current date/time as plain text, which the microcontroller can then parse [#15591249] JavaScript-based pages are not suitable here because the microcontroller will not run a JavaScript interpreter [#15591249] One example from the thread shows firmware returning a simple NTP time string like `Time: 22:48:25 01/15/2016 GMT+01`, which can then be parsed into a structure [#15596807]
Summary generated by AI based on the discussion content.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 15590908
    Duch__
    Level 31  
    Posts: 2338
    Help: 33
    Rate: 1598
    I'm looking for an NTP time server that displays the current time in text form via html after entering a web address. We exclude watch pages of the type http://www.timeanddate.com/worldclock/poland/warsaw because the microprocessor chip in which it is to work cannot handle such a page.
  • ADVERTISEMENT
  • #2 15590953
    A.Gieronimo
    Level 35  
    Posts: 2321
    Help: 268
    Rate: 309
    The servers are 99% synchronised with NTP anyway.
    So you just need to find one that can be read from html.
    Or make your own.
    Code: Javascript
    Log in, to see the code
  • #3 15591249
    Anonymous
    Anonymous  
  • ADVERTISEMENT
  • #4 15591590
    Samuraj
    Level 35  
    Posts: 2792
    Help: 286
    Rate: 619
    And isn't it easier to implement the classic NTP.
    If you're going to have the answer in a string, you're probably going to trim it and convert it to inty anyway.
  • #5 15591625
    Anonymous
    Anonymous  
  • ADVERTISEMENT
  • #6 15591682
    Samuraj
    Level 35  
    Posts: 2792
    Help: 286
    Rate: 619
    But NTP is not that difficult. Since you have sending/receiving frames it's downhill from there.

    You send a frame
    Code: C / C++
    Log in, to see the code


    The server sends you a frame from which you have to extract
    Code: C / C++
    Log in, to see the code

    The rest is just splitting.
  • ADVERTISEMENT
  • #7 15591742
    JacekCz
    Level 42  
    Posts: 8670
    Help: 760
    Rate: 1463
    NTP as the name suggests :) , is a standalone protocol, and in a formal sense there is no NTP in ASCII. It is a very old protocol, from the days when resources were conserved, and among other things includes the concept of compensating for packet "time of flight" in networks of the time.

    My guess is that use in the "native" version gives a much smaller need than HTTP for RAM/CPU so with puncet times .... (unless the software already has a relationship with HTTP)
  • #8 15596807
    tomson5
    Level 16  
    Posts: 259
    Help: 1
    Rate: 5
    I use the firmware with NTP in my ESP plugged into the AVR
    I retrieve the time using the AT+CIPNTP command
    in response I get Time: 22:48:25 01/15/2016 GMT+01
    All I need to do now is parse this into a struct
  • #9 15596833
    Samuraj
    Level 35  
    Posts: 2792
    Help: 286
    Rate: 619
    Is it possible to know which firmware this is?
    Are there any sources for it?
  • #10 15596916
    michalko12
    MCUs specialist
    Posts: 3394
    Help: 462
    Rate: 321
    There is NTP, there is also SNTP. The latter protocol is simpler to implement and I suspect there are plenty of examples of how to decode data from this protocol.
  • #11 15597323
    tomson5
    Level 16  
    Posts: 259
    Help: 1
    Rate: 5
    I don't remember the source. Probably github.com. Type in google "esp8266 firmware ntp" you will find for sure. I'm happy to help if you have any questions.
ADVERTISEMENT