Go Down

Topic: GSM Shield 2 with standard GsmScanNetworks Sketch gives no data (Solved) (Read 1 time) previous topic - next topic

peeprada

Hi!

So I have Arduino Uno and GSM 2 connected together. GSM shield has external 5V 3A power supply.
I am using version 1.6.13 Hourly build 2016/11/09 02:33
Receiving Calls and SMS's works. When I call to shield, it displays a calling number, when I use Receive SMS sketch, calling number is displayed and SMS is displayed.

But standard GsmScanNetworks sketch gives only zeros:

Quote
GSM networks scanner
Modem IMEI: 0
Scanning available networks. May take some seconds.

Current carrier: 0
Signal Strength:  [0-31]
What could be the problem?
Code is magic of thinking

peeprada

Howover, running this sketch:
Code: [Select]
#include <GSM.h>

// modem verification object
GSMModem modem;

// IMEI variable
String IMEI = "";

void setup()
{
  // initialize serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
 
  // start modem test (reset and check response)
  Serial.print("Starting modem test...");
  if(modem.begin())
    Serial.println("modem.begin() succeeded");
  else
    Serial.println("ERROR, no modem answer.");
}

void loop()
{
  // get modem IMEI
  Serial.print("Checking IMEI...");
  IMEI = modem.getIMEI();
 
  // check IMEI response
  if(IMEI != NULL)
  {
    // show IMEI in serial monitor
    Serial.println("Modem's IMEI: " + IMEI);
    // reset modem to check booting:
    Serial.print("Resetting modem...");
    modem.begin();
    // get and check IMEI one more time
    if(modem.getIMEI() != NULL)
    {
      Serial.println("Modem is functoning properly");
    }
    else
    {
      Serial.println("Error: getIMEI() failed after modem.begin()");
    }
  }
  else
  {
    Serial.println("Error: Could not get IMEI");
  }
  // do nothing:
  while(true);
}


Gives this reply:
Quote
Starting modem test...ERROR, no modem answer.
Checking IMEI...Modem's IMEI: 0
Resetting modem...Modem is functoning properly
Code is magic of thinking

peeprada

Receiving an SMS with following sketch works:
Code: [Select]
// include the GSM library
#include <GSM.h>

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

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

// Array to hold the number a SMS is retreived 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
  boolean 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);

}



A test SMS is displayed like this:

Quote
SMS Messages Receiver
GSM initialized
Waiting for messages
Message received from:
+3725123456
This is a test number twenty nine..................@

O
END OF MESSAGE
MESSAGE DELETED
Code is magic of thinking

peeprada

Sending SMS with following standard sketch from Examples works as well:
Code: [Select]
// Include the GSM library
#include <GSM.h>

#define PINNUMBER "1234"

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

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 Sender");

  // connection state
  boolean notConnected = true;

  // Start GSM shield
  // If your SIM has PIN, pass it as a parameter of begin() in quotes
  while (notConnected) {
    if (gsmAccess.begin(PINNUMBER) == GSM_READY) {
      notConnected = false;
    } else {
      Serial.println("Not connected");
      delay(1000);
    }
  }

  Serial.println("GSM initialized");
}

void loop() {

  Serial.print("Enter a mobile number: ");
  char remoteNum[20];  // telephone number to send sms
  readSerial(remoteNum);
  Serial.println(remoteNum);

  // sms text
  Serial.print("Now, enter SMS content: ");
  char txtMsg[200];
  readSerial(txtMsg);
  Serial.println("SENDING");
  Serial.println();
  Serial.println("Message:");
  Serial.println(txtMsg);

  // send the message
  sms.beginSMS(remoteNum);
  sms.print(txtMsg);
  sms.endSMS();
  Serial.println("\nCOMPLETE!\n");
}

/*
  Read input serial
 */
int readSerial(char result[]) {
  int i = 0;
  while (1) {
    while (Serial.available() > 0) {
      char inChar = Serial.read();
      if (inChar == '\n') {
        result[i] = '\0';
        Serial.flush();
        return 0;
      }
      if (inChar != '\r') {
        result[i] = inChar;
        i++;
      }
    }
  }
}


I got an SMS and serial output looked like this:
Quote
SMS Messages Sender
GSM initialized
Enter a mobile number: 5123456
Now, enter SMS content: SENDING

Message:
Hello world! This is Arduino GSM sending you a message!

COMPLETE!

Enter a mobile number:
Code is magic of thinking

peeprada

I am using version 1.6.13 Hourly build 2016/11/09 02:33

Standard Band management sketch doesn't work.

I have following output:
Quote
Restarting modem...
Modem restarted.
Unrecognized modem answer:
Current band:
Want to change the band you’re on?
Select band:
1 : E-GSM(900)
2 : DCS(1800)
3 : PCS(1900)
4 : E-GSM(900)+DCS(1800) ex: Europe
5 : GSM(850)+PCS(1900) Ex: USA, South Am.
6 : GSM(850)+E-GSM(900)+DCS(1800)+PCS(1900)

Configuring band EGSM_MODE
Error while changing band
Unrecognized modem answer:
Current band:
Want to change the band you’re on?
Select band:
1 : E-GSM(900)
2 : DCS(1800)
3 : PCS(1900)
4 : E-GSM(900)+DCS(1800) ex: Europe
5 : GSM(850)+PCS(1900) Ex: USA, South Am.
6 : GSM(850)+E-GSM(900)+DCS(1800)+PCS(1900)
Code is magic of thinking

peeprada

I tried to use older version that I have - 1.6.5

It worked!
So there is some kind of bug in the new wersion

Serial output looks like that

Quote
GSM networks scanner
Modem IMEI: 861074029135004
Scanning available networks. May take some seconds.
> Elisa Eesti
> Tele2
> EMT

Current carrier: Elisa Eesti
Signal Strength: 18 [0-31]
Scanning available networks. May take some seconds.
Code is magic of thinking


Go Up