Go Down

Topic: GPRS modem Maduino A6 Ai Thinker doesn't properly register on network (Read 361 times) previous topic - next topic

d2fry

Hello everyone!
I'm trying to do a simple gprs test connection but with no luck, I've tried a m2m german sim and also an italian wind sim.
Both sims see the network but don't properly register: AT+COPS? returns ERROR 50
The Maduino is powered with 1A usb charger, and serial connections are fine.
Here is the output and the code.
Am I doing something wrong? :'(


german sim


Code: [Select]

###comando n.1: AT
AT


###comando n.2: AT
AT
 
OK
OK

###comando n.3: ATI
ATI
 
Ai Thinker Co.LTD
A6
V03.03.20161229019H03
 
OK
###comando n.4: AT+IPR?
AT+IPR?
 
+IPR: 4800
 
OK
###comando n.5: AT+CPIN?
AT+CPIN?
 
+CPIN:READY
 
OK
###comando n.6: AT+CCID
AT+CCID
 
+CCID:8988303000000xxxxxx
 
OK
###comando n.7: AT+CSQ
AT+CSQ
 
+CSQ: 7,99
 
OK
####################################################CREG
###comando n.8: AT+CREG?
AT+CREG?
 
+CREG: 1,10
 
OK
###comando n.9: AT+CREG=1
AT+CREG=1
 
OK
###comando n.10: AT+CREG?
AT+CREG?
 
+CREG: 1,10
 
OK
####################################################COPS
###comando n.11: AT+COPS?
AT+COPS?
 
+COPS: 0
 
OK
###comando n.12: AT+COPS=0,2
AT+COPS=0,2
###comando n.13: AT+COPS?
AT+COPS?
 
+CME ERROR:50
####################################################CGATT
###comando n.14: AT+CGATT?
AT+CGATT?
 
+CGATT:1
 
OK
###comando n.15: AT+CGATT=1
AT+CGATT=1
 
OK
###comando n.16: AT+CGATT?
AT+CGATT?
 
+CGATT:1
 
OK
####################################################CIP
###comando n.17: AT+CGDCONT=1,"IP","WM"
AT+CGDCONT=1,"IP","WM"
 
OK
###comando n.18: AT+CIPSTATUS
AT+CIPSTATUS
 
 
+CIPSTATUS:0,IP INITIAL 
1,IP INITIAL 
2,IP INITIAL 
3,IP INITIAL 
4,IP INITIAL 
5,IP INITIAL 
6,IP INITIAL 
7,IP INITIAL 
 
 
OK
###comando n.19: AT+CGACT=1,1
AT+CGACT=1,1
 
+CME ERROR:148
###comando n.20: AT+CIPSTATUS
AT+CIPSTATUS
 
 
+CIPSTATUS:0,IP INITIAL 
1,IP INITIAL 
2,IP INITIAL 
3,IP INITIAL 
4,IP INITIAL 
5,IP INITIAL 
6,IP INITIAL 
7,IP INITIAL 
 
 
OK
###comando n.21: AT+CIFSR
AT+CIFSR
 
+CME ERROR:50
###comando n.22: AT+CIPSTART="TCP","www.com1.it",80
AT+CIPSTART="TCP","www.com1.it",80
 
+CME ERROR:50
###comando n.23: AT+CIPSEND=80
AT+CIPSEND=80
 
+CME ERROR:53
###comando n.24: GET http://www.com1.it/pippogprs HTTP/1.0
 HOST:com1.it
 
 
GET http://www.com1.it/pippogprs HTTP/1.0
 HOST:com1.it
 
 
 
+C###comando n.25: AT+CIPCLOSE
ME ERROR:58
AT+CIPCLOSE
 
+CME ERROR:50




italian sim
Code: [Select]
Setting baudrate...###comando n.1: AT
4����###comando n.2: AT
###comando n.3: AT
###comando n.4: AT
###comando n.5: AT
###comando n.6: AT
###comando n.7: AT
###comando n.8: AT
###comando n.9: AT
AT

OK
OK
After 3s, test begin!!
###comando n.10: ATI
ATI

Ai Thinker Co.LTD
A6
V03.03.20161229019H03

OK
###comando n.11: AT+IPR?
AT+IPR?

+IPR: 4800

OK
###comando n.12: AT+CPIN?
AT+CPIN?

+CPIN:READY

OK
###comando n.13: AT+CCID
AT+CCID

+CCID:89398xxxxxxxxx

OK

+CIEV: service,  0
+CIEV: roam, 0

+CREG: 2
###comando n.14: AT+CSQ
AT+CSQ

+CSQ: 10,99

OK
####################################################CREG
###comando n.15: AT+CREG?
AT+CREG?

+CREG: 1,12

OK
###comando n.16: AT+CREG=1
AT+CREG=1

OK
###comando n.17: AT+CREG?
AT+CREG?

+CREG: 1,12

OK
####################################################COPS
###comando n.18: AT+COPS?
AT+COPS?

+COPS: 2

OK
###comando n.19: AT+COPS=0,2
AT+COPS=0,2
###comando n.20: AT+COPS?
AT+COPS?

+CME ERROR:50
####################################################CGATT
###comando n.21: AT+CGATT?
AT+CGATT?

+CGATT:0

OK
###comando n.22: AT+CGATT=1
AT+CGATT=1

+CIEV: service,  0
+CIEV: roam, 0

+CREG: 2

+CME ERROR:30

+CME ERROR:50
###comando n.23: AT+CGATT?
AT+CGATT?

+CGATT:1

OK
####################################################CIP
###comando n.24: AT+CGDCONT=1,"IP","internet.wind",0,0
AT+CGDCONT=1,"IP","internet.wind",0,0

OK
###comando n.25: AT+CIPSTATUS
AT+CIPSTATUS


+CIPSTATUS:0,IP INITIAL 
1,IP INITIAL 
2,IP INITIAL 
3,IP INITIAL 
4,IP INITIAL 
5,IP INITIAL 
6,IP INITIAL 
7,IP INITIAL 


OK
###comando n.26: AT+CGACT=1,1
AT+CGACT=1,1

+CME ERROR:148
###comando n.27: AT+CIPSTATUS
AT+CIPSTATUS


+CIPSTATUS:0,IP INITIAL 
1,IP INITIAL 
2,IP INITIAL 
3,IP INITIAL 
4,IP INITIAL 
5,IP INITIAL 
6,IP INITIAL 
7,IP INITIAL 


OK
###comando n.28: AT+CIFSR
AT+CIFSR

+CME ERROR:50
###comando n.29: AT+CIPSTART="TCP","www.google.it",80
AT+CIPSTART="TCP","www.google.it",80

+CME ERROR:50
###comando n.30: AT+CIPSEND=80
AT+CIPSEND=80

+CME ERROR:53
###comando n.31: GET http://www.google.it/pippogprs HTTP/1.0
 HOST:google.it


GET http://www.google.it/pippogprs HTTP/1.0
 HOST:google.it


###comando n.32: AT+CIPCLOSE

+CME ERROR:58
AT+CIPCLOSE

+CME ERROR:50



Code: [Select]
#include <SoftwareSerial.h>

SoftwareSerial mySerial(7, 8);
#include<stdio.h>
#include<string.h>
#define DEBUG true

#define MONITOR Serial
#define CONTROL mySerial

#define SPEEDMONITOR 9600
#define SPEEDCONTROL 9600

unsigned char ctrl_z = 26;

int cn = 0;
void setup()
{
  MONITOR.begin(SPEEDMONITOR);
  CONTROL.begin(SPEEDCONTROL);
  delay(1000);
  int pon = 9;
  int poff = 6;
  int lowp = 5;
  pinMode(pon, OUTPUT);
  pinMode(poff, OUTPUT);
  pinMode(lowp, OUTPUT);
  digitalWrite(poff, LOW);
  digitalWrite(lowp, HIGH);
  digitalWrite(pon, HIGH);
  delay(3000);
  digitalWrite(pon, LOW);
  delay(1000);
  baudrate();
  MONITOR.println("After 3s, test begin!!");
  delay(3000);

}

void loop()
{

  sendData("ATI", 500, DEBUG);    //        flushb(1000);
  sendData("AT+IPR?", 500, DEBUG); //   flushb(1000);
  sendData("AT+CPIN?", 1000, DEBUG);   flushb(1000);
  sendData("AT+CCID", 2500, DEBUG);
  sendData("AT+CSQ", 2500, DEBUG);

  MONITOR.println("####################################################CREG");
  sendData("AT+CREG?", 3000, DEBUG);
  sendData("AT+CREG=1", 1000, DEBUG);
  sendData("AT+CREG?", 2500, DEBUG);


  MONITOR.println("####################################################COPS");
  sendData("AT+COPS?", 500, DEBUG);
  sendData("AT+COPS=0,2", 30000, DEBUG);
  sendData("AT+COPS?", 500, DEBUG);


  MONITOR.println("####################################################CGATT");
  sendData("AT+CGATT?", 500, DEBUG);
  sendData("AT+CGATT=1", 30000, DEBUG);
  sendData("AT+CGATT?", 500, DEBUG);


  MONITOR.println("####################################################CIP");
  //sendData("AT+CGDCONT=1,\"IP\",\"em\"",1000,DEBUG);
  //sendData("AT+CGDCONT=1,\"IP\",\"WM\"",1000,DEBUG);
  sendData("AT+CGDCONT=1,\"IP\",\"internet.wind\",0,0", 1000, DEBUG);
  sendData("AT+CIPSTATUS", 1000, DEBUG);
  sendData("AT+CGACT=1,1", 1000, DEBUG);
  sendData("AT+CIPSTATUS", 1000, DEBUG);

  sendData("AT+CIFSR", 1000, DEBUG);
  //sendData("AT+CIPSTART=\"TCP\",\"www.com1.it\",80",1000,DEBUG);
  sendData("AT+CIPSTART=\"TCP\",\"www.google.it\",80", 1000, DEBUG);
  sendData("AT+CIPSEND=80", 1000, DEBUG);
  //     sendData("GET http://www.com1.it/pippogprs HTTP/1.0\r\n HOST:com1.it\r\n\r\n",100,DEBUG);
  sendData("GET http://www.google.it/pippogprs HTTP/1.0\r\n HOST:google.it\r\n\r\n", 100, DEBUG);
  delay(10000);
  sendData("AT+CIPCLOSE ", 1000, DEBUG);





}
void baudrate()
{
  if (DEBUG)     {
    MONITOR.print("Setting baudrate...");
  }
  int i = 0;
  for (i = 0; i < 1000; i++)
  {
    String msg = String("");

    msg = sendData("AT", 1000, DEBUG);
    if ( msg.indexOf("OK") >= 0 )
    {
      if (DEBUG)     {
        MONITOR.println("OK");
      }
      return;
    }
  }
  if (DEBUG)     {
    MONITOR.println("ko");
  }
}


String sendData(String command, const int timeout)
{
  sendData(command,  timeout, false);
}

String sendData(String command, const int timeout, boolean debug)
{
  cn++;
  String response = "";
  if (debug)
  {
    MONITOR.print("###comando n.");
    MONITOR.print(cn);
    MONITOR.print(": ");
    MONITOR.println(command);

  }
  CONTROL.println(command);
  long int time = millis();
  while ( (time + timeout) > millis())
  {
    while (CONTROL.available())
    {
      char c = CONTROL.read();
      response += c;
      //   Serial.print(c);
    }
  }
  if (debug)     {
    MONITOR.print(response);
  }

  return response;
}

void flushb(const int timeout)
{
  long int time = millis();
  while ( (time + timeout) > millis())
  {
    while (CONTROL.available())
    {
      char c = CONTROL.read();
      MONITOR.print(c);
    }
  }
}




Grazie
Fabrizio

Go Up