Json buffer size

I am using json api to set the color of individual led
for example:
{“seg”:{“i”:[0,[255,0,0],1,[0,128,0],2,[0,0,255]]}}
So in my case i have 1200 leds and this i array is of length 2400 i am getting error 9 in response
or some time bad request.

So how to configure the json configuration for this to work , i am using esp32 4mb

The command below referenced in the kno.wled.ge works fine under mac but gives error 9 under windows

curl -X POST “http://[WLED-IP]/json/state” -d ‘{“on”:“t”,“v”:true}’ -H “Content-Type: application/json”

I have also seen others talk about error 9 under windows
The correct command under windows is listed below :

or complete one
curl http://wled-ip/json -d {\“on\”:\“t\”,\“v\”:true} -H “Content-Type: application/json”

For your command try this :

curl http://wled-ip/json -d {\“seg\”:{\“i\”:[0,[255,0,0],1,[0,128,0],2,[0,0,255]]}} -H “Content-Type: application/json”

That is a lot of LED data to be transferring in a non-binary format. You should look into using something like DMX.

As @Artacus said, this is too many LEDs for ArduinoJson to handle in memory.
Arrays of about 1000 and up single values are known to cause trouble.

Hello guys ,

Happy to see you are checking this out as it seems a lot of people are interested in individual led control .

Just to clarify your comments does not relate to error 9 but to the led limit that could cause an issue in performance ?

I will create a PR to add your comment for 1000 led limit to the docs below ,which the source of the command example mentioned by the poster , if you have anything to add or rephrase for the same .
https://kno.wled.ge/interfaces/json-api/#per-segment-individual-led-control

Now we got that out of the way , I finally got it to work under windows and was testing with three irregular fixtures ( cubes and rings ) which all under 1000 leds and planning to do heavy scripting on that . Does ledmap help in this case ? Im not really sure if the dmx option only possible with extra hw as there is limited info on the site . Cheers

The limit can be mitigated by custom compiling and increasing JSON buffer size.
It will need thorough testing by the user though.
There may be other issues so I recommend reading ArduinoJson documentation.

Yes finding the way to support that heavy data transfer, right now splitting the requests into multiple requests.

Could you share the code you used ? when i run something like the below in a nested loop "sometimes it fails " but other times it works or lags a bit .The leds are not more then 256 and mcu(s) are only one meter away from router .

curl http://10.0.3.61/json -d {“seg”:{“i”:[%%x,[255,0,0]]}} -H “Content-Type: application/json”

yes 255 is the best i can control even beyond that it crashes

let segObj = {
  seg: {
    i: [],
  },
}; //segment object example
if (segObj?.seg?.i?.length > 200) {
      let newSegObj = JSON.parse(JSON.stringify(segObj));
        let array = segObj?.seg?.i;
        let result = [];
        let valuesCount = 0;
        while (valuesCount < segObj?.seg?.i?.length) {
          result.push(array.slice(valuesCount, valuesCount + 200));
          valuesCount += 200;
        }
        result?.forEach((ele) => {
          newSegObj.seg.i = ele;
          requestJson(newSegObj); //
        });
        return;
 }

this is how i splitting request if and sending data for 100 leds in one request

add some time slack in your requests or not all may get processed.
too fast and they may even cause ESP to reboot

yes will put some time interval between each request. it will work while setting the individual leds, but wont work while saving it as a preset.

Is there any another way to control the individual leds without having a delay ?Or I just use other software to do that

UDP realtime/Hyperion, DDP, E1.31, ArtNet

Yes I have been testing different protocols ,my mac does not like Hyperion but this seems really interesting , i just tested it today for first time , including individual led control GitHub - psieg/Lightpack: Lightpack and Prismatik open repository