I'm getting some data from my digital ocean server to arduino Yun. On my serial monitor, data is coming okay, but it has curly braces with it.
So in my server side javascript, I'm sending data with data and time:
io.on('connection', function(socket){
console.log('a user connected');
socket.on("start",function(data){
console.log(data);
var seconds = new Date().getTime() / 1000;
uvData.add({sensor: data, time: seconds});
})
});
and I'm getting those data from arduino every five seconds:
/*
Yún HTTP Client
This example for the Arduino Yún shows how create a basic
HTTP client that connects to the internet and downloads
content. In this case, you'll connect to the Arduino
website and download a version of the logo as ASCII text.
created by Tom igoe
May 2013
*/
#include <Bridge.h>
#include <HttpClient.h>
void setup() {
// Bridge takes about two seconds to start up
// it can be helpful to use the on-board LED
// as an indicator for when it has initialized
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
Bridge.begin();
digitalWrite(13, HIGH);
Serial.begin(9600);
while (!Serial); // wait for a serial connection
}
void loop() {
// Initialize the client library
HttpClient client;
// Make a HTTP request:
client.get("http://104.131.94.5:3000/getdata");
// if there are incoming bytes available
// from the server, read them and print them:
while (client.available()) {
char data = client.read();
Serial.print(data);
}
delay(5000);
}
And from serial monitor in Arduino, it's printing like following:
{"sensor":"0.02","time":1458829507.398,"_id":"ZyiqUiWFJYWDcqe7"}
So if the sensor value is greater than certain value(0.02), I would like to turn on/off led..but how do I point that value in the sketch? since it's printing inside the curly braces, I'm not sure how I can access to it..
Any help would be appreciated..thank you!!