0
我試圖從Xively_GPRS主站庫(https://github.com/Seeed-Studio/Xively_GPRS)使用此示例來獲取xively網站的數據,對於Arduino的串口監視器:「Xively GPRS主站庫」用sim900 icomsat盾爲arduino GET示例
「從Xively例如
IP = 191.171.127.94讀」 我使用的是icomsat 1.1 SIM900從Itead工作室基於Arduino的盾牌。
有人可以幫助我嗎?謝謝!
#include <GPRSClient.h>
#include <Xively.h>
#include <SoftwareSerial.h>
#define PIN_TX 2
#define PIN_RX 3
// Your Xively key to let you upload data
char xivelyKey[] = "yGr24HFXpc2IVMACSdmyypR9d6ubk8XX2f3RRFJ2phhR96AR";
// Define the string for our datastream ID
char sensorId[] = "sensor";
XivelyDatastream datastreams[] = {
XivelyDatastream(sensorId, strlen(sensorId), DATASTREAM_FLOAT),
};
// Finally, wrap the datastreams into a feed
XivelyFeed feed(675207838, datastreams, 1 /* number of datastreams */);
char apn[] = "tim.br";
char user[] = "tim";
char pass[] = "tim";
GPRSClient gprs(PIN_TX,PIN_RX,4800,apn,user,pass);
XivelyClient xivelyclient(gprs);
void setup() {
// put your setup code here, to run once:
Serial.begin(4800);
Serial.println("Reading from Xively example");
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 ret = xivelyclient.get(feed, xivelyKey);
if (ret > 0){
Serial.println("Datastream is...");
Serial.println(feed[0]);
Serial.print("Temperature is: ");
Serial.println(feed[0].getFloat());
}
Serial.println();
delay(15000UL);
}