ESP 43 inch Display slow

Hi I have a 43 Display. The program work correctly but very slow. Sometimes it take 6 seconds to output a command. I send commands to 3 esp32's via ESP-now.
What did I do wrong. I spent a lot of time trying to speed it up by removing functions but only make it worse. Can you please suggest a fix please.

Tagged:

Comments

  • Hello, here are some optimization suggestions:

    Modification suggestion 1:

    Replace the delay function with the FreeRTOS time function.

    void loop() {
    lv_timer_handler(); // Handle LVGL tasks
    vTaskDelay(5 / portTICK_PERIOD_MS); // Non-blocking delay
    sendDataToAll(); // Send data to all devices
    
    // Process the slider value and update the label
    updateSliders();
    }
    

    Modification suggestion 2:

    Reduce the frequency of reading the DHT22 sensor to avoid reading it in every loop.

    unsigned long lastDHTReadTime = 0;
    const unsigned long dhtInterval = 2000; // Read every 2 seconds
    
    void loop() {
    lv_timer_handler(); // Handle LVGL tasks
    vTaskDelay(5 / portTICK_PERIOD_MS); // Non-blocking delay
    
    // Read DHT22 sensor every 2 seconds
    if (millis() - lastDHTReadTime > dhtInterval) {
    temp = dht.readTemperature();
    humid = dht.readHumidity();
    lastDHTReadTime = millis();
    }
    
    sendDataToAll();
    updateSliders();
    }
    

    Hope these can help you.

  • Hi, I urgently needs help. I uploaded the above attach code and it failed to upload. It give me loads of errors, errors I haven't seen before. I don't know if something changed in one of the libraries as it always loaded up before last Friday. I replaced all libraries but it seems to make it worse. Please help.

  • edited November 20

    I'm using LVGL 8.3.11 and a 5inch touch display SKU-DIS07050H

  • Hello @jdebruyn ,

    @jdebruyn said:
    Hi, I urgently needs help. I uploaded the above attach code and it failed to upload. It give me loads of errors, errors I haven't seen before. I don't know if something changed in one of the libraries as it always loaded up before last Friday. I replaced all libraries but it seems to make it worse. Please help.

    Are you still need help for ESP 4.3 inch Display slow,
    or need help for 5 inch display problem?
    Could you provide more detailed information about the 5-inch display?
    Why would you upload the above code from a 5 inch screen? How is it now?
    If possible,please send me the code and error message and the configuration for the 5-inch compilation error.

  • I was in the proses to do the above fix and could not get the code to upload due to the many errors. I misprinted I am using a 5inch not 4.3inch. The following are the last 3 errors, there are many more: E:\New_Project_V1\Trans_RGB_Stepper_StringAdj_V5\Transmitter_18.8.24_V5\Steel_V4_Trans\Steel_V4_Trans.ino:159:10: error: 'lv_indev_drv_t' does not name a type; did you mean 'lv_indev_data_t'?
    159 | static lv_indev_drv_t indev_drv;
    | ^~~~~~
    | lv_indev_data_t
    E:\New_Project_V1\Trans_RGB_Stepper_StringAdj_V5\Transmitter_18.8.24_V5\Steel_V4_Trans\Steel_V4_Trans.ino:160:22: error: 'indev_drv' was not declared in this scope
    160 | lv_indev_drv_init(&indev_drv);
    | ^~~~~
    E:\New_Project_V1\Trans_RGB_Stepper_StringAdj_V5\Transmitter_18.8.24_V5\Steel_V4_Trans\Steel_V4_Trans.ino:160:3: error: 'lv_indev_drv_init' was not declared in this scope; did you mean 'lv_fs_drv_init'?
    160 | lv_indev_drv_init(&indev_drv);
    | ^~~~~
    | lv_fs_drv_init
    E:\New_Project_V1\Trans_RGB_Stepper_StringAdj_V5\Transmitter_18.8.24_V5\Steel_V4_Trans\Steel_V4_Trans.ino:162:23: error: 'my_touchpad_read' was not declared in this scope
    162 | indev_drv.read_cb = my_touchpad_read;
    | ^~~~
    E:\New_Project_V1\Trans_RGB_Stepper_StringAdj_V5\Transmitter_18.8.24_V5\Steel_V4_Trans\Steel_V4_Trans.ino:163:3: error: 'lv_indev_drv_register' was not declared in this scope; did you mean 'lv_fs_drv_register'?
    163 | lv_indev_drv_register(&indev_drv);
    | ^~~~~
    | lv_fs_drv_register

    exit status 1

    Compilation error: 'LV_IMGBTN_STATE_RELEASED' undeclared (first use in this function); did you mean 'LV_IMAGEBUTTON_STATE_RELEASED'?

  • Code for the above.

  • edited November 22

    Hello @jdebruyn ,

    I understand you're facing issues with slow performance in your ESP32 program that uses ESP-NOW to send commands to three devices. I'll review your code and suggest potential fixes.

    Here are a few observations and suggestions based on your code:

    1. ESP-NOW Send Latency

    • Sending data to multiple addresses sequentially might introduce delays. Consider optimizing this by sending the data to all peers in a loop:
      cpp uint8_t *broadcastAddresses[] = {broadcastAddress, broadcastAddress2, broadcastAddress3}; for (int i = 0; i < 3; i++) { esp_now_send(broadcastAddresses[i], (uint8_t *)&myData1, sizeof(myData1)); }
    • Ensure the esp_now_send function isn't blocking due to retries or waiting for acknowledgment. Check if esp_now_register_send_cb reveals any failures and try reducing data size if needed.

    2. UI Updates in loop()

    • The frequent calls to lv_label_set_text and lv_snprintf for each slider might be slowing things down. Consider updating the UI only when slider values change:
      cpp static int prev_Slider_LL = -1; // Example for Slider_LL int Slider_LL = (int)lv_slider_get_value(ui_Slider_LL); if (Slider_LL != prev_Slider_LL) { lv_snprintf(buf, sizeof(buf), "LL: %d", Slider_LL); lv_label_set_text(ui_A5, buf); prev_Slider_LL = Slider_LL; }
    • This approach can minimize unnecessary updates.

    3. Sensor Reading Delay

    • The delay(100) for the DHT22 sensor at the end of loop() could slow down the entire process. Instead, use a non-blocking approach:
      cpp unsigned long lastDHTRead = 0; if (millis() - lastDHTRead > 2000) { // Read every 2 seconds lastDHTRead = millis(); float temp = dht.readTemperature(); float humid = dht.readHumidity(); // Handle sensor data }
    • This ensures the sensor doesn't affect the responsiveness of other operations.

    4. LVGL Rendering Performance

    • Ensure that the display buffer size is optimal. A larger buffer can reduce the number of updates and improve performance. You could experiment with increasing screenWidth * screenHeight / 8 to higher values if memory permits.
    • Use lv_task_handler() instead of lv_timer_handler() if rendering is taking too long.

    5. Optimize Wi-Fi/ESP-NOW

    • Ensure Wi-Fi tasks aren't consuming excessive CPU by monitoring debug logs. You might try reducing Wi-Fi channel scanning intervals.
    • If ESP-NOW encryption is not required, keep it disabled (as you already have peerInfo.encrypt = false).

    6. Parallelism

    • If the display, sliders, and ESP-NOW tasks are independent, consider running them in separate FreeRTOS tasks to avoid bottlenecks.

    Would you like me to suggest more FreeRTOS-based solutions, or do you need help implementing any of the above?

  • edited November 22

    Thanks for the feedback, however at this moment I cannot upload the code to my ESP32 as there is too many errors. I was able to fix and upload before but as of Last Friday it keeps on failing to upload. Would you mind to please check why. Could it be the display or code, I am out of ideas. Thanks for your time.
    Errors I get: error: 'lv_indev_drv_init' was not declared in this scope; did you mean 'lv_fs_drv_init'?
    161 | indev_drv.type = LV_INDEV_TYPE_POINTER;
    | ^~~~~
    | lv_fs_drv_init
    error: 'my_touchpad_read' was not declared in this scope
    163 | lv_indev_drv_register(&indev_drv);
    | ^~~~~~
    164:3: error: 'lv_indev_drv_register' was not declared in this scope; did you mean 'lv_fs_drv_register'?
    164 |
    | ^
    | lv_fs_drv_register
    exit status 1
    Compilation error: variable or field 'my_disp_flush' declared void

  • @jdebruyn said:
    Code for the above.

    I have checked this error message of yours and the code is normal, it is the same as in our example, it is normal. Did you change the library?

  • edited November 22

    I didn't change the Library, how will I manage the errors as it stop the uploading?

Sign In or Register to comment.