Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ha_mqtt_sensor_dht22.ino ArduinoJson 5 to ArduinoJson 6 upgrade #49

Open
micgoebe opened this issue Jan 4, 2023 · 0 comments
Open

ha_mqtt_sensor_dht22.ino ArduinoJson 5 to ArduinoJson 6 upgrade #49

micgoebe opened this issue Jan 4, 2023 · 0 comments

Comments

@micgoebe
Copy link

micgoebe commented Jan 4, 2023

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant