![Dragino PAB2 Скачать руководство пользователя страница 38](http://html1.mh-extra.com/html/dragino/pab2/pab2_user-manual_2527139038.webp)
// if the sending interval has passed since your
// last connection, then connect again and send data:
if (now - lastRequest >= postingInterval) {
updateData();
sendData();
lastRequest = now;
}
}
void updateData() {
// convert the readings to a String to send it:
dataString = "Temperature,";
data= random(10) + 20;
// add pressure:
data= "\nPressure,";
data= random(5) + 100;
}
// this method makes a HTTP connection to the server:
void sendData() {
// form the string for the API header parameter:
String apiString = "X-ApiKey: ";
api= APIKEY;
// form the string for the URL parameter:
String url = "https://api.xively.com/v2/feeds/";
url += FEEDID;
url += ".csv";
// Send the HTTP PUT request, form the linux command and use Process Class to send this command to Yun
Shield
// Is better to declare the Process here, so when the
// sendData function finishes the resources are immediately
// released. Declaring it global works too, BTW.
Process xively;
Console.print("\n\nSending data... ");
xively.begin("curl");
xively.addParameter("-k");
xively.addParameter("--request");
xively.addParameter("PUT");
xively.addParameter("--data");
xively.addParameter(dataString);
xively.addParameter("--header");
xively.addParameter(apiString);
xively.addParameter(url);
xively.run();
Console.println("done!");
// If there's incoming data from the net connection,
// send it out the Console:
while (xively.available() > 0) {
char c = xively.read();
Console.write(c);
}
}
w w w . e k t
2
. c o m
Electronics
Katrangi
Trading
Содержание PAB2
Страница 1: ...Yun Shield User Manual VERSION 1 1 w w w e k t 2 c o m Electronics Katrangi Trading...
Страница 20: ...Screen Shot Xively Dashboard w w w e k t 2 c o m Electronics Katrangi Trading...
Страница 28: ...Yun Shield Quick Start Guide VERSION 1 0 w w w e k t 2 c o m Electronics Katrangi Trading...
Страница 39: ...Screen Shot Xively Dashboard w w w e k t 2 c o m Electronics Katrangi Trading...