" Xively GPRS-master library"用arduino的sim900 icomsat盾牌获取示例

时间:2014-03-28 06:25:02

标签: arduino gprs xively

我正在尝试使用Xively_GPRS-master库(https://github.com/Seeed-Studio/Xively_GPRS)中的这个示例来获取xively网站的数据,我只在arduino的串行监视器中得到这个:

“从Xively示例中读取

IP = 191.171.127.94“

我正在使用基于icomsat 1.1 sim900的屏幕来安装来自Itead Studio的arduino。

有人可以帮帮我吗? THANKYOU!

#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);
}

1 个答案:

答案 0 :(得分:0)

很难说出这里的问题。你可以发布串口监视器输出吗?另外,您是否在Xively Workbench请求日志中看到了任何请求?那将是第一个检查的地方。