Go Down

Topic: Need help sending an SMS message using a SIM900 Shield! (Read 55 times) previous topic - next topic

clr024

Hello-

I am currently working on a school project and am struggling with the code to send out a text using the SIM900 GPRS shield I purchased. 


the code is below.  We bought a standard SIM card at the at&t store and it is activated through the IMEI number on the device so that shouldnt be the issue.  As far as the code, in the serial monitor they only thing that will show up is the SMS Message Sender...nothing further.  Help Please!


#include <GSM.h>

#define PINNUMBER ""

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

 
boolean notConnected = true;
  while (notConnected) {
    if (gsmAccess.begin(PINNUMBER) == GSM_READY) {
      notConnected = false;
      Serial.println("GSM initialized");
    } else {
      Serial.println("Not connected");
      delay(1000);
    }
  }

 
}

void loop() {

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

  // sms text
  Serial.print("Now, enter SMS content: Hello! ");
  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 = '\0';
        Serial.flush();
        return 0;
      }
      if (inChar != '\r') {
        result = inChar;
        i++;
      }
    }
  }
}

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy