Timeline for RFID reading function returning null
Current License: CC BY-SA 4.0
19 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Feb 10, 2024 at 20:45 | history | edited | ocrdu | CC BY-SA 4.0 |
deleted 22 characters in body
|
| Jul 25, 2022 at 16:25 | history | edited | ocrdu | CC BY-SA 4.0 |
added 50 characters in body; edited title
|
| Dec 10, 2020 at 20:20 | vote | accept | Enver Pasha | ||
| Dec 10, 2020 at 20:20 | vote | accept | Enver Pasha | ||
| Dec 10, 2020 at 20:20 | |||||
| S Dec 10, 2020 at 20:19 | history | suggested | ocrdu | CC BY-SA 4.0 |
Changed tags.
|
| Dec 10, 2020 at 20:17 | review | Suggested edits | |||
| S Dec 10, 2020 at 20:19 | |||||
| Dec 10, 2020 at 20:09 | comment | added | ocrdu | So maybe ArduinoJson doesn't play nice with String objects, or there is some other reason I don't know about. I'll write an answer based on my comment; please accept it (if you accept it 8-). | |
| Dec 10, 2020 at 20:00 | answer | added | ocrdu | timeline score: 0 | |
| Dec 10, 2020 at 19:53 | comment | added | Enver Pasha | @ocrdu The second one , doc["rfid"] = str_rfid.c_str(); this worked. | |
| Dec 10, 2020 at 19:53 | comment | added | ocrdu | Which one worked? | |
| Dec 10, 2020 at 19:52 | comment | added | Enver Pasha | @ocrdu Sir tank you so much it worked. | |
| Dec 10, 2020 at 19:45 | comment | added | ocrdu | @Enver-Pasha: It could be your JSON object capacity is too small because of string duplication when you deserialise to print it. You could try a capacity like JSON_OBJECT_SIZE(3) + 500 for deserialising, just for testing. Have a look at arduinojson.org/v5/assistant for more. Also see arduinojson.org/v6/how-to/… . Not sure it is the problem, but worth a try. Also: you could try: doc["rfid"] = str_rfid.c_str(); to see if that works better (CString instead of String object). | |
| Dec 10, 2020 at 19:42 | comment | added | Enver Pasha | @ocrdu the function works and returns string, i output it using serial print. It is correct. But when i assign it to doc["rfid"], the in the json output the field is null. I created a string to test String a = "example" i assign it to the doc["rfid"] , in the json i show this value it works well with other strings. | |
| Dec 10, 2020 at 19:33 | comment | added | ocrdu | @hcheung: The function returns a String, and that return value is used and present, according to the OP. Variable scope has nothing to do with it. | |
| Dec 10, 2020 at 8:37 | comment | added | Enver Pasha | @hcheung sir how can fix this, what should i do to fix this problem. | |
| Dec 9, 2020 at 23:52 | comment | added | hcheung | Your function create a local variable and return it value at end of the function, a local variable will out of Scope upon exiting the function and no longer available. Furthermore, String object uses dynamic memory allocation in the heap, and get free up when it is out of scope. Read a book about C++ programming and try not to use String object if you are new to Arduino/C++ programming. | |
| Dec 9, 2020 at 22:17 | history | edited | Enver Pasha | CC BY-SA 4.0 |
edited title
|
| Dec 9, 2020 at 21:58 | review | First posts | |||
| Dec 10, 2020 at 11:37 | |||||
| Dec 9, 2020 at 21:48 | history | asked | Enver Pasha | CC BY-SA 4.0 |