Hello! Excuse ma - English is not my mother tongue and I am quite new in programming and Arduino world. But I am working in Botanical Garden and it needs very much different temperature controllers, moisture checking and etc...
Right now I am working on project, where Arduino reads from analog inputs readings from 9 soil moisture sensors. Sensors are calibrated, result is mapped and constrained, so the output can be only from 0 to 99.
Right now result will be displayed in lcd. But I want that I can can see data from my webpage. So, Arduino send data array through serial and WiFi module (NodeMCU) receives it and sends values to webpage. That I want. Of course values changing (interval is right now10 sec).
With code I can see array in NodeMCU (which receives it from Arduino):
I can see correctly Jsaon 6 array as it sent from Arduino serial:
{"MULLA_NIISKUS":[41,56,66,65,62,63,65,67,60]}
// MULLA_NIISKUS means "soil dampness"
9 numbers are moisture sensor values flowerpot nr 1, flowerpot nr 2 and etc.
How I can get these values from Json 6 array to different int-s?
int flowerpot_1
int flowerpot_2...
I read three days different tutorials, tried tens of examples, but not success. I can see only full array as a string and this is quite useless as I understand.
Many ways to do this. You could use strchr() to find the opening bracket ('[') and then search for the commas and break up the string. Or you could use strtok(). The first thing I would do is get rid of the String class variable msg and make is a char msg[] array. Once you've done that, study what you find here
econjack:
Many ways to do this. You could use strchr() to find the opening bracket ('[') and then search for the commas and break up the string. Or you could use strtok(). The first thing I would do is get rid of the String class variable msg and make is a char msg[] array. Once you've done that, study what you find here
Page down and see the box titled "Parsing Program" for source code that extracts the first 4 elements of the array. Insert this code in the setup() function and add Serial.begin and Serial.println.
It works, but how add "protection" that processor will not print out quantum of zeros?
Why is the processor printing all those 0s? The other values that are being printed don't match the expected output from gbafamily's code, so you must be running different code against different data.
Anonymous printing sucks, and it strongly discouraged.