Page 1 of 1

ESP32 prints some weird characters on i2c lcd using AsyncWebServer

Posted: Thu Apr 09, 2020 4:20 pm
by gbaranski
Hi, I use github.com/me-no-dev/ESPAsyncWebServer library for WiFi, SSD1306 from Adafruit for lcd, I coded something like this, on request "/setAlarm" ESP prints on LCD string "testing", but that prints me weird characters, code lloks like that, calling the same function from any different class works, only doesnt work if called from asynwebserver library
  1. void ManageWifi::setupServerHandling() {
  2.     server.on("/getTimeData", HTTP_GET, [] (AsyncWebServerRequest *request) {
  3.         request->send(200, "text/plain", R"({"currentTime":")" + wifiTimeManager.getTime() + "\"}");
  4.         Serial.print("received/get");
  5.     });
  6.     server.on("/setAlarm", HTTP_GET, [](AsyncWebServerRequest * request) {
  7.         if(request->hasParam("time")) {
  8.             AsyncWebParameter* p = request->getParam("time");
  9.             Serial.printf("Received %s with value %s from IP: \n", p->name().c_str(), p->value().c_str());
  10.             Serial.println(request->client()->remoteIP());
  11.             request->send(200, "text/plain", "OK");
  12.             wifiTimeManager.saveAlarmTime(String(p->value()));
  13.             String outputMsg = "New request!\n Time: " + String(p->value()) + "\n IP: " + request->client()->remoteIP().toString();
  14.  
  15.             lcdManager.printTextLcd("testing", 1);
  16.         }
  17.     });
  18.     server.onNotFound(notFound);
  19.     server.begin();
  20. }
I tried using xTaskCreate but that gave me same error.
  1. void ManageLcd::printTextLcd(String lcdText, int fontSize){
  2.     clearLcd();
  3.     display.setTextSize(fontSize);
  4.     display.print(lcdText);
  5.     display.display();
  6.     delay(1000);
  7. }
  8.  
  9.  
  10.  
  11. void ManageLcd::clearLcd() {
  12.     display.setTextColor(WHITE);
  13.     display.setCursor(10, 0);
  14.     display.clearDisplay();
  15.  
  16.     display.display();
  17. }
Screenshot 2020-04-09 at 18.19.45.png
Screenshot 2020-04-09 at 18.19.45.png (218.64 KiB) Viewed 6118 times
that shows how it looks like for me

Re: ESP32 prints some weird characters on i2c lcd using AsyncWebServer

Posted: Fri Apr 10, 2020 6:26 am
by ESP_Me-no-dev
You are not sending a response to the request in the alarm handler :) You must request->send(response) in every handler.

Re: ESP32 prints some weird characters on i2c lcd using AsyncWebServer

Posted: Fri Apr 10, 2020 9:39 am
by gbaranski
I do at line 11

Re: ESP32 prints some weird characters on i2c lcd using AsyncWebServer

Posted: Sat Apr 11, 2020 8:20 am
by ESP_Sprite
Moved to the Arduino subforum.