I have purchase the Yun and managed to upload sketches ,like connect to temboo and get the weather etc...
I am however experiencing a problem with updating data to xively.com.
I am using the sketch from the examples folder.
I fill in the project name ,apikey and idfeed.
When I open the serial monitor I see messages saying: sending data................ Data sent.
The example says it sends dummy data to xively.
In this case I have opened a channel called Temperature in xively.com. However the data points never update after I setup an initial value.
Any assistance will be appreciated.
Thank you in advance.
Hi W.
I'm facing the exact issue with curl post to update the Temperature datastream on my Xively account. I tested the same curl example via a PHP script from my Webserver on the same network and can update with success.
I did notice something on my Yun. When I ping the Xively IP address using the ping in the diagnostic section of the network page in the advanced section of the Yun interface, I can't ping it. (Neither any external (wan) site of my network. Not to mention I tried from wifi and Ethernet (both with fixed) IPs.
I then updated my subnetwork from 255.255.255.0 to 255.255.0.0 with effect of being able to ping Xively/ Google.
Still can't update Xively using the xively.connect functions...
Thank you for asking. Here's my code. No error message duing compile or upload (via IP not serial) not reply from Xively after the "PUT". Obviously nothing beiing updated on Xively either.
#include <Bridge.h>
#include <Process.h>
#include "passwords.h" // contains my passwords, see below
// set up net client info:
const unsigned long postingInterval = 60000; //delay between updates to xively.com
unsigned long lastRequest = 0; // when you last made a request
String dataString = "";
void setup() {
// start serial port:
Bridge.begin();
Serial.begin(9600);
while(!Serial); // wait for Network Serial to open
Serial.println("Xively client");
// Do a first update immediately
updateData();
sendData();
lastRequest = millis();
}
void loop() {
// get a timestamp so you can calculate reading and sending intervals:
long now = millis();
// 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_Outdoors,2014-08-22T15:33:20Z,";
dataString += random(10) + 20;
// add pressure:
dataString += "\nAtmospheric_Pressure_Outdoors,2014-08-22T15:33:20Z,";
dataString += 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: ";
apiString += APIKEY;
Serial.print("API Key Strin");
Serial.println(apiString);
// form the string for the URL parameter:
String url = "https://api.xively.com/v2/feeds/";
url += FEEDID;
url += ".csv";
Serial.print("URL Chaine ");
Serial.println(url);
// Send the HTTP PUT request
// Is better to declare the Process here, so when the
// sendData function finishes the resources are immediately
// released. Declaring it global works too, BTW.
Serial.println(dataString);
Serial.println(apiString);
Process xively;
Serial.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();
Serial.println("done!");
// If there's incoming data from the net connection,
// send it out the Serial:
while (xively.available()>0) {
char c = xively.read();
Serial.write(c);
}
}
and the password.h (fake API Key in this example)
#define APIKEY "L3sZFDUVhZ7VttZA2c41PDprYzD93qDi6i8qsw6Ca3eeFAKE"// fake Xively api key here for this forum
#define FEEDID 1415205353 // replace your feed ID
#define USERAGENT "Climate Station" // user agent is the project name
while(!Serial); // wait for Network Serial to open
This will wait forever until you open serial monitor over USB cable and you said you're uploading via IP.
Use Console instead of Serial. Console works over wifi/IP/network
Hi Federico,
Thank you for posting this reply.
I'm actually uploading my script via IP, but my arduino is also connected to the serial via USB. The monitor out put is printing out the checks I'm doing such as the if the Xively chaîne is being formatted correctly.
When I push to Xively I should be receiving a code 200 or an error if my statement is incorrect. But nothing
Setup the Yun to act a wifi client on my home wifi network as per explained in the basic setup guide
Left all the Network settings to default as defined in the OpenWRT flash image
Uploaded my Xively script via IP on the Ethernet port
#include <Bridge.h>
#include <Process.h>
#include "passwords.h"
// set up net client info:
const unsigned long postingInterval = 60000; //delay between updates to xively.com
unsigned long lastRequest = 0; // when you last made a request
String dataString = "";
void setup() {
// start serial port:
Bridge.begin();
Serial.begin(9600);
while(!Serial); // wait for Network Serial to open
Serial.println("Xively client");
// Do a first update immediately
updateData();
sendData();
lastRequest = millis();
}
void loop() {
// get a timestamp so you can calculate reading and sending intervals:
long now = millis();
// 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_Outdoors,";
dataString += random(10) + 20;
// add pressure:
dataString += "\nAtmospheric_Pressure_Outdoors,";
dataString += 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: ";
apiString += APIKEY;
Serial.print("API Key String ");
Serial.println(apiString);
// form the string for the URL parameter:
String url = "https://api.xively.com/v2/feeds/";
url += FEEDID;
url += ".csv";
Serial.print("URL Chaine ");
Serial.println(url);
// Send the HTTP PUT request
Serial.println(dataString);
Serial.println(apiString);
Process xively;
Serial.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();
Serial.println("done!");
// If there's incoming data from the net connection,
// send it out the Serial:
while (xively.available()>0) {
char c = xively.read();
Serial.write(c);
}
}
Connected the Yun to the USB port on my Ubuntu machine (in tools switched back to the USB), the serial.print output on the monitor looks like this
And hallelujah my Xively datastreams are updating. I check this on the Xively page, Request Log section were I'm getting this log
Request
URL /api/v2/feeds/1415205353.csv
Method PUT
At
REQUEST HEADERS
Version HTTP/1.0
Host api.xively.com
X-Request-Start 1409735322524129
User-Agent curl/7.29.0
Accept */*
X-Apikey L3sZFDUVhZ7VttZA2c41PDprYzD93qDi6i8qsw6Ca3eFAKE
Origin
REQUEST BODY
Temperature_Outdoors,26
Atmospheric_Pressure_Outdoors,102
Response
Status Code 200
RESPONSE HEADERS
X-Request-Id 2d96cbb1cc11b1d7dd1c1eef31918f79948b60e8
Cache-Control max-age=0
Content-Type text/plain; charset=utf-8
Content-Length 0
THE ISSUE
Now if I configure my Yun with static IP addresses the push to Xively to update doesn't happen any more;
WAN 192.168.1.3, 255.255.255.0, gateway 192.168.1.1 - DHCP server disabled (As my router is the DHCP server for all the home network)
LAN 192.168.1.2, 255.255.255.0, gateway 192.168.1.1 - DHCP server disabled (As my router is the DHCP server for all the home network)
Any idea how to configure the Yun to allow push when using fixed IP addresses?