Publishing a single MQTT message with multiple payload

I am trying to send data to AWS using ArduinoJSON/ArduinoMQTT/ArduinoBearSSL and so on.

By the the time everything is compiled there is not a whole lot of ram to use.

I am trying so send 150 data variables but there is not enough ram to do this as a single payload.

How can I send this as multiple payloads?

Thanks

As I understand it, you can only send one payload with each MQTT message. Why not send 2 separate messages each with a payload where the payload contains an identifier indicating that it is one of a pair and which pair it belongs to ?

One topic multiple payloads.

    bmeInfo.concat( String(x_eData.Temperature, 2) );
    bmeInfo.concat( "," );
    bmeInfo.concat( String(x_eData.Pressure, 2) );
    bmeInfo.concat( "," );
    bmeInfo.concat( String(x_eData.Humidity, 2) );
    bmeInfo.concat( "," );
    bmeInfo.concat( String(x_eData.IAQ, 2) );
    xSemaphoreTake( sema_MQTT_KeepAlive, portMAX_DELAY );
    if ( MQTTclient.connected() )
    {
      MQTTclient.publish( topicInsideInfo, bmeInfo.c_str() );
    }

Which Arduino are you using?

One topic, one payload, multiple data items in the payload, but 150 data items cannot work like that

I am using the MKR1500/MKR1010 as a cheaper data stand in.

Yep, already thought of that but just trying to understand if there is another way around it.

PubSubClient has beginPublish which described as "Begins sending a publish message. The payload of the message is provided by one or more calls to write followed by a call to endPublish ." but I am not sure if they try to buffer the whole message before sending it though which is exactly what can't be handled given the lack of RAM.

There is an example (mqtt_large_message.ino) with the PubSubClient library. The full message is not buffered before being sent

Have you looked at that ?

Sending 150 parameters in a single message may not be wrong, but it does sound odd. What are you trying to do?

Just trying to send a subset of CAN message signals (could be 1000's on a given vehicle) to AWS for remote monitoring.

Micromod Teensy can handle the CAN traffic just need something to send the data.

Very difficult to find a small form factor NB modem with the chip shortage. So I am trying to use the MKR1500 MB handle the modem, TLS security(built in crypto) and the MQTT messaging. The Micromod Teensy is handling the JSON encoding as the calculated signals reside in the RAM (has 1MB).

150 signals/s is like 2K bytes/second of data in a JSON format which and NB modem should be able to handle very easily.

Thanks

Yes, that was my next stop.

But I need to know the full message size before the fact which I need to communicate to MKR in advance.

So essentially I need to buffer the message in the host twice.

Need to create the JSON in a buffer so I know the size and then buffer in the UART so I do not block the host after the message is generated but waiting for the MKR to receive the data and send it.

Thanks

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.