Arduino Uno R3 + SIM900

时间:2016-08-04 22:04:10

标签: arduino gsm arduino-uno gprs sim900

我是一名尝试硬件的程序员

我试图连接我在网上购买的SIM900防护罩。 所以我已经按照大量的教程将SIM盾与Arduino UNO连接起来。

嗯,它进展不顺利。

我已经在其中放入了一个未锁定的SIM卡,并且netlight在3秒内闪烁3次意味着它找到了网络。

我还将引脚设置为D7和D8,正如很多人所指出的那样。 我也使用9v和1A的电源。

但是当我尝试运行一个简单的基本示例代码时,它们不能正常执行。

我运行此示例代码:

#include <SoftwareSerial.h>

SoftwareSerial GPRS(7, 8);

unsigned char buffer[64];  // buffer array for data receive over serial port
int count=0;               // counter for buffer array 

void setup()
{
  GPRS.begin(19200);
  Serial.begin(19200);
}

void loop()
{
  if (GPRS.available())
  {
    while(GPRS.available())
    {
      buffer[count++]=GPRS.read();
      if(count == 64)break;
    }
    Serial.write(buffer,count);
    clearBufferArray();
    count = 0;
  }
  if (Serial.available())
    GPRS.write(Serial.read());
}

void clearBufferArray() 
{
  for (int i=0; i<count;i++)
  {
    buffer[i]=NULL;
  }
}

之后我输入

  

AT

串行监视器中的

选择了19200波特 并打印出来 enter image description here (两个??)

似乎命令没有被发送......

这是我如何构建的东西 enter image description here enter image description here

请帮忙!! 我做错了什么?

1 个答案:

答案 0 :(得分:2)

我修好了!

我进入我的GSM库(位于库文件夹中),然后在GSM.cpp中将rx和tx引脚更改为7和8。 谢谢你的帮助!