1
votes

I'm trying to get my arduino GSM shield working with the example "Send SMS" code provided. However, when I upload and compile the program, the serial monitor displays "SMS Messages Sender" and nothing else occurs.

I am using Arduino uno r3 and gsm sim 900. powered gsm with 5V 1.5A. I have connected arduino pins 7&8 to pins 7&8 of gsm. I have connected the gsm to ground too.

When I use SoftwareSerial.h it works. But I wish to use GSM.h library which now isn't working. Any help please

 // include the GSM library
 #include <GSM.h>

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

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

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

}

i expected this code to enable me to receive message and i can modify it to store the message in variables

1

1 Answers

1
votes

Your problem is probably the wiring.

Your board (Arduino UNO R3) has its UART (the one you intend to use when you define Serial.begin(9600) on pins 0 RX and 1 TX. See here for the schematic and picture below (top right corner with tags TX and RX).

Software emulated serial works because you're defining pins 7 and 8 to be the emulated UART TX and RX signals.

Arduino UNO R3 board top side