-
Notifications
You must be signed in to change notification settings - Fork 7.7k
ESP32 mqtt broker data publishing at uneven rates #6251
-
Hello everyone, we are currently working on project that involves IMU sensors along with ESP32. we are trying to send sensor data to MQTT broker every 100ms(its fast because that's the need of the project)
The Serial Monitor says it is getting successfully sent on broker after 100ms. But on the broker it is getting published at uneven rate(some after 200ms or some after 2ms gap). There is uneven gap between messages which should be 100ms approx. We taught the issue might be on the MQTT broker but if we send the data per second then it is getting perfectly published on time.
But in our case we need faster speed (publish per 100ms).. here the ESP32 shows uncertain behaviour..
Did anyone ever faced such issue ?
We are using ESP32 version : 1.0.6
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 1 reply
-
Hi,
I'm not sure you can 100% rely on the broker at this data rate. I've never tried at this data rate.
Are you using QOS 0?
Beta Was this translation helpful? Give feedback.
All reactions
-
by default PubSub client uses QoS 0 for publishing.. there is no way to modify it.
Also we found out that it is happening because of TCP buffering. Whenever the esp32 runs the publish function it puts the message on the TCP buffer. As the publishing rate is fast (in our case 100ms) TCP buffer accumulates multiple messages together and publishes them at once on the broker, rather than publishing each one of them separately after every 100ms
You can see in the image when we subscribe to the topic on web client, and track it using Wireshark for debugging we can see that each TCP packet is received after 300/400ms and contains 3/4 messages together.
Beta Was this translation helpful? Give feedback.