Become a leader in the IoT community!
New DevHeads get a 320-point leaderboard boost when joining the DevHeads IoT Integration Community. In addition to learning and advising, active community leaders are rewarded with community recognition and free tech stuff. Start your Legendary Collaboration now!
I haven’t done something like this, but maybe you can put a backup storage in the device that can store the data when the WiFi is disconnected. Then after it gains back connection it sends the stored data to the cloud.That will be of a great help.
The type of data here is also to be considered as well
@umeshlokhande
This situation could be handled by adding SDCard or using the built-in Flash memory of ESP32 for local storage to ensure data will not be lost during network issues. And, then implement the *Retry Mechanism* to reconnect ESP32 back to the network
How would you handle data if it is saved in file will you chuck all data to mqtt server at once? After reading the file back
You can do that in the firmware, maybe you can a file for each dataset and then in sequence
thank you
I will break down the file into chunks in binary format and then publish them separately. And then merge all the data again when it finishes sending the last chunk
Then this will be handled on iot server side
Yes, both mqtt server and the client can handle these chunks as long as the payload size doesn’t exceed. I use *Mosquitto Broker* which supports a maximum payload size of *268435455 bytes*
Preventing data loss on ESP32 during MQTT disconnects
We use something like history packets. Packers are stored in a lifo stack and it will be appended with the live packets and sent as history packets . Server separately handles history packets and stores accordingly
@josephogbonna You can use buffering, each time you send message check if it was tranmitted or not if not put in a buffer (Queue,file in sd card for example) once connetion restablished ( wifi / internet connextion mqtt connection) send all the untrasmitted mssages in your queue
CONTRIBUTE TO THIS THREAD