Hi All,
I’m looking for a simple way (example code) to pass information between an Imp and Arduino.
Overall, the process I’m trying to create is:
Imp: Gets JSON data from web site, stores in a table
Arduino: Requests data from the table (by referencing the key:value)
Imp: Communicates data
Arduino: Displays the data on a LED display
Current example code being run is (thanks to jwehr for this code!!!)
AGENT CODE:
function getTicker() { local reqURL = "https://btc-e.com/api/2/btc_usd/ticker"; server.log(format("Sending request to %s", reqURL)); local req = http.get(reqURL); // send the request synchronously (blocking). Returns an HttpMessage object. local res = req.sendsync(); // check the status code on the response to verify that it's what we actually wanted. server.log(format("Response returned with status %d", res.statuscode)); if (res.statuscode != 200) { server.log("Request for Ticker data failed."); return; } //Decode JSON from the body to a variable local response = http.jsondecode(res.body); //send it to the device. device.send("ticker", response); //refresh the data every 30 seconds. imp.wakeup(30, getTicker); } getTicker();
DEVICE CODE:
agent.on("ticker", function(data) { //Do something with your ticker data server.log(data.ticker.high); });
-I would love to just use the Imp and not worry about the Arduino however there is no library code for running a 8 character LED display from the IMP - specifically the JY-LKM1638 (if you know how I could do this that would be amazing!)