Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A ArduinoJson
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 24
    • Issues 24
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Benoît Blanchon
  • ArduinoJson
  • Issues
  • #1879
Closed
Open
Issue created Feb 27, 2023 by philippesikora@philippesikora

ArduinoJson library with ESP32 Web Server using Server-Sent Events (SSE)

Is it the right way to use ArduinoJson library with ESP32 Web Server using Server-Sent Events (SSE) to avoid memory fragmentation or other potential issues Thank you

void sendWES_displayWebBrowser() {

/*

{"solar_watt":10000,"pool_watt":10000,"pac_watt":10000,"IINST1":10,"IINST2":10, "IINST3":10}

Data structures 96 Bytes needed to stores the JSON objects and arrays in memory Strings 0 Bytes needed to stores the strings in memory Total (minimum) 96 Minimum capacity for the JsonDocument. Total (recommended) 96 Including some slack in case the strings change, and rounded to a power of two

*/

DynamicJsonDocument json_wes(96); /* Allocate a temporary JsonDocument */

json_wes["solar_watt"] = solar_watt; json_wes["pool_watt"] = pool_watt; json_wes["pac_watt"] = pac_watt; json_wes["IINST1"] = IINST1; json_wes["IINST2"] = IINST2; json_wes["IINST3"] = IINST3;

char buffer_json_wes[96];

serializeJson(json_wes, buffer_json_wes);

/* https://github.com/me-no-dev/ESPAsyncWebServer#setup-event-source-on-the-server */

events.send(buffer_json_wes,"wes.json" ,millis());

json_wes.clear();
}

Assignee
Assign to
Time tracking