Seeed-Studio / Seeeduino_GPRS

Seeeduino GPRS Library
http://www.seeedstudio.com/depot/Seeeduino-GPRS-p-1909.html
MIT License
89 stars 57 forks source link

Seeeduino GPRS Build Status

Seeeduino GPRS is a IoT panel, you can connect to the internet through GPRS wireless network with it. Making/answering voice calls and sending/receiving SMS messages are also supported. Meanwhile, Seeeduino GPRS supports FM radio function and bluetooth communication. For more information, you can visit our Wiki.

Features

Applications

Getting Started

please follow the example sketch in example folder.

Note:There is another library has better performance GPRS SIM900, to use it, exchange the RX and TX pins.

Sample of using GPRS_SIM900 library - GPRS_TCPConnection.ino

#include <SoftwareSerial.h>
#include <Wire.h>
#include "sim900.h"

#define PIN_TX    8  // Has already exchanged TX and RX pins
#define PIN_RX    7

#define SIM800_POWER_PIN        9  // Define SIM800 power status and control pins
#define SIM800_POWER_STATUS     12

//make sure that the baud rate of SIM800 is 9600!
//you can use the AT Command(AT+IPR=9600) to set it through SerialDebug
#define BAUDRATE  9600

char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\r\n\r\n";
char buffer[512];
GPRS gprs(PIN_TX, PIN_RX, BAUDRATE);
void setup(){
  Serial.begin(9600);
  SIM800_PreInit();
  // use DHCP
  while(!gprs.init()) {
      delay(1000);
      Serial.print("init error\r\n");
  }
  delay(3000);    
  // attempt DHCP
  while(!gprs.join(F("cmnet"))) {
      Serial.println("gprs join network error");
      delay(2000);
  }

  // successful DHCP
  Serial.print("IP Address is ");
  Serial.println(gprs.getIPAddress());

  if(!gprs.connect(TCP,"mbed.org", 80)) {
      Serial.println("connect error");
  }else{
      Serial.println("connect mbed.org success");
  }

  Serial.println("waiting to fetch...");
  gprs.send(http_cmd, sizeof(http_cmd)-1);
  while (true) {
      int ret = gprs.recv(buffer, sizeof(buffer)-1);
      if (ret <= 0){
          Serial.println("fetch over...");
          break;
      }
      buffer[ret] = '\0';
      Serial.print("Recv: ");
      Serial.print(ret);
      Serial.print(" bytes: ");
      Serial.println(buffer);
  }
  gprs.close();
  gprs.disconnect();
}

void loop(){

}

void SIM800_PreInit(void)
{
    Serial.println("SIM800 PreInit...");
    pinMode(SIM800_POWER_STATUS,INPUT);
    delay(10);
    if(LOW == digitalRead(SIM800_POWER_STATUS))
    {
        if(sim900_send_AT() != true)
        {            
            delay(800);
            digitalWrite(SIM800_POWER_PIN,HIGH);
            delay(200);
            digitalWrite(SIM800_POWER_PIN,LOW);
            delay(2000);
            digitalWrite(SIM800_POWER_PIN,HIGH);
            delay(3000);  
        }
        while(sim900_send_AT() != true);                
        Serial.println("Init O.K!");         
    }
    else
    {
        Serial.println("Power check failed!");  
    }
}

This software is written by lawliet zou () for Seeed Technology Inc. and is licensed under The MIT License. Check License.txt/LICENSE for the details of MIT license.

Contributing to this software is warmly welcomed. You can do this basically by
forking, committing modifications and then pulling requests (follow the links above
for operating guide). Adding change log and your contact into file header is encouraged.
Thanks for your contribution.

Seeed is a hardware innovation platform for makers to grow inspirations into differentiating products. By working closely with technology providers of all scale, Seeed provides accessible technologies with quality, speed and supply chain knowledge. When prototypes are ready to iterate, Seeed helps productize 1 to 1,000 pcs using in-house engineering, supply chain management and agile manufacture forces. Seeed also team up with incubators, Chinese tech ecosystem, investors and distribution channels to portal Maker startups beyond.

Analytics