Skip to content
This repository was archived by the owner on Jun 7, 2025. It is now read-only.
This repository was archived by the owner on Jun 7, 2025. It is now read-only.

ha_mqtt_sensor_dht22.ino ArduinoJson 5 to ArduinoJson 6 upgrade #49

@micgoebe

Description

@micgoebe

compiling ha_mqtt_sensor_dht22.ino lately gives an error saying the code needs to be migrated from ArduinoJson 5 to ArduinoJson 6.

the following link to a website is given, and i could solve the topic by watching just the video at second example given, see https://arduinojson.org/v6/doc/upgrade/
In short:

  • change 'StaticJsonBuffer' to 'StaticJsonDocument' to become > StaticJsonDocument<200> doc;
  • remove line > JsonObject& root = jsonBuffer.createObject();
  • replace the 'root' object with 'doc' subsequently
  • replace root.prettyPrintTo(Serial); with serializeJsonPretty(doc, Serial);
  • replace root.printTo(data, root.measureLength() + 1); with serializeJson(doc, data);
    (this latest line i don't understand why the measureLenght paramter can be omitted, but seems to work)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions