From 9a64c1bb1c5f9a7b57a8fd8f9f25791582f7a07f Mon Sep 17 00:00:00 2001 From: Fede85 Date: Tue, 23 Sep 2014 17:14:55 +0200 Subject: [PATCH] removed Xively and Cosm examples --- .../examples/XivelyClient/XivelyClient.ino | 113 ---------- .../examples/CosmClient/CosmClient.ino | 162 --------------- .../CosmClientString/CosmClientString.ino | 147 ------------- .../examples/XivelyClient/XivelyClient.ino | 164 --------------- .../XivelyClientString/XivelyClientString.ino | 155 -------------- .../GSMXivelyClient/GSMXivelyClient.ino | 186 ----------------- .../GSMXivelyClientString.ino | 167 --------------- .../WiFiXivelyClient/WiFiXivelyClient.ino | 194 ------------------ .../WiFiXivelyClientString.ino | 181 ---------------- 9 files changed, 1469 deletions(-) delete mode 100644 libraries/Bridge/examples/XivelyClient/XivelyClient.ino delete mode 100644 libraries/Ethernet/examples/CosmClient/CosmClient.ino delete mode 100644 libraries/Ethernet/examples/CosmClientString/CosmClientString.ino delete mode 100644 libraries/Ethernet/examples/XivelyClient/XivelyClient.ino delete mode 100644 libraries/Ethernet/examples/XivelyClientString/XivelyClientString.ino delete mode 100644 libraries/GSM/examples/GSMXivelyClient/GSMXivelyClient.ino delete mode 100644 libraries/GSM/examples/GSMXivelyClientString/GSMXivelyClientString.ino delete mode 100644 libraries/WiFi/examples/WiFiXivelyClient/WiFiXivelyClient.ino delete mode 100644 libraries/WiFi/examples/WiFiXivelyClientString/WiFiXivelyClientString.ino diff --git a/libraries/Bridge/examples/XivelyClient/XivelyClient.ino b/libraries/Bridge/examples/XivelyClient/XivelyClient.ino deleted file mode 100644 index b2b8dc163..000000000 --- a/libraries/Bridge/examples/XivelyClient/XivelyClient.ino +++ /dev/null @@ -1,113 +0,0 @@ -/* - Xively sensor client with Strings - - This sketch connects an analog sensor to Xively, - using an Arduino Yún. - - created 15 March 2010 - updated 27 May 2013 - by Tom Igoe - - http://arduino.cc/en/Tutorial/YunXivelyClient - - */ - - -// include all Libraries needed: -#include -#include "passwords.h" // contains my passwords, see below - -/* - NOTE: passwords.h is not included with this repo because it contains my passwords. - You need to create it for your own version of this application. To do so, make - a new tab in Arduino, call it passwords.h, and include the following variables and constants: - - #define APIKEY "foo" // replace your pachube api key here - #define FEEDID 0000 // replace your feed ID - #define USERAGENT "my-project" // user agent is the project name - */ - - -// 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,"; - dataString += random(10) + 20; - // add pressure: - dataString += "\nPressure,"; - 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; - - // form the string for the URL parameter: - String url = "https://api.xively.com/v2/feeds/"; - url += FEEDID; - url += ".csv"; - - // 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. - 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); - } - -} - - - - diff --git a/libraries/Ethernet/examples/CosmClient/CosmClient.ino b/libraries/Ethernet/examples/CosmClient/CosmClient.ino deleted file mode 100644 index 11dac86f8..000000000 --- a/libraries/Ethernet/examples/CosmClient/CosmClient.ino +++ /dev/null @@ -1,162 +0,0 @@ -/* - Cosm sensor client - - This sketch connects an analog sensor to Cosm (http://www.cosm.com) - using a Wiznet Ethernet shield. You can use the Arduino Ethernet shield, or - the Adafruit Ethernet shield, either one will work, as long as it's got - a Wiznet Ethernet module on board. - - This example has been updated to use version 2.0 of the cosm.com API. - To make it work, create a feed with a datastream, and give it the ID - sensor1. Or change the code below to match your feed. - - - Circuit: - * Analog sensor attached to analog in 0 - * Ethernet shield attached to pins 10, 11, 12, 13 - - created 15 March 2010 - updated 14 May 2012 - by Tom Igoe with input from Usman Haque and Joe Saavedra - -http://arduino.cc/en/Tutorial/CosmClient - This code is in the public domain. - - */ - -#include -#include - -#define APIKEY "YOUR API KEY GOES HERE" // replace your Cosm api key here -#define FEEDID 00000 // replace your feed ID -#define USERAGENT "My Project" // user agent is the project name - -// assign a MAC address for the ethernet controller. -// Newer Ethernet shields have a MAC address printed on a sticker on the shield -// fill in your address here: -byte mac[] = { - 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED -}; - -// fill in an available IP address on your network here, -// for manual configuration: -IPAddress ip(10, 0, 1, 20); - -// initialize the library instance: -EthernetClient client; - -// if you don't want to use DNS (and reduce your sketch size) -// use the numeric IP instead of the name for the server: -//IPAddress server(216,52,233,121); // numeric IP for api.cosm.com -char server[] = "api.cosm.com"; // name address for cosm API - -unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds -boolean lastConnected = false; // state of the connection last time through the main loop -const unsigned long postingInterval = 10L * 1000L; // delay between updates to cosm.com -// the "L" is needed to use long type numbers - - -void setup() { - // start serial port: - Serial.begin(9600); - // start the Ethernet connection: - if (Ethernet.begin(mac) == 0) { - Serial.println("Failed to configure Ethernet using DHCP"); - // DHCP failed, so use a fixed IP address: - Ethernet.begin(mac, ip); - } -} - -void loop() { - // read the analog sensor: - int sensorReading = analogRead(A0); - - // if there's incoming data from the net connection. - // send it out the serial port. This is for debugging - // purposes only: - if (client.available()) { - char c = client.read(); - Serial.print(c); - } - - // if there's no net connection, but there was one last time - // through the loop, then stop the client: - if (!client.connected() && lastConnected) { - Serial.println(); - Serial.println("disconnecting."); - client.stop(); - } - - // if you're not connected, and ten seconds have passed since - // your last connection, then connect again and send data: - if (!client.connected() && (millis() - lastConnectionTime > postingInterval)) { - sendData(sensorReading); - } - // store the state of the connection for next time through - // the loop: - lastConnected = client.connected(); -} - -// this method makes a HTTP connection to the server: -void sendData(int thisData) { - // if there's a successful connection: - if (client.connect(server, 80)) { - Serial.println("connecting..."); - // send the HTTP PUT request: - client.print("PUT /v2/feeds/"); - client.print(FEEDID); - client.println(".csv HTTP/1.1"); - client.println("Host: api.cosm.com"); - client.print("X-ApiKey: "); - client.println(APIKEY); - client.print("User-Agent: "); - client.println(USERAGENT); - client.print("Content-Length: "); - - // calculate the length of the sensor reading in bytes: - // 8 bytes for "sensor1," + number of digits of the data: - int thisLength = 8 + getLength(thisData); - client.println(thisLength); - - // last pieces of the HTTP PUT request: - client.println("Content-Type: text/csv"); - client.println("Connection: close"); - client.println(); - - // here's the actual content of the PUT request: - client.print("sensor1,"); - client.println(thisData); - - } - else { - // if you couldn't make a connection: - Serial.println("connection failed"); - Serial.println(); - Serial.println("disconnecting."); - client.stop(); - } - // note the time that the connection was made or attempted: - lastConnectionTime = millis(); -} - - -// This method calculates the number of digits in the -// sensor reading. Since each digit of the ASCII decimal -// representation is a byte, the number of digits equals -// the number of bytes: - -int getLength(int someValue) { - // there's at least one byte: - int digits = 1; - // continually divide the value by ten, - // adding one to the digit count for each - // time you divide, until you're at 0: - int dividend = someValue / 10; - while (dividend > 0) { - dividend = dividend / 10; - digits++; - } - // return the number of digits: - return digits; -} - diff --git a/libraries/Ethernet/examples/CosmClientString/CosmClientString.ino b/libraries/Ethernet/examples/CosmClientString/CosmClientString.ino deleted file mode 100644 index 22a6b3ff4..000000000 --- a/libraries/Ethernet/examples/CosmClientString/CosmClientString.ino +++ /dev/null @@ -1,147 +0,0 @@ -/* - Cosm sensor client with Strings - - This sketch connects an analog sensor to Cosm (http://www.cosm.com) - using a Wiznet Ethernet shield. You can use the Arduino Ethernet shield, or - the Adafruit Ethernet shield, either one will work, as long as it's got - a Wiznet Ethernet module on board. - - This example has been updated to use version 2.0 of the Cosm.com API. - To make it work, create a feed with two datastreams, and give them the IDs - sensor1 and sensor2. Or change the code below to match your feed. - - This example uses the String library, which is part of the Arduino core from - version 0019. - - Circuit: - * Analog sensor attached to analog in 0 - * Ethernet shield attached to pins 10, 11, 12, 13 - - created 15 March 2010 - updated 14 May 2012 - by Tom Igoe with input from Usman Haque and Joe Saavedra - - http://arduino.cc/en/Tutorial/CosmClientString - This code is in the public domain. - - */ - -#include -#include - - -#define APIKEY "YOUR API KEY GOES HERE" // replace your Cosm api key here -#define FEEDID 00000 // replace your feed ID -#define USERAGENT "My Project" // user agent is the project name - -// assign a MAC address for the ethernet controller. -// fill in your address here: -byte mac[] = { - 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED -}; - -// fill in an available IP address on your network here, -// for manual configuration: -IPAddress ip(10, 0, 1, 20); - -// initialize the library instance: -EthernetClient client; - -// if you don't want to use DNS (and reduce your sketch size) -// use the numeric IP instead of the name for the server: -//IPAddress server(216,52,233,121); // numeric IP for api.cosm.com -char server[] = "api.cosm.com"; // name address for Cosm API - -unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds -boolean lastConnected = false; // state of the connection last time through the main loop -const unsigned long postingInterval = 10L * 1000L; // delay between updates to Cosm.com -// the "L" is needed to use long type numbers -void setup() { - // start serial port: - Serial.begin(9600); - // give the ethernet module time to boot up: - delay(1000); - // start the Ethernet connection: - if (Ethernet.begin(mac) == 0) { - Serial.println("Failed to configure Ethernet using DHCP"); - // DHCP failed, so use a fixed IP address: - Ethernet.begin(mac, ip); - } -} - -void loop() { - // read the analog sensor: - int sensorReading = analogRead(A0); - // convert the data to a String to send it: - - String dataString = "sensor1,"; - dataString += sensorReading; - - // you can append multiple readings to this String if your - // Cosm feed is set up to handle multiple values: - int otherSensorReading = analogRead(A1); - dataString += "\nsensor2,"; - dataString += otherSensorReading; - - // if there's incoming data from the net connection. - // send it out the serial port. This is for debugging - // purposes only: - if (client.available()) { - char c = client.read(); - Serial.print(c); - } - - // if there's no net connection, but there was one last time - // through the loop, then stop the client: - if (!client.connected() && lastConnected) { - Serial.println(); - Serial.println("disconnecting."); - client.stop(); - } - - // if you're not connected, and ten seconds have passed since - // your last connection, then connect again and send data: - if (!client.connected() && (millis() - lastConnectionTime > postingInterval)) { - sendData(dataString); - } - // store the state of the connection for next time through - // the loop: - lastConnected = client.connected(); -} - -// this method makes a HTTP connection to the server: -void sendData(String thisData) { - // if there's a successful connection: - if (client.connect(server, 80)) { - Serial.println("connecting..."); - // send the HTTP PUT request: - client.print("PUT /v2/feeds/"); - client.print(FEEDID); - client.println(".csv HTTP/1.1"); - client.println("Host: api.cosm.com"); - client.print("X-ApiKey: "); - client.println(APIKEY); - client.print("User-Agent: "); - client.println(USERAGENT); - client.print("Content-Length: "); - client.println(thisData.length()); - - // last pieces of the HTTP PUT request: - client.println("Content-Type: text/csv"); - client.println("Connection: close"); - client.println(); - - // here's the actual content of the PUT request: - client.println(thisData); - } - else { - // if you couldn't make a connection: - Serial.println("connection failed"); - Serial.println(); - Serial.println("disconnecting."); - client.stop(); - } - // note the time that the connection was made or attempted: - lastConnectionTime = millis(); -} - diff --git a/libraries/Ethernet/examples/XivelyClient/XivelyClient.ino b/libraries/Ethernet/examples/XivelyClient/XivelyClient.ino deleted file mode 100644 index ea6298c4f..000000000 --- a/libraries/Ethernet/examples/XivelyClient/XivelyClient.ino +++ /dev/null @@ -1,164 +0,0 @@ -/* - Xively sensor client - - This sketch connects an analog sensor to Xively (http://www.xively.com) - using a Wiznet Ethernet shield. You can use the Arduino Ethernet shield, or - the Adafruit Ethernet shield, either one will work, as long as it's got - a Wiznet Ethernet module on board. - - This example has been updated to use version 2.0 of the Xively.com API. - To make it work, create a feed with a datastream, and give it the ID - sensor1. Or change the code below to match your feed. - - - Circuit: - * Analog sensor attached to analog in 0 - * Ethernet shield attached to pins 10, 11, 12, 13 - - created 15 March 2010 - modified 9 Apr 2012 - by Tom Igoe with input from Usman Haque and Joe Saavedra - -http://arduino.cc/en/Tutorial/XivelyClient - This code is in the public domain. - - */ - -#include -#include - -#define APIKEY "YOUR API KEY GOES HERE" // replace your xively api key here -#define FEEDID 00000 // replace your feed ID -#define USERAGENT "My Project" // user agent is the project name - -// assign a MAC address for the ethernet controller. -// Newer Ethernet shields have a MAC address printed on a sticker on the shield -// fill in your address here: -byte mac[] = { - 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED -}; - -// fill in an available IP address on your network here, -// for manual configuration: -IPAddress ip(10, 0, 1, 20); -// initialize the library instance: -EthernetClient client; - -// if you don't want to use DNS (and reduce your sketch size) -// use the numeric IP instead of the name for the server: -IPAddress server(216,52,233,122); // numeric IP for api.xively.com -//char server[] = "api.xively.com"; // name address for xively API - -unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds -boolean lastConnected = false; // state of the connection last time through the main loop -const unsigned long postingInterval = 10*1000; //delay between updates to Xively.com - -void setup() { - // Open serial communications and wait for port to open: - Serial.begin(9600); - while (!Serial) { - ; // wait for serial port to connect. Needed for Leonardo only - } - - - // start the Ethernet connection: - if (Ethernet.begin(mac) == 0) { - Serial.println("Failed to configure Ethernet using DHCP"); - // DHCP failed, so use a fixed IP address: - Ethernet.begin(mac, ip); - } -} - -void loop() { - // read the analog sensor: - int sensorReading = analogRead(A0); - - // if there's incoming data from the net connection. - // send it out the serial port. This is for debugging - // purposes only: - if (client.available()) { - char c = client.read(); - Serial.print(c); - } - - // if there's no net connection, but there was one last time - // through the loop, then stop the client: - if (!client.connected() && lastConnected) { - Serial.println(); - Serial.println("disconnecting."); - client.stop(); - } - - // if you're not connected, and ten seconds have passed since - // your last connection, then connect again and send data: - if (!client.connected() && (millis() - lastConnectionTime > postingInterval)) { - sendData(sensorReading); - } - // store the state of the connection for next time through - // the loop: - lastConnected = client.connected(); -} - -// this method makes a HTTP connection to the server: -void sendData(int thisData) { - // if there's a successful connection: - if (client.connect(server, 80)) { - Serial.println("connecting..."); - // send the HTTP PUT request: - client.print("PUT /v2/feeds/"); - client.print(FEEDID); - client.println(".csv HTTP/1.1"); - client.println("Host: api.xively.com"); - client.print("X-XivelyApiKey: "); - client.println(APIKEY); - client.print("User-Agent: "); - client.println(USERAGENT); - client.print("Content-Length: "); - - // calculate the length of the sensor reading in bytes: - // 8 bytes for "sensor1," + number of digits of the data: - int thisLength = 8 + getLength(thisData); - client.println(thisLength); - - // last pieces of the HTTP PUT request: - client.println("Content-Type: text/csv"); - client.println("Connection: close"); - client.println(); - - // here's the actual content of the PUT request: - client.print("sensor1,"); - client.println(thisData); - - } - else { - // if you couldn't make a connection: - Serial.println("connection failed"); - Serial.println(); - Serial.println("disconnecting."); - client.stop(); - } - // note the time that the connection was made or attempted: - lastConnectionTime = millis(); -} - - -// This method calculates the number of digits in the -// sensor reading. Since each digit of the ASCII decimal -// representation is a byte, the number of digits equals -// the number of bytes: - -int getLength(int someValue) { - // there's at least one byte: - int digits = 1; - // continually divide the value by ten, - // adding one to the digit count for each - // time you divide, until you're at 0: - int dividend = someValue / 10; - while (dividend > 0) { - dividend = dividend / 10; - digits++; - } - // return the number of digits: - return digits; -} - diff --git a/libraries/Ethernet/examples/XivelyClientString/XivelyClientString.ino b/libraries/Ethernet/examples/XivelyClientString/XivelyClientString.ino deleted file mode 100644 index 4cfeb45ba..000000000 --- a/libraries/Ethernet/examples/XivelyClientString/XivelyClientString.ino +++ /dev/null @@ -1,155 +0,0 @@ -/* - Xively sensor client with Strings - - This sketch connects an analog sensor to Xively (http://www.xively.com) - using a Wiznet Ethernet shield. You can use the Arduino Ethernet shield, or - the Adafruit Ethernet shield, either one will work, as long as it's got - a Wiznet Ethernet module on board. - - This example has been updated to use version 2.0 of the xively.com API. - To make it work, create a feed with two datastreams, and give them the IDs - sensor1 and sensor2. Or change the code below to match your feed. - - This example uses the String library, which is part of the Arduino core from - version 0019. - - Circuit: - * Analog sensor attached to analog in 0 - * Ethernet shield attached to pins 10, 11, 12, 13 - - created 15 March 2010 - modified 9 Apr 2012 - by Tom Igoe with input from Usman Haque and Joe Saavedra - modified 8 September 2012 - by Scott Fitzgerald - - http://arduino.cc/en/Tutorial/XivelyClientString - This code is in the public domain. - - */ - -#include -#include - - -#define APIKEY "YOUR API KEY GOES HERE" // replace your Xively api key here -#define FEEDID 00000 // replace your feed ID -#define USERAGENT "My Project" // user agent is the project name - - -// assign a MAC address for the ethernet controller. -// fill in your address here: -byte mac[] = { - 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED -}; - -// fill in an available IP address on your network here, -// for manual configuration: -IPAddress ip(10, 0, 1, 20); - -// initialize the library instance: -EthernetClient client; - -// if you don't want to use DNS (and reduce your sketch size) -// use the numeric IP instead of the name for the server: -IPAddress server(216,52,233,121); // numeric IP for api.xively.com -//char server[] = "api.xively.com"; // name address for xively API - -unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds -boolean lastConnected = false; // state of the connection last time through the main loop -const unsigned long postingInterval = 10*1000; //delay between updates to xively.com - -void setup() { - // Open serial communications and wait for port to open: - Serial.begin(9600); - while (!Serial) { - ; // wait for serial port to connect. Needed for Leonardo only - } - - - // give the ethernet module time to boot up: - delay(1000); - // start the Ethernet connection: - if (Ethernet.begin(mac) == 0) { - Serial.println("Failed to configure Ethernet using DHCP"); - // DHCP failed, so use a fixed IP address: - Ethernet.begin(mac, ip); - } -} - -void loop() { - // read the analog sensor: - int sensorReading = analogRead(A0); - // convert the data to a String to send it: - - String dataString = "sensor1,"; - dataString += sensorReading; - - // you can append multiple readings to this String if your - // xively feed is set up to handle multiple values: - int otherSensorReading = analogRead(A1); - dataString += "\nsensor2,"; - dataString += otherSensorReading; - - // if there's incoming data from the net connection. - // send it out the serial port. This is for debugging - // purposes only: - if (client.available()) { - char c = client.read(); - Serial.print(c); - } - - // if there's no net connection, but there was one last time - // through the loop, then stop the client: - if (!client.connected() && lastConnected) { - Serial.println(); - Serial.println("disconnecting."); - client.stop(); - } - - // if you're not connected, and ten seconds have passed since - // your last connection, then connect again and send data: - if (!client.connected() && (millis() - lastConnectionTime > postingInterval)) { - sendData(dataString); - } - // store the state of the connection for next time through - // the loop: - lastConnected = client.connected(); -} - -// this method makes a HTTP connection to the server: -void sendData(String thisData) { - // if there's a successful connection: - if (client.connect(server, 80)) { - Serial.println("connecting..."); - // send the HTTP PUT request: - client.print("PUT /v2/feeds/"); - client.print(FEEDID); - client.println(".csv HTTP/1.1"); - client.println("Host: api.xively.com"); - client.print("X-xivelyApiKey: "); - client.println(APIKEY); - client.print("User-Agent: "); - client.println(USERAGENT); - client.print("Content-Length: "); - client.println(thisData.length()); - - // last pieces of the HTTP PUT request: - client.println("Content-Type: text/csv"); - client.println("Connection: close"); - client.println(); - - // here's the actual content of the PUT request: - client.println(thisData); - } - else { - // if you couldn't make a connection: - Serial.println("connection failed"); - Serial.println(); - Serial.println("disconnecting."); - client.stop(); - } - // note the time that the connection was made or attempted: - lastConnectionTime = millis(); -} - diff --git a/libraries/GSM/examples/GSMXivelyClient/GSMXivelyClient.ino b/libraries/GSM/examples/GSMXivelyClient/GSMXivelyClient.ino deleted file mode 100644 index a0fffcd3b..000000000 --- a/libraries/GSM/examples/GSMXivelyClient/GSMXivelyClient.ino +++ /dev/null @@ -1,186 +0,0 @@ -/* - GSM Xively client - - This sketch connects an analog sensor to Xively (http://www.xively.com) - using a Telefonica GSM/GPRS shield. - - This example has been updated to use version 2.0 of the Xively.com API. - To make it work, create a feed with a datastream, and give it the ID - sensor1. Or change the code below to match your feed. - - Circuit: - * Analog sensor attached to analog in 0 - * GSM shield attached to an Arduino - * SIM card with a data plan - - created 4 March 2012 - by Tom Igoe - and adapted for GSM shield by David Del Peral - - This code is in the public domain. - - http://arduino.cc/en/Tutorial/GSMExamplesXivelyClient - - */ - -// libraries -#include - -// Xively Client data -#define APIKEY "YOUR API KEY GOES HERE" // replace your xively api key here -#define FEEDID 00000 // replace your feed ID -#define USERAGENT "My Project" // user agent is the project name - -// PIN Number -#define PINNUMBER "" - -// APN data -#define GPRS_APN "GPRS_APN" // replace your GPRS APN -#define GPRS_LOGIN "login" // replace with your GPRS login -#define GPRS_PASSWORD "password" // replace with your GPRS password - -// initialize the library instance: -GSMClient client; -GPRS gprs; -GSM gsmAccess; - -// if you don't want to use DNS (and reduce your sketch size) -// use the numeric IP instead of the name for the server: -// IPAddress server(216,52,233,121); // numeric IP for api.xively.com -char server[] = "api.xively.com"; // name address for xively API - -unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds -boolean lastConnected = false; // state of the connection last time through the main loop -const unsigned long postingInterval = 10*1000; //delay between updates to Xively.com - -void setup() -{ - // initialize serial communications and wait for port to open: - Serial.begin(9600); - while (!Serial) { - ; // wait for serial port to connect. Needed for Leonardo only - } - - // connection state - boolean notConnected = true; - - // After starting the modem with GSM.begin() - // attach the shield to the GPRS network with the APN, login and password - while (notConnected) - { - if ((gsmAccess.begin(PINNUMBER) == GSM_READY) & - (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD) == GPRS_READY)) - notConnected = false; - else - { - Serial.println("Not connected"); - delay(1000); - } - } -} - -void loop() -{ - // read the analog sensor: - int sensorReading = analogRead(A0); - - // if there's incoming data from the net connection. - // send it out the serial port. This is for debugging - // purposes only: - if (client.available()) - { - char c = client.read(); - Serial.print(c); - } - - // if there's no net connection, but there was one last time - // through the loop, then stop the client: - if (!client.connected() && lastConnected) - { - client.stop(); - } - - // if you're not connected, and ten seconds have passed since - // your last connection, then connect again and send data: - if (!client.connected() && ((millis() - lastConnectionTime) > postingInterval)) - { - sendData(sensorReading); - } - - // store the state of the connection for next time through - // the loop: - lastConnected = client.connected(); -} - -/* - This method makes a HTTP connection to the server. -*/ -void sendData(int thisData) -{ - // if there's a successful connection: - if (client.connect(server, 80)) - { - Serial.println("connecting..."); - - // send the HTTP PUT request: - client.print("PUT /v2/feeds/"); - client.print(FEEDID); - client.println(".csv HTTP/1.1"); - client.println("Host: api.xively.com"); - client.print("X-ApiKey: "); - client.println(APIKEY); - client.print("User-Agent: "); - client.println(USERAGENT); - client.print("Content-Length: "); - - // calculate the length of the sensor reading in bytes: - // 8 bytes for "sensor1," + number of digits of the data: - int thisLength = 8 + getLength(thisData); - client.println(thisLength); - - // last pieces of the HTTP PUT request: - client.println("Content-Type: text/csv"); - client.println("Connection: close"); - client.println(); - - // here's the actual content of the PUT request: - client.print("sensor1,"); - client.println(thisData); - } - else - { - // if you couldn't make a connection: - Serial.println("connection failed"); - Serial.println(); - Serial.println("disconnecting."); - client.stop(); - } - // note the time that the connection was made or attempted - lastConnectionTime = millis(); -} - -/* - This method calculates the number of digits in the - sensor reading. Since each digit of the ASCII decimal - representation is a byte, the number of digits equals - the number of bytes. -*/ -int getLength(int someValue) -{ - // there's at least one byte: - int digits = 1; - - // continually divide the value by ten, - // adding one to the digit count for each - // time you divide, until you're at 0: - int dividend = someValue / 10; - while (dividend > 0) - { - dividend = dividend / 10; - digits++; - } - - // return the number of digits: - return digits; -} - diff --git a/libraries/GSM/examples/GSMXivelyClientString/GSMXivelyClientString.ino b/libraries/GSM/examples/GSMXivelyClientString/GSMXivelyClientString.ino deleted file mode 100644 index 077961dce..000000000 --- a/libraries/GSM/examples/GSMXivelyClientString/GSMXivelyClientString.ino +++ /dev/null @@ -1,167 +0,0 @@ -/* - Xively client with Strings - - This sketch connects two analog sensors to Xively (http://www.xively.com) - through a Telefonica GSM/GPRS shield. - - This example has been updated to use version 2.0 of the Xively.com API. - To make it work, create a feed with two datastreams, and give them the IDs - sensor1 and sensor2. Or change the code below to match your feed. - - This example uses the String library, which is part of the Arduino core from - version 0019. - - Circuit: - * Analog sensors attached to A0 and A1 - * GSM shield attached to an Arduino - * SIM card with a data plan - - created 8 March 2012 - by Tom Igoe - and adapted for GSM shield by David Del Peral - - This code is in the public domain. - - */ - -// Include the GSM library -#include - -// Xively login information -#define APIKEY "YOUR API KEY GOES HERE" // replace your xively api key here -#define FEEDID 00000 // replace your feed ID -#define USERAGENT "My Project" // user agent is the project name - -// PIN Number -#define PINNUMBER "" - -// APN data -#define GPRS_APN "GPRS_APN" // replace your GPRS APN -#define GPRS_LOGIN "login" // replace with your GPRS login -#define GPRS_PASSWORD "password" // replace with your GPRS password - -// initialize the library instance -GSMClient client; -GPRS gprs; -GSM gsmAccess; - -// if you don't want to use DNS (and reduce your sketch size) -// use the numeric IP instead of the name for the server: -// IPAddress server(216,52,233,121); // numeric IP for api.xively.com -char server[] = "api.xively.com"; // name address for Xively API - -unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds -boolean lastConnected = false; // state of the connection last time through the main loop -const unsigned long postingInterval = 10*1000; // delay between updates to Xively.com - -void setup() -{ - // initialize serial communications and wait for port to open: - Serial.begin(9600); - while (!Serial) { - ; // wait for serial port to connect. Needed for Leonardo only - } - - // connection state - boolean notConnected = true; - - // After starting the modem with GSM.begin() - // attach the shield to the GPRS network with the APN, login and password - while (notConnected) - { - if ((gsmAccess.begin(PINNUMBER) == GSM_READY) & - (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD) == GPRS_READY)) - notConnected = false; - else - { - Serial.println("Not connected"); - delay(1000); - } - } - - Serial.println("Connected to GPRS network"); -} - -void loop() -{ - // read the sensor on A0 - int sensorReading = analogRead(A0); - - // convert the data to a String - String dataString = "sensor1,"; - dataString += sensorReading; - - // you can append multiple readings to this String to - // send the xively feed multiple values - int otherSensorReading = analogRead(A1); - dataString += "\nsensor2,"; - dataString += otherSensorReading; - - // if there's incoming data from the net connection. - // send it out the serial port. This is for debugging - // purposes only - if (client.available()) - { - char c = client.read(); - Serial.print(c); - } - - // if there's no net connection, but there was one last time - // through the loop, then stop the client - if (!client.connected() && lastConnected) - { - Serial.println(); - Serial.println("disconnecting."); - client.stop(); - } - - // if you're not connected, and ten seconds have passed since - // your last connection, then connect again and send data - if (!client.connected() && (millis() - lastConnectionTime > postingInterval)) - { - sendData(dataString); - } - // store the state of the connection for next time through - // the loop - lastConnected = client.connected(); -} - -// this method makes a HTTP connection to the server -void sendData(String thisData) -{ - // if there's a successful connection: - if (client.connect(server, 80)) - { - Serial.println("connecting..."); - - // send the HTTP PUT request: - client.print("PUT /v2/feeds/"); - client.print(FEEDID); - client.println(".csv HTTP/1.1"); - client.println("Host: api.xively.com"); - client.print("X-ApiKey: "); - client.println(APIKEY); - client.print("User-Agent: "); - client.println(USERAGENT); - client.print("Content-Length: "); - client.println(thisData.length()); - - // last pieces of the HTTP PUT request - client.println("Content-Type: text/csv"); - client.println("Connection: close"); - client.println(); - - // here's the actual content of the PUT request - client.println(thisData); - } - else - { - // if you couldn't make a connection - Serial.println("connection failed"); - Serial.println(); - Serial.println("disconnecting."); - client.stop(); - } - // note the time that the connection was made or attempted: - lastConnectionTime = millis(); -} diff --git a/libraries/WiFi/examples/WiFiXivelyClient/WiFiXivelyClient.ino b/libraries/WiFi/examples/WiFiXivelyClient/WiFiXivelyClient.ino deleted file mode 100644 index b88dd2c58..000000000 --- a/libraries/WiFi/examples/WiFiXivelyClient/WiFiXivelyClient.ino +++ /dev/null @@ -1,194 +0,0 @@ -/* - Wifi Xively sensor client - - This sketch connects an analog sensor to Xively (http://www.xively.com) - using an Arduino Wifi shield. - - This example is written for a network using WPA encryption. For - WEP or WPA, change the Wifi.begin() call accordingly. - - This example has been updated to use version 2.0 of the Xively API. - To make it work, create a feed with a datastream, and give it the ID - sensor1. Or change the code below to match your feed. - - Circuit: - * Analog sensor attached to analog in 0 - * Wifi shield attached to pins 10, 11, 12, 13 - - created 13 Mar 2012 - modified 31 May 2012 - by Tom Igoe - modified 8 Nov 2013 - by Scott Fitzgerald - - This code is in the public domain. - - */ -#include -#include - -#define APIKEY "YOUR API KEY GOES HERE" // replace your xively api key here -#define FEEDID 00000 // replace your feed ID -#define USERAGENT "My Arduino Project" // user agent is the project name - -char ssid[] = "yourNetwork"; // your network SSID (name) -char pass[] = "secretPassword"; // your network password - -int status = WL_IDLE_STATUS; - -// initialize the library instance: -WiFiClient client; -// if you don't want to use DNS (and reduce your sketch size) -// use the numeric IP instead of the name for the server: -IPAddress server(216,52,233,121); // numeric IP for api.xively.com -//char server[] = "api.xively.com"; // name address for xively API - -unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds -boolean lastConnected = false; // state of the connection last time through the main loop -const unsigned long postingInterval = 10*1000; //delay between updates to xively.com - -void setup() { - //Initialize serial and wait for port to open: - Serial.begin(9600); - while (!Serial) { - ; // wait for serial port to connect. Needed for Leonardo only - } - - // check for the presence of the shield: - if (WiFi.status() == WL_NO_SHIELD) { - Serial.println("WiFi shield not present"); - // don't continue: - while (true); - } - - String fv = WiFi.firmwareVersion(); - if ( fv != "1.1.0" ) - Serial.println("Please upgrade the firmware"); - - // attempt to connect to Wifi network: - while ( status != WL_CONNECTED) { - Serial.print("Attempting to connect to SSID: "); - Serial.println(ssid); - // Connect to WPA/WPA2 network. Change this line if using open or WEP network: - status = WiFi.begin(ssid, pass); - - // wait 10 seconds for connection: - delay(10000); - } - // you're connected now, so print out the status: - printWifiStatus(); -} - - -void loop() { - // read the analog sensor: - int sensorReading = analogRead(A0); - - // if there's incoming data from the net connection. - // send it out the serial port. This is for debugging - // purposes only: - while (client.available()) { - char c = client.read(); - Serial.print(c); - } - - // if there's no net connection, but there was one last time - // through the loop, then stop the client: - if (!client.connected() && lastConnected) { - Serial.println(); - Serial.println("disconnecting."); - client.stop(); - } - - // if you're not connected, and ten seconds have passed since - // your last connection, then connect again and send data: - if (!client.connected() && (millis() - lastConnectionTime > postingInterval)) { - sendData(sensorReading); - } - // store the state of the connection for next time through - // the loop: - lastConnected = client.connected(); -} - -// this method makes a HTTP connection to the server: -void sendData(int thisData) { - // if there's a successful connection: - if (client.connect(server, 80)) { - Serial.println("connecting..."); - // send the HTTP PUT request: - client.print("PUT /v2/feeds/"); - client.print(FEEDID); - client.println(".csv HTTP/1.1"); - client.println("Host: api.xively.com"); - client.print("X-ApiKey: "); - client.println(APIKEY); - client.print("User-Agent: "); - client.println(USERAGENT); - client.print("Content-Length: "); - - // calculate the length of the sensor reading in bytes: - // 8 bytes for "sensor1," + number of digits of the data: - int thisLength = 8 + getLength(thisData); - client.println(thisLength); - - // last pieces of the HTTP PUT request: - client.println("Content-Type: text/csv"); - client.println("Connection: close"); - client.println(); - - // here's the actual content of the PUT request: - client.print("sensor1,"); - client.println(thisData); - - } - else { - // if you couldn't make a connection: - Serial.println("connection failed"); - Serial.println(); - Serial.println("disconnecting."); - client.stop(); - } - // note the time that the connection was made or attempted: - lastConnectionTime = millis(); -} - - -// This method calculates the number of digits in the -// sensor reading. Since each digit of the ASCII decimal -// representation is a byte, the number of digits equals -// the number of bytes: - -int getLength(int someValue) { - // there's at least one byte: - int digits = 1; - // continually divide the value by ten, - // adding one to the digit count for each - // time you divide, until you're at 0: - int dividend = someValue / 10; - while (dividend > 0) { - dividend = dividend / 10; - digits++; - } - // return the number of digits: - return digits; -} - -void printWifiStatus() { - // print the SSID of the network you're attached to: - Serial.print("SSID: "); - Serial.println(WiFi.SSID()); - - // print your WiFi shield's IP address: - IPAddress ip = WiFi.localIP(); - Serial.print("IP Address: "); - Serial.println(ip); - - // print the received signal strength: - long rssi = WiFi.RSSI(); - Serial.print("signal strength (RSSI):"); - Serial.print(rssi); - Serial.println(" dBm"); -} - - - diff --git a/libraries/WiFi/examples/WiFiXivelyClientString/WiFiXivelyClientString.ino b/libraries/WiFi/examples/WiFiXivelyClientString/WiFiXivelyClientString.ino deleted file mode 100644 index 20be0feb3..000000000 --- a/libraries/WiFi/examples/WiFiXivelyClientString/WiFiXivelyClientString.ino +++ /dev/null @@ -1,181 +0,0 @@ -/* - Wifi Xively sensor client with Strings - - This sketch connects an analog sensor to Xively (http://www.xively.com) - using a Arduino Wifi shield. - - This example is written for a network using WPA encryption. For - WEP or WPA, change the Wifi.begin() call accordingly. - - This example has been updated to use version 2.0 of the xively.com API. - To make it work, create a feed with a datastream, and give it the ID - sensor1. Or change the code below to match your feed. - - This example uses the String library, which is part of the Arduino core from - version 0019. - - Circuit: - * Analog sensor attached to analog in 0 - * Wifi shield attached to pins 10, 11, 12, 13 - - created 16 Mar 2012 - modified 31 May 2012 - by Tom Igoe - modified 8 Sept 2012 - by Scott Fitzgerald - - This code is in the public domain. - - */ - -#include -#include - -#define APIKEY "YOUR API KEY GOES HERE" // replace your xively api key here -#define FEEDID 00000 // replace your feed ID -#define USERAGENT "My Arduino Project" // user agent is the project name - -char ssid[] = "yourNetwork"; // your network SSID (name) -char pass[] = "secretPassword"; // your network password - -int status = WL_IDLE_STATUS; - -// initialize the library instance: -WiFiClient client; - -// if you don't want to use DNS (and reduce your sketch size) -// use the numeric IP instead of the name for the server: -//IPAddress server(216,52,233,121); // numeric IP for api.xively.com -char server[] = "api.xively.com"; // name address for xively API - -unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds -boolean lastConnected = false; // state of the connection last time through the main loop -const unsigned long postingInterval = 10*1000; //delay between updates to xively.com - -void setup() { - //Initialize serial and wait for port to open: - Serial.begin(9600); - while (!Serial) { - ; // wait for serial port to connect. Needed for Leonardo only - } - - // check for the presence of the shield: - if (WiFi.status() == WL_NO_SHIELD) { - Serial.println("WiFi shield not present"); - // don't continue: - while (true); - } - - String fv = WiFi.firmwareVersion(); - if ( fv != "1.1.0" ) - Serial.println("Please upgrade the firmware"); - - // attempt to connect to Wifi network: - while ( status != WL_CONNECTED) { - Serial.print("Attempting to connect to SSID: "); - Serial.println(ssid); - // Connect to WPA/WPA2 network. Change this line if using open or WEP network: - status = WiFi.begin(ssid, pass); - - // wait 10 seconds for connection: - delay(10000); - } - // you're connected now, so print out the status: - printWifiStatus(); -} - -void loop() { - // read the analog sensor: - int sensorReading = analogRead(A0); - // convert the data to a String to send it: - - String dataString = "sensor1,"; - dataString += sensorReading; - - // you can append multiple readings to this String if your - // xively feed is set up to handle multiple values: - int otherSensorReading = analogRead(A1); - dataString += "\nsensor2,"; - dataString += otherSensorReading; - - // if there's incoming data from the net connection. - // send it out the serial port. This is for debugging - // purposes only: - while (client.available()) { - char c = client.read(); - Serial.print(c); - } - - // if there's no net connection, but there was one last time - // through the loop, then stop the client: - if (!client.connected() && lastConnected) { - Serial.println(); - Serial.println("disconnecting."); - client.stop(); - } - - // if you're not connected, and ten seconds have passed since - // your last connection, then connect again and send data: - if (!client.connected() && (millis() - lastConnectionTime > postingInterval)) { - sendData(dataString); - } - // store the state of the connection for next time through - // the loop: - lastConnected = client.connected(); -} - -// this method makes a HTTP connection to the server: -void sendData(String thisData) { - // if there's a successful connection: - if (client.connect(server, 80)) { - Serial.println("connecting..."); - // send the HTTP PUT request: - client.print("PUT /v2/feeds/"); - client.print(FEEDID); - client.println(".csv HTTP/1.1"); - client.println("Host: api.xively.com"); - client.print("X-ApiKey: "); - client.println(APIKEY); - client.print("User-Agent: "); - client.println(USERAGENT); - client.print("Content-Length: "); - client.println(thisData.length()); - - // last pieces of the HTTP PUT request: - client.println("Content-Type: text/csv"); - client.println("Connection: close"); - client.println(); - - // here's the actual content of the PUT request: - client.println(thisData); - } - else { - // if you couldn't make a connection: - Serial.println("connection failed"); - Serial.println(); - Serial.println("disconnecting."); - client.stop(); - } - // note the time that the connection was made or attempted: - lastConnectionTime = millis(); -} - - -void printWifiStatus() { - // print the SSID of the network you're attached to: - Serial.print("SSID: "); - Serial.println(WiFi.SSID()); - - // print your WiFi shield's IP address: - IPAddress ip = WiFi.localIP(); - Serial.print("IP Address: "); - Serial.println(ip); - - // print the received signal strength: - long rssi = WiFi.RSSI(); - Serial.print("signal strength (RSSI):"); - Serial.print(rssi); - Serial.println(" dBm"); -} - -