I am new to xively. I am planning to connect some devices (may call Internet of things) to internet. All my devices will have GPRS for connection. The data collected by these device will be uploaded to net and stored in some spreadsheet like form. I found that xively is a good choice. Can anybody give a tutorial for this kind of project? I searched a lot but unable to find it.
1 Answers
I do this kind of application all the time. Xively is pretty good. data.sparkfun.com is also a great free datalogging service.
There are tons of resources out there, but I haven't found any great 'tutorials' that specifically address GPRS connection. Personally, I use an arduino for GPRS connection to devices. If you haven't used arduino, I recommend the books "getting started with arduino" and "programming arduino."
I also recommend getting very well acquainted with sparkfun.com, instructables.com, and adafruit.com, which give free tutorials, projects, and information about all kinds of internet of things applications.
Here is the code I used for a GPRS thermometer that i made. The hardware setup was basically the same as the one shown on this tutorial. I threw in a couple of comments that will help you with some of the little problems it took me months to figure out.
My best advice is just keep doing tutorials and at first, focus on learning and copying lots of projects before you get too invested in any single creation. There is a ton of stuff to learn about this. Best of luck.
#include <GPRSClient.h>
#include <Xively.h>
#include <SoftwareSerial.h>
#define numSamples 5
#define sensor 0 // select the input pin for the thermistor
int samples[numSamples];
#define PIN_TX 7
#define PIN_RX 8
char xivelyKey[] = "[your api key]"; // API key
char sensorId[] = "sensor"; // Define the strings for our datastream IDs
XivelyDatastream datastreams[] = {
XivelyDatastream(sensorId, strlen(sensorId), DATASTREAM_FLOAT),
};
XivelyFeed feed([your feed id], datastreams, 1); // # of Datastreams
char apn[] = "wap.cingular"; //depends on what sim card you are using. I used an att gophone. make sure you have a data plan
GPRSClient gprs(PIN_TX,PIN_RX,19200,apn,NULL,NULL);
XivelyClient xivelyclient(gprs);
void setup() {
Serial.begin(19200);
Serial.println("Starting single datastream upload to Xively...");
Serial.println();
gprs.init();
while(false == gprs.join()) {
Serial.println("connect error");
delay(2000);
}
// successful DHCP
Serial.print("IP = ");
Serial.println(gprs.getIPAddress());
}
void loop() {
//int sensorValue = 333; // for debugging
float averageADC = getADC();
float temp = convertToTemp(averageADC);
datastreams[0].setFloat(temp);
Serial.print("Read sensor value ");
Serial.println(datastreams[0].getFloat());
Serial.println("Uploading it to Xively");
int ret = xivelyclient.put(feed, xivelyKey);
if(true == ret){
Serial.println("update success!");
}else{
Serial.println("update failed!");
}
Serial.println();
delay(10*1000);
}
float getADC()
{
for(int i = 0; i < numSamples; i++) {
samples[i]= analogRead(sensor);
Serial.print("sample reading: ");
Serial.println(samples[i]);
delay(2000);
}
float averageADC = 0;
for (int i = 0; i < numSamples; i++) {
averageADC += samples[i];
}
averageADC /= numSamples;
Serial.print("averageADC = : ");
Serial.println(averageADC);
return averageADC;
}
float convertToTemp(float analogReading) //
{
float seriesResistance = 100000.0;
float thermistance = seriesResistance / (1023.0 / analogReading - 1.0);
Serial.print("thermistance: ");
Serial.println(thermistance);
float temp = 0.00650 - 0.00026322 * log(thermistance) + .00000003402782 * log(thermistance)*log(thermistance)*log(thermistance); //these coefficients come from solving the steinhart hart equation
Serial.println(temp);
temp = 1.0/temp;
Serial.println(temp);
temp = (temp - 273.15) * 1.8000 + 32.0;
Serial.println(temp);
return temp;
}

- 1,565
- 19
- 27