Can I read data from json using Arduino and ethernet…
when json data is obtained from mysql database hosting…
my php code looks like this…
//open connection to mysql db
$connection = mysqli_connect("localhost","youngzy_one","****","mo_bus") or die("Error " . mysqli_error($connection));
//fetch table rows from mysql db
$sql = "select * from tabeldata";
$result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));
//create an array
$emparray = array();
$emparray = $row;
//write to json file
$fp = fopen('light.json', 'w');
//close the db connection
so what should i do.. to make arduino can get data from my hosting database?
honestly i'm still new to arduino...
I have modified the lighting by using a web condition with esp8266 at this link .. by using ethernet, and I can do it ..
the light condition is determined by the status on json .. so I thought if I could modify the json status by retrieving data from the database.. so i modify it and i can do it, and the json result can be seen as I have mentioned before,..
so the problem is what should i do to make arduino read this json status, can the arduino read it?
yes i have ethernet shield...
in my case, i need two way data stream..
the first thing is to send data from my arduino and store it to my hosting database..
and i succed to do it..
the second thing is how to make arduino receive data from my database..
this is my actual problem..
i'm stuck at get request, and don't have a good reference..
many reference is just explain how to send data to hosting, not otherwise..
do you have any example of it?
What you need is a JSON library for arduino. There are several: google it.
Once you have this library, you will need to READ THE DOCUMENTATION. It will have a way of parsing data from a connection and creating an object, and that object will have ways of accessing the data inside it.
Note that it will be very important to dispose of these things after you are done with them. If you don't, the memory will fill up and everything will just stop.
But simply: this is a complicated job, you will need to use a library.