Go Down

Topic: SIM card will not connect to network using GSM SIM900 Module  (Read 919 times) previous topic - next topic

abbyenginerd411

We are currently working on a project that will allow us to send a text message once a wire is cut.
We are using a GSM Module and an Arduino UNO. Our SIM card ( T-Mobile Pre-paid SIM card)  does not want to connect to the network, we have the GSM library and we are using the Arduino 1.8.5 code program.
Does our code need to have certain lines to tell the card to connect?
When we plugged the SIM into a phone to check if it was connected the phone said " No SIM Available."
Any Suggestions we will gladly take, as we are quickly approaching the deadline for this project. ( This is a high school Vo-Tech center project)


The first code is a code we set up to check to see if it is working through AT commands and a serial monitor :


Code: [Select]
#include <SoftwareSerial.h>
SoftwareSerial GPRS (7, 8) ;
unsigned char buffer[64] ; // buffer array for data recieved over serial port
int count = 0; // counter for buffer array
void setup() {
  GPRS.begin(9600) ; // the GPRS baud rate
  Serial.begin(9600) ; // the Serial port of Arduino baud rate
}

void loop()
{
  while (GPRS.available()) // reading data into char array
  {
    buffer[count++] = GPRS.read(); // writing data into array
    if (count == 64) break;
  }
  Serial.write(buffer, count); //if no data transmission ends, write buffer to hardware Serial port
  clearBufferArray(); // call clearBufferArray function to clear the storaged data from the array
  count = 0; // set counter of while loop to zero

  if (Serial.available()) // if data is available on hardware Serial port, data is coming from PC
  {
    byte b = Serial.read();
    if (b == '*')
      GPRS.write(0x1a);
    else
      GPRS.write(b); // write it to the GPRS shield
  }
}
void clearBufferArray()
{
  for (int i = 0; i < count; i++)
  {
    buffer[i] = NULL;
  }
}





Second Code is the actual code used that if a switch is disconnected and connected it will send an SMS to your phone:

Code: [Select]
#include <SoftwareSerial.h>
SoftwareSerial GPRS(7, 8);
boolean state, lastState;

void setup()
{
  pinMode(2, INPUT_PULLUP);
  state = digitalRead(2);
  lastState = state;

  GPRS.begin(9600);
  Serial.begin(9600);

  GPRS.println("AT");

  delay(1000);
}

void loop()
{
  while (GPRS.available())
  {
    Serial.write(GPRS.read());
  }
  lastState = state;
  state = digitalRead(2);

  if (state != lastState )
  {
    sendSMS();
  }
  delay(500);
}
void sendSMS()
{
  Serial.print("Bike Alert: Your lock has been ");
  Serial.println(state ? "reconnected" : "disconnected");

  GPRS.println("AT+CMGF=1\r");

  delay(500);

  GPRS.println("AT+CMGS=\"+10000000000\"");//Changed phone number for privacy

  delay(500);

  GPRS.print("Bike Alert: Your lock has been ");
  GPRS.println(state ? "reconnected" : "disconnected");
  GPRS.write( 0x1a );
 
  delay(500);

}


Thank You:
Two frustrated High School Engineering Students

dannable

There seems to be issues when using the recent IDE with the Arduino GPRS/GSM shield V2. Try using an older version of the IDE for starters?
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

abbyenginerd411


dannable

Click on the 'Software' tab at the top of the screen, then scroll down to 'Previous Releases'.
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

Go Up