Arduinojson: Not parsing, tried everything in FAQ

Created on 15 Apr 2018  路  9Comments  路  Source: bblanchon/ArduinoJson

I have tried all the solutions here:

https://arduinojson.org/faq/why-parsing-fails/?utm_source=github&utm_medium=issues

but it still doesn't work for some reason (quite a noob here).
I am using an adapted version of this code:

https://github.com/DotNetDann/ESP8266-MQTT-JSON-SK6812RGBW-HomeAssistant

to work with an NRF24L01+, and an Arduino Uno, but eventually with an ESP8266 (Wemos D1 mini pro)
but this part works (verified by serial monitor and cut completely out of code below)

now I simply have a char[119] called jsone, instead of json, and I even tried using the gps code in the arduinojson sample, but it crashed.

so since I'm a noob and really new to the github scene, here is the documents: Neopixel effects, authentication (not used) and the code in question. PS: the only part that matters is bool processJson.

ESP_RF24_Digital_LEDs.zip

question

Most helpful comment

Hi @lolimpol,

You are using an Arduino Uno, right?
The Uno has only 2KB of RAM, so it's possible that you're running out of memory.
If you want to keep the Uno, you need to reduce memory consumption.

First, you must reduce the global variables.
For example, the three following variables are wasting 663 bytes, that's 32% of the total RAM!

char text[32] = "";
char json[512] = "";
char jsone[119] = "{\"id\":1, \"state\"

Then, I strongly advise against using dynamic memory allocation on the Uno because it causes fragmentation.
In particular, you should not use any String.
Unfortunately, you cannot be sure that the libraries that you include are following this discipline.

Regards,
Benoit

PS: If none of that makes sense, please read "The missing C++ course" in Mastering ArduinoJson.

All 9 comments

Hi @lolimpol

I looked at the attached file. I'm sorry to say that, but it really is a mess.

I saw several suspicious things:

  • the effect string is saved as a pointer
  • the message parameter is ignored
  • the processJson() is repeatedly called with the same input, so only the first call can work

However, none of these problems explains a crash of the device.
Can you try to narrow down the scope of the investigation?

See also:

Regards,
Benoit

Actually, the device doesn't crash, it simply doesn't process. And all the things mentioned above DO work in the actual code, I just commented that out since I know it works.

@MESA0511, please post your own issue! Then you can have full attention of all the troubleshooters.

@lolimpol Did you manage to make some progress?

@bblanchon sadly not yet, I have no clue what could be wrong, I have isolated all the problematic factors out... At least I think.

Can you send a short program that reproduces the issue (50 lines max)?

@bblanchon yes, here it is, but this one runs perfectly!

Arduino code.zip

so there must be something in the lines I deleted between the two that is causing it not to parse, it's not the RF24 library though, as it is included here.

Hi @lolimpol,

You are using an Arduino Uno, right?
The Uno has only 2KB of RAM, so it's possible that you're running out of memory.
If you want to keep the Uno, you need to reduce memory consumption.

First, you must reduce the global variables.
For example, the three following variables are wasting 663 bytes, that's 32% of the total RAM!

char text[32] = "";
char json[512] = "";
char jsone[119] = "{\"id\":1, \"state\"

Then, I strongly advise against using dynamic memory allocation on the Uno because it causes fragmentation.
In particular, you should not use any String.
Unfortunately, you cannot be sure that the libraries that you include are following this discipline.

Regards,
Benoit

PS: If none of that makes sense, please read "The missing C++ course" in Mastering ArduinoJson.

@bblanchon, that's probably it. But if it can't even run on a UNO, then it won't run on a Nano, so I guess I will have to search for a more lightweight solution. But thanks for the help!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

koffienl picture koffienl  路  3Comments

ligantx picture ligantx  路  4Comments

lbussy picture lbussy  路  5Comments

ArnieO picture ArnieO  路  3Comments

loewekordel picture loewekordel  路  4Comments