Publish multiple readings with MQTT
Posted: Tue May 09, 2017 6:30 am
I have a project were I want to take multiple readings from 1-4 current sensors and publish them to a MQTT broker. Right now I´m not sure about sampling frequency that I need for these sensors and if I could use oversampling to decrease the number of values to publish. These readings will occur up to 20 times per hour when the current is above a threshold value and will last for 2-15 seconds.
But let´s say that I want to read 4 sensors at 100Hz for 15 seconds and then publish them to an MQTT. So it would be up to 6000 values that I need to publish to the broker. It is not important to publish these values exactly in real time as I suspect that could be a problem. But directly after the readings goes below the threshold value they need to be published.
Most of the MQTT-examples that I´ve found only publish couple of readings at a time.
Should I store these readings in int arrays and then publish the whole array or is it possible to publish each separate value in this array?
If it´s best to publish the array as one value do I need to convert these values to a char array or is there a way that are more efficient?
Maybe someone here have experience to deal with this type of problem
The connection to the MQTT server could be quite slow with GPRS up to 4G
But let´s say that I want to read 4 sensors at 100Hz for 15 seconds and then publish them to an MQTT. So it would be up to 6000 values that I need to publish to the broker. It is not important to publish these values exactly in real time as I suspect that could be a problem. But directly after the readings goes below the threshold value they need to be published.
Most of the MQTT-examples that I´ve found only publish couple of readings at a time.
Should I store these readings in int arrays and then publish the whole array or is it possible to publish each separate value in this array?
If it´s best to publish the array as one value do I need to convert these values to a char array or is there a way that are more efficient?
Maybe someone here have experience to deal with this type of problem
The connection to the MQTT server could be quite slow with GPRS up to 4G