Skip to content

MQTT poor performance #6543

Closed
Closed
@FStefanni

Description

@FStefanni

Board

esp32 dev module

Device Description

esp32 devkit c v4

Hardware Configuration

  • I2C sensors
  • I2C display SSD1306

Version

v2.0.2

IDE Name

VS Code + arduino-cli

Operating System

Linux Debian Testing

Flash frequency

default

PSRAM enabled

no

Upload speed

default

Description

Hi,

I try to summarize in the following.

The program

  • ESP32 configuration:
    • ESP32 attached to WiFi
    • ESP32 attached to a MQTT broker
  • ESP32 during its loop:
    • At periodic timeout
      • Show into the display a different information page (i.e. cycle through available pages)
      • Available pages are:
        • Sensors data
        • WiFi information (ssid, rssi, ip, mode)
    • If a mqtt message arrives
      • Publish a message with sensors data

The issue

The reply to the MQTT message can be very slow, till 11 seconds.
Also, the response to a simple network ping is sometimes very slow (more than 1 second).

The workaround

I have found that the calling of the WiFi methods to retrieve the information to display are the origin of the slowdown.
So, if I avoid to call them when I display the page (i.e. I read them only once during the setup() and then I show the "preloaded" values), everything works fine (immediate MQTT reply, ping avg near to 300ms).
The methods are:

  • WiFi.RSSI()
  • WiFi.localIP()
  • WiFi.SSID()
  • WiFi.getMode()
  • Maybe also the "AP alter ego methods" have the same issue (not tested):
    • WiFi.softAPSSID()
    • WiFi.softAPIP()

I have seen that the Arduino ESP32 is not a plain wrapper to ESP-IDF methods, but it also adds some logic, so I do not know whether the issue is in the Arduino layer or the ESP-IDF methods.

FYI, also the Arduino ESP32 version 2.0.0 has the same issue, and the same workaround works as well.

Regards.

Sketch

Not possible to share.

Debug Message

No message available

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions