I have a ethenet shield. I want to update my server page. Server page have to show current time. The code is given in this link. Code works but there is two problem

1- When i press the stop button in the browser, Arduino stops. After this i press refresh button and there is no response.

2- How can i synchronize the arduino time. From where? without setup another server. Is there any time stamp server that compatible with arduino?

2 Answers 2


Question 1.

Your code looks odd:

void checkForClient(){

  EthernetClient client = server.available();

  if (client) {
    boolean sentHeader = false;
    while (client.connected()) {
      if (client.available()) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          sentHeader = true;
  delay(1); // give the web browser time to receive the data


void durumBildir(EthernetClient client, int deger,String ID){
  if (timeStatus()!= timeNotSet) {
    digitalClockDisplay( client);  


You never read from client, so it will always be available (and thus you never leave your loop). I just tested it. Why are you sending the time out indefinitely? Even when you disconnect the poor Arduino is still sending the date and time out forever. No wonder you can't connect again.


I don't have an answer for question 1.

For question 2:

You can add a function to implement an NTP (network time protocol) client. For example, see the UdpNtpClient article on arduino.cc. In your setup() or loop() code call the function initially or perhaps hourly or daily to set system time via an NTP time server. The server's IP address can be hardcoded or otherwise as you like.

For lists of public time servers, see www.ntp.org and pool.ntp.org.

Alternately, you could add a DS1302 or similar clock chip board to your hardware.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.