Arduino gsm屏蔽没有响应。gsmAccess.begin()不起作用

Arduino gsm屏蔽没有响应。gsmAccess.begin()不起作用,arduino,gsm,Arduino,Gsm,我正试图让我的arduino GSM屏蔽使用提供的示例“发送SMS”代码。但是,当我上传和编译程序时,串行监视器显示“SMS Messages Sender”,其他情况不会发生 我正在使用Arduino uno r3和gsm sim 900。配备5V 1.5A电源的gsm。我已将arduino的针脚7和8连接到gsm的针脚7和8。我已经把gsm也接地了 当我使用SoftwareSerial.h时,它可以工作。但我希望使用GSM.h库,它现在不工作。需要帮忙吗 // include the GS

我正试图让我的arduino GSM屏蔽使用提供的示例“发送SMS”代码。但是,当我上传和编译程序时,串行监视器显示“SMS Messages Sender”,其他情况不会发生

我正在使用Arduino uno r3和gsm sim 900。配备5V 1.5A电源的gsm。我已将arduino的针脚7和8连接到gsm的针脚7和8。我已经把gsm也接地了

当我使用SoftwareSerial.h时,它可以工作。但我希望使用GSM.h库,它现在不工作。需要帮忙吗

 // include the GSM library
 #include <GSM.h>

 // PIN Number for the SIM
    #define PINNUMBER ""

  // initialize the library instances
   GSM gsmAccess;
 GSM_SMS sms;

 // Array to hold the number a SMS is retrieved from
 char senderNumber[20];
  void setup() {
 // initialize serial communications and wait for port to open:
 Serial.begin(9600);
  while (!Serial) {
 ; // wait for serial port to connect. Needed for native USB port only
 }

Serial.println("SMS Messages Receiver");

// connection state
bool notConnected = true;

// Start GSM connection
while (notConnected) {
if (gsmAccess.begin(PINNUMBER) == GSM_READY) {
  notConnected = false;
} else {
  Serial.println("Not connected");
  delay(1000);
 }
 }

Serial.println("GSM initialized");
Serial.println("Waiting for messages");
}
void loop() {
char c;

// If there are any SMSs available()
if (sms.available()) {
Serial.println("Message received from:");

// Get remote number
sms.remoteNumber(senderNumber, 20);
Serial.println(senderNumber);

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

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

Serial.println("\nEND OF MESSAGE");

// Delete message from modem memory
sms.flush();
Serial.println("MESSAGE DELETED");
}

delay(1000);

}
//包括GSM库
#包括
//SIM卡的PIN码
#定义PINNUMBER“”
//初始化库实例
GSM-gsmAccess;
手机短信;
//用于保存从中检索SMS的号码的数组
字符发送者编号[20];
无效设置(){
//初始化串行通信并等待端口打开:
Serial.begin(9600);
而(!串行){
;//等待串行端口连接。仅本机USB端口需要
}
Serial.println(“SMS消息接收器”);
//连接状态
bool notConnected=true;
//启动GSM连接
while(未连接){
如果(gsmAccess.begin(PINNUMBER)=GSM\u READY){
notConnected=false;
}否则{
Serial.println(“未连接”);
延迟(1000);
}
}
Serial.println(“GSM初始化”);
Serial.println(“等待消息”);
}
void循环(){
字符c;
//如果有可用的SMS()
如果(sms.available()){
Serial.println(“收到的消息:”);
//获取远程号码
sms.远程号码(发送方号码,20);
Serial.println(发送方编号);
//消息处理的一个示例
//任何以#开头的邮件都应丢弃
如果(sms.peek()='#'){
Serial.println(“废弃短信”);
sms.flush();
}
//读取消息字节并打印它们
而(c=sms.read()){
连续打印(c);
}
Serial.println(“\n消息名称”);
//从调制解调器存储器中删除消息
sms.flush();
Serial.println(“消息已删除”);
}
延迟(1000);
}

我希望这段代码能够让我接收消息,我可以修改它以将消息存储在变量中

您的问题可能是接线问题

您的电路板(Arduino UNO R3)有其UART(您在定义
串行时打算使用的UART。在引脚
0 RX
1 TX
上开始(9600)
。请参阅下面的示意图和图片(右上角带有标记TX和RX)

软件模拟串行工作,因为您将引脚7和8定义为模拟UART TX和RX信号