0

I have a testing configuration which consists of a raspberry pi 3 b+ has a mqtt server, an esp32 with some led´s and a webpage to toogle them (webpage and esp32 are clients). For the esp32 i am using the PubSubClient has the library for the communication. Basically what it happens when i toogle a led, i publish "in1" topic which the esp32 is subscribed, reads its payload ("on" or "off") and then it publishs a message to the broswer according the output state for confirmation. Keep in mind that this is all happening in a local network. After some tests, i saw that it takes max. 10 ms for the browser to publish a message. However, the complete cycle takes from 20 to 100 ms since the first publish message till the confirmation message (message esp32 sends reporting output state). Ive found out that it has nothing to do with the code since it takes 1ms from when the subscribed topic gets a new message, till the esp32 publishs the output state of the designed led.

The raspberry pi is running mosquitto v 1.5.5 with websockets enabled. Don´t think it has something to do with the configuration since the same happens when i test it with the mosquitto server i have in my laptop.

All the messages and subscriptions are 0 qos.

I just think it is a ridiculous amount of time for a communication in a local network, not to talk it´s very inconsistent (20 to 100 ms).

Very gratefull for all the help.

1
  • im calling client.loop(); in void loop() without any other task or delay. Jan 14, 2019 at 1:41

2 Answers 2

0

The question was solved. All i had to do was disable esp32 wifi power save mode

1
  • How did you do that?
    – untitled
    Sep 17, 2019 at 19:29
0

just add Esp_wifi_set_ps (WIFI_PS_NONE); right before calling WiFi.begin(WLAN_SSID, WLAN_PASS); to disable modem sleep entirely.

Don't forget to add #include "esp_wifi.h" at the beginning of your sketch.

ESP32 per default uses the esp_wifi_set_ps(WIFI_PS_MIN_MODEM) mode (Modem-sleep minimum power save mode) which leads to slow response time. Good to know: There's also the command esp_wifi_set_ps(WIFI_PS_MAX_MODEM) for battery optimised applications. See: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/wifi.html?highlight=wifi_mode_apsta#esp32-wi-fi-power-saving-mode

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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