Adafruit.io and Json Files?

Hi all,

I’ve come to a bit of a stumbling block with a project.

I’m posting some data in json format to Adafruit.io and I’m wanting an Arduino to read this and change some variables from this.

However, while I can do one or two terms perfectly fine, there seems to be a limit as to how much data can be read/stored.

At this moment, I’m just manually inputting data to Adafruit.io and getting the Arduino to read this and print it out over serial.

The code below is what I currently have:

#include <ArduinoJson.h>
#include "config.h"

AdafruitIO_Feed *digital = io.feed("XXXXXX");

//Test Message (Works): {\"day\":Mon,\"sensor1\":12,\"sensor2\":0.5}
//Test Message (Fails): {\"day\":Mon,\"sensor1\":12,\"sensor2\":0.5,\"sensor3\":1023}

void setup() {
 
  Serial.begin(115200);
  while(! Serial);

  // connect to io.adafruit.com
  Serial.print("Connecting to Adafruit IO");
  io.connect();

  digital->onMessage(handleMessage);

  // wait for a connection
  while(io.status() < AIO_CONNECTED) {
    Serial.print(".");
    delay(500);
  }

  // we are connected
  Serial.println();
  Serial.println(io.statusText());
  digital->get();

}

void loop() {

  io.run();
  Serial.println("Nope...");
  delay(1000);


}
void handleMessage(AdafruitIO_Data *data) {

  Serial.print("received <- ");
  Serial.println(data->value());
  delay(1000);
}

(Adafruit connection settings are in another sheet)

a data value of: {“day”:Mon,“sensor1”:12,“sensor2”:0.5} - works

Whereas a value of: {“day”:Mon,“sensor1”:12,“sensor2”:0.5,“sensor3”:1023} - fails (Too many characters or bits of info?!)

I was wondering if there’s a bottleneck somewhere which is causing these issues? I’ve had a look to see if Adafruit.io has any limits on pulling data and I can’t seem to find anything.

If I try a simple csv data entry I can get about 25 bits of data before it reads no more.

I hope someone might have an idea!

Regards.

Try : {\"day\":\"Mon\",\"sensor1\":12,\"sensor2\":0.5,\"sensor3\":1023}

The ArduinoJson assistant provides the following parsing code:

const size_t capacity = JSON_OBJECT_SIZE(4) + 40;
DynamicJsonDocument doc(capacity);

const char* json = "{\"day\":\"Mon\",\"sensor1\":12,\"sensor2\":0.5,\"sensor3\":1023}";

deserializeJson(doc, json);

const char* day = doc["day"]; // "Mon"
int sensor1 = doc["sensor1"]; // 12
float sensor2 = doc["sensor2"]; // 0.5
int sensor3 = doc["sensor3"]; // 1023

ALL of the json parsing happens in the mysterious AdafruitIO_Feed library that you did not provide a link to.

You really should take up issues with crappy Adafruit code/libraries on the Adafruit site.