Arduino to aws format error

Hey can anyone help with some errors im getting when publishing to AWS.

So im using an MKR WIFI 1010 and transfering to aws with staticjson<600>. I have included the arduinojson library. The error im getting on the AWS side is message cant be displayed in specified format. I have tried increasing the bytes all the way up to <3200> and it dosnt clear the error. But if i remove some ouputs from the program error clears out and it publishes fine. Im confused on if im using correct library and correct programming any help with this would be greatly appreciated.

side note i have been using this program for about a year now. Problem occurred when increasing outputs in my program to advance my device capabilities. There for increasing outputs signals this error. I have got it to publish 19 outputs but if i add an additional one to make it 20 is where I'm seeing the problem.

mqttClient.beginMessage(subject);
StaticJsonDocument<600> doc;

1 Like

You failed to post your code so we cannot really help you. As you're using MQTT chances are that you're using the PubSubClient library on the Arduino side. This library has a default message buffer size of 256 bytes, so this might be your problem.

Below is a bit of code including the libraries im using.

/////Inlclude Libraries
#include <ArduinoBearSSL.h>
#include <ArduinoECCX08.h>
#include <ArduinoMqttClient.h>
#include <WiFiNINA.h>
#include <ArduinoJson.h>
#include <WiFiUdp.h>
#include <RTCZero.h>

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_ADS1015.h>
#include "Adafruit_MAX31855.h"
#include <ArduinoRS485.h>
#include <ArduinoModbus.h>

const char broker[] = "a2dbeyqm79swuo-ats.iot.us-east-2.amazonaws.com";

WiFiClient wifiClient; // Used for the TCP socket connection
BearSSLClient sslClient(wifiClient); // Used for SSL/TLS connection, integrates with ECC508
MqttClient mqttClient(sslClient);

unsigned long lastMillis = 0;
unsigned long epoch;

Adafruit_ADS1115 ads1; // Construct an ads1115 at the default address: 0x48
Adafruit_ADS1115 ads2(0x49); // construct an ads1115 at address 0x49

#define MAXDO 10 // Define MAX31855 DO Pin
#define MAXCS 6 // Define MAX31855 CS Pin
#define MAXCLK 7 // Define MAX31855 CLK Pin

Adafruit_MAX31855 thermocouple(MAXCLK, MAXCS, MAXDO); // initialize the Thermocouple

int x; //Create x variable
int y; //Create y variable
float z; //create z variable
float kw;
float voltage;
float current;
float pf;
float cfm;
int t;
float val;
float pressure;
float temp;
float hours;
float fault;
float loaded;

void setup() {

pinMode(16,OUTPUT);
pinMode(17,OUTPUT);
pinMode(18,OUTPUT);
digitalWrite(16, HIGH);
pinMode (0,OUTPUT);
digitalWrite (0,HIGH);

Serial.begin(9600, SERIAL_8E1);

// start the Modbus RTU client
if (!ModbusRTUClient.begin(9600, SERIAL_8E1 )) {
Serial.println("Failed to start Modbus RTU Client!");
while (1);

Your library sets the same buffer size:

#define TX_PAYLOAD_BUFFER_SIZE 256

You may change that by using the setTxPayloadSize() method.

1 Like

Confused on this can you be a little more specific as to what i should try?

mqttClient.setTxPayloadSize(500);

If that doesn't work, post complete code and use code tags!

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