ESP32 prints some weird characters on i2c lcd using AsyncWebServer

gbaranski
Posts: 2
Joined: Thu Apr 09, 2020 1:33 pm

ESP32 prints some weird characters on i2c lcd using AsyncWebServer

Postby gbaranski » Thu Apr 09, 2020 4:20 pm

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 1750 times
that shows how it looks like for me

User avatar
ESP_Me-no-dev
Posts: 69
Joined: Mon Jan 04, 2016 6:30 pm

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

Postby ESP_Me-no-dev » Fri Apr 10, 2020 6:26 am

You are not sending a response to the request in the alarm handler :) You must request->send(response) in every handler.

gbaranski
Posts: 2
Joined: Thu Apr 09, 2020 1:33 pm

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

Postby gbaranski » Fri Apr 10, 2020 9:39 am

I do at line 11

ESP_Sprite
Posts: 3746
Joined: Thu Nov 26, 2015 4:08 am

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

Postby ESP_Sprite » Sat Apr 11, 2020 8:20 am

Moved to the Arduino subforum.

Who is online

Users browsing this forum: No registered users and 27 guests