Sms Arduino GSM短信息和GPRS-Xively。Can';两者不能同时进行

Sms Arduino GSM短信息和GPRS-Xively。Can';两者不能同时进行,sms,arduino,gsm,gprs,xively,Sms,Arduino,Gsm,Gprs,Xively,嗨,这里是Arduino初学者 我正在使用带有官方Arduino GSM模块的Arduino UNO R3。IDE1.0.5 我正在尝试将数据上传到Xively,但也能够接收短信 我已经能够独立完成这两项工作(甚至为这两项工作创建函数) 两者都能独立工作 当我试图同时实现它们时,我遇到了一个问题 我把序列号标记放进去,发现了问题所在(我认为是关于-xivelyclient.put(feed,xivelyKey);point) 该程序将执行-上传一个数据点,然后卡在这里。短信将不起作用,也不会上传

嗨,这里是Arduino初学者

我正在使用带有官方Arduino GSM模块的
Arduino UNO R3
。IDE1.0.5

我正在尝试将数据上传到
Xively
,但也能够接收短信

我已经能够独立完成这两项工作(甚至为这两项工作创建函数)

两者都能独立工作

当我试图同时实现它们时,我遇到了一个问题

我把序列号标记放进去,发现了问题所在(我认为是关于-
xivelyclient.put(feed,xivelyKey);
point)

该程序将执行-上传一个数据点,然后卡在这里。短信将不起作用,也不会上传另一个数据点。奇怪的是,如果忽略短信功能,完全相同的功能将起作用。我需要两者都做

以下是串行终端输出:

短信接收器

正在启动客户端

GSM初始化

等待消息

读取传感器值807.00

一,

上传到Xively

问题出在
xvley
code我在猜什么

附件是我的代码-我被难住了-任何帮助都将不胜感激

#include <GSM.h>   // include the GSM library
#include <stdlib.h>
#include <HttpClient.h>
#include <Xively.h>


GSM gsmAccess;     // initialize the library instances
GSM_SMS sms;
GSMClient client;
GPRS gprs;

#define PINNUMBER ""  // PIN Number for the SIM
#define xivelyFeed 2026168855
char xivelyKey[] = "WwRCfO61e28WASeUcfGHJmyoo4g7mXczEC1pBMGYc3VgGgBX";

#define sensorPin A0
#define ledPin 9

#define GPRS_APN       "internet" // replace with the APN of the GPRS provider
#define GPRS_LOGIN     "" // empty on bluevia, replace with your GPRS login if needed
#define GPRS_PASSWORD  "" // empty on bluevia, replace with your GPRS password 

char senderNumber[20];
char server[] = "api.xively.com";      // name address for xively API

unsigned long lastConnectionTime = 0;         // last time you connected to the server
boolean lastConnected = false;                  // state of the connection last 
const unsigned long postingInterval = 10*1000;  //delay between updates to Pachube.com

char sensorID[] = "Light";  //datastreams
char ledID[] = "LED";

XivelyDatastream datastreams[] = {
XivelyDatastream(sensorID, strlen(sensorID), DATASTREAM_FLOAT),
XivelyDatastream(ledID, strlen(ledID), DATASTREAM_FLOAT),
};


// Finally, wrap the datastreams into a feed
XivelyFeed feed(xivelyFeed, datastreams, 2 /* number of datastreams */);

XivelyClient xivelyclient(client);

void setup()
{

Serial.begin(9600);

 Serial.println("SMS Messages Receiver");
 Serial.println("Starting Xively client.");

boolean notConnected = true;



 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("GSM initialized");
  Serial.println("Waiting for messages");
  pinMode(sensorPin, INPUT);

}

void loop()
{




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


  UploadData(); 
  delay(10);
  CheckSMS();




}

void UploadData( ){
  //read sensor values
  int sensorValue = analogRead(sensorPin);
  datastreams[0].setFloat(sensorValue);

  //print the sensor valye
  Serial.print("Read sensor value ");
  Serial.println(datastreams[0].getFloat());

  Serial.println(1);


  //send value to xively
  Serial.println("Uploading it to Xively");
  int ret = xivelyclient.put(feed, xivelyKey);

  Serial.println(2);

  //return message
  Serial.print("xivelyclient.put returned ");
  Serial.println(ret);
  Serial.println("");

  Serial.println(3);
  //delay between calls
  delay(15000);  
} 

void CheckSMS(){

  char c; // variable for the SMS message
  int password =0;
  pinMode(12,OUTPUT);
  int incomingByte=0;

  if (sms.available())
  {
    Serial.println("Message received from:");
    sms.remoteNumber(senderNumber, 20); // Get remote number
    Serial.println(senderNumber);

    if(sms.peek()=='#')                    // An example of message disposal    
                        // Any messages starting with # should discarded
    {
      Serial.println("Discarded SMS");
      sms.flush();
    }

    while(c=sms.read())                      // Read message bytes and print them
     {
      Serial.print(c);

      password += c;

      Serial.print("instance 1");
      Serial.println(password);

      incomingByte = password;

      if (incomingByte == 150) {
      digitalWrite(12,HIGH);
      delay(5000);
      digitalWrite(12,LOW);
      incomingByte= 222;   }


     }
    Serial.println("\nEND OF MESSAGE");
    sms.flush();                            // Delete message from modem memory
    Serial.println("MESSAGE DELETED");
    Serial.println(password);
   }
   delay(1000);

    } 
#包括//包括GSM库
#包括
#包括
#包括
GSM gsmAccess;//初始化库实例
手机短信;
GSM客户;
GPRS;
#定义PIN号码“”//SIM卡的PIN号码
#定义xivelyFeed 2026168855
char xivelyKey[]=“WwRCfO61e28WASeUcfGHJmyoo4g7mXczEC1pBMGYc3VgGgBX”;
#定义传感器引脚A0
#定义LED引脚9
#定义GPRS_APN“internet”//替换为GPRS提供商的APN
#定义GPRS_LOGIN”“//在bluevia上为空,如果需要,替换为您的GPRS登录
#定义GPRS_密码“”//在bluevia上为空,替换为您的GPRS密码
字符发送者编号[20];
char服务器[]=“api.xively.com”;//xively api的名称地址
unsigned long lastConnectionTime=0;//上次连接到服务器时
boolean lastConnected=false;//上次连接的状态
const unsigned long postingininterval=10*1000;//Pachube.com更新之间的延迟
char sensorID[]=“Light”;//数据流
字符ledID[]=“LED”;
XIVELYDATASEAM数据流[]={
十四数据流(传感器ID、strlen(传感器ID)、数据流_浮点),
XivelyDatastream(ledID、strlen(ledID)、DATASTREAM_FLOAT),
};
//最后,将数据流包装到提要中
XivelyFeed提要(XivelyFeed,数据流,2/*数据流数量*/);
XivelyClient XivelyClient(客户);
无效设置()
{
Serial.begin(9600);
Serial.println(“SMS消息接收器”);
Serial.println(“启动Xively客户端”);
布尔notConnected=true;
while(未连接)
{
如果((gsmAccess.begin(PINNUMBER)=GSM\u READY)&
(gprs.attachGPRS(gprs\u APN、gprs\u登录、gprs\u密码)=gprs\u就绪))
notConnected=false;
其他的
{
Serial.println(“未连接”);
延迟(1000);
}
}
Serial.println(“GSM初始化”);
Serial.println(“等待消息”);
引脚模式(传感器引脚,输入);
}
void循环()
{
//如果有来自网络连接的传入数据。
//通过串口发送出去,这是调试用的
//仅用于:
if(client.available())
{
char c=client.read();
连续打印(c);
}
上传数据();
延迟(10);
CheckSMS();
}
无效上载数据(){
//读取传感器值
int sensorValue=模拟读数(sensorPin);
数据流[0]。setFloat(传感器值);
//打印传感器值
串行打印(“读取传感器值”);
Serial.println(数据流[0].getFloat());
序列号println(1);
//将值发送给xively
Serial.println(“上传到Xively”);
int-ret=xivelyclient.put(feed,xivelyKey);
序列号println(2);
//回信
Serial.print(“xivelyclient.put返回”);
序列号println(ret);
Serial.println(“”);
序列号println(3);
//通话间隔
延迟(15 000);
} 
void CheckSMS(){
char c;//SMS消息的变量
int密码=0;
pinMode(12,输出);
int incomingByte=0;
如果(sms.available())
{
Serial.println(“收到的消息:”);
sms.remoteNumber(senderNumber,20);//获取远程号码
Serial.println(发送方编号);
if(sms.peek()='#')//消息处理示例
//任何以#开头的邮件都应丢弃
{
Serial.println(“废弃短信”);
sms.flush();
}
while(c=sms.read())//读取消息字节并打印它们
{
连续打印(c);
密码+=c;
串行打印(“实例1”);
Serial.println(密码);
incomingByte=密码;
如果(incomingByte==150){
数字写入(12,高);
延迟(5000);
数字写入(12,低);
incomingByte=222;}
}
Serial.println(“\n消息名称”);
sms.flush();//从调制解调器内存中删除消息
Serial.println(“消息已删除”);
Serial.println(密码);
}
延迟(1000);
} 

很难说清楚您的问题是什么。您是否也可以发布串行监视器的内容

在同时执行这两项操作时,您可能会遇到内存问题。Xively库相当大,在Uno上经常会遇到内存问题。您可以尝试使用该库检查并打印循环中每一步后剩余的内存量。另一种尝试是在Arduino Meg上运行相同的代码a、 如果您可以访问一个。Mega的SRAM数量明显增加,不会出现这些问题。

如果((gsmAccess.begin(PINNUMBER)==GSM\u READY)& (gprs.attachGPRS(gprs\u APN、gprs\u登录、gprs\u密码)=gprs\u就绪))

应为if((gsmAccess.begin(PINNUMBER)=GSM_READY)和&(DOUBLE&)
(gprs.attachGPRS(gprs\u APN,gprs\u登录,gprs\u密码)==gprs\u就绪))

谢谢您的回复。我尝试了密码wwit