daily pastebin goal
88%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <SoftwareSerial.h>
  2. SoftwareSerial gprsSerial(7,8);
  3.  
  4. void setup(){
  5.   gprsSerial.begin(19200); // GPRS shield baud rate
  6.   Serial.begin(19200);  
  7.   delay(500);
  8. }
  9.  
  10. void loop(){
  11.   if(Serial.available()) {
  12.     switch(Serial.read()) {
  13.       case '0': testSIM900(); break;
  14.         // AT OK
  15.       case '1': testSIMCARD(); break;
  16.         // +CPIN: READY
  17.         // +CREG: 0,1
  18.       case '2': testNETWORK(); break;
  19.         // +CGATT: 1
  20.     }
  21.   }
  22.  
  23.   if(gprsSerial.available()) Serial.write(gprsSerial.read());
  24. }
  25.  
  26. void testSIM900() {
  27.   gprsSerial.println("AT");
  28.   // AT OK
  29.   delay(100);
  30.  
  31. }
  32.  
  33. void testSIMCARD() {
  34.   gprsSerial.println("AT+CPIN?");
  35.   // +CPIN: READY
  36.   delay(100);
  37.   gprsSerial.println("AT+CREG?");
  38.   // +CREG: 0,1
  39.   delay(100);
  40. }
  41.  
  42. void testNETWORK() {
  43.   gprsSerial.println("AT+CGATT?");
  44.   // +CGATT: 1
  45.   delay(100);
  46. }
  47.    
  48. AT
  49.  
  50. OK
  51. AT+CPIN?
  52.  
  53. +CPIN: READY
  54.  
  55. OK
  56. AT+CREG?
  57.  
  58. +CREG: 1,2
  59.  
  60. OK
  61.  
  62. +CREG: 0
  63.  
  64. +CGREG: 0
  65. AT+CGATT?
  66.  
  67. +CGATT: 0
  68.  
  69. OK
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top