I have simple example, where in loop is called webServer to handle clients and also text drawing on display. The thing is that webServer is not responding, but when I remove second part of loop - drawing text to display then web server starts to work normally.

Server does not respond:

 void loop() {
      unsigned long timeNow = millis();
      if ((timeNow > screenChangeTime))  {
           display.drawString(12, 20,"Loaded: "+String(particles));
           screenChangeTime= timeNow + delay;

Server responds:

void loop() {

bumped to the homepage by Community 19 hours ago

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

  • it is possible that the watchdog triggers because the loop() was taking to long. – Juraj Feb 13 at 4:51
  • 3
    Please edit your question to include a Minimal, Complete, and Verifiable example of code, not just snippets. Minimal means you've stripped away irrelevant stuff, just leaving what's needed to show the problem. Complete means all the library names are shown, all the variable declarations, and all the function definitions – so people don't have to waste time guessing what you did or what you meant. Verifiable means it can be compiled and tested, allowing other people to test their theories about the problem – user31481 Feb 13 at 9:13
  • 2
    Your way of handling the milliseconds is not correct; at the roll of the millis counter you will have problems. Better to use the usual way (if ((millis() - previousTime) >= screenChangeTime) { previousTime += screenChangeTime; ... }) – frarugi87 Feb 13 at 13:06
  • @frarugi87 while that may be an issue in the long run (in about 49 days 17 hours after power-up) it is unlikely to be the issue here. – Phil Sep 27 at 13:22
  • @Phil if the screenChangeTime variable is not unsigned long (even if I doubt that it isn't) it has problems much sooner. In any case, I know it is not the issue here, and in fact it was a comment, not an answer. – frarugi87 Sep 29 at 11:53

My guess is, that you're wasting too much time within the drawing-part.

What is the value for delay? I guess you have a number too low chosen here. And you should really set this new time after you have updated the display by display.display();.

Your webserver doesn't respond because he's not called often enough inside this code.

  • The purpose of the if statement is to not draw every time, it's also not a blocking function. – Tvde1 Jul 16 at 13:29

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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