×

SparkFun will be closed May 25, 2015 for Memorial Day. Orders placed after 2pm on Friday the 22nd will ship out on Tuesday. Thanks!

Member #491913

Member Since: November 25, 2013

Country: United States

  • I purchased this to send SMS messages documenting the temperature from a cabin. The goal was to send a daily message with the temperature and send alerts more frequently if the temperature dropped below 50 degrees.

    I had a lot of trouble getting this setup and there is a lack of up-to-date tutorials on the internet. I purchased a prepaid SIM card from T-Mobile. After inserting the SIM card I was unable to communicate with the device and it kept returning:

    +SIND: 1 +SIND: 10
    +SIND: 3 +SIND: 4

    But the +SIND: 11 would not show up. I would send the AT+SBAND=8 command (this is the setting needed for T-Mobile, others use AT+SBAND=7 I believe) but nothing would return. I finally changed “No line ending” to “Both NL & CR” and that fixed it. After changing to “Both NL & CR” it would return “OK” after sending the “AT+SBAND=8” command.

    After this it would successfully return:

    +SIND: 1 +SIND: 10
    +SIND: 11 +SIND: 3 +SIND: 4

    I was then able to send text messages using this script: http://arduino.cc/en/Tutorial/GSMExamplesSendSMS

    The goal was to send SMS messages at regular intervals and I came across a lot of issues with this. I set a loop for debugging and tried to send a variable number every loop. My variable would increase each loop and attempt to send “Test #”. It would successfully send the first message, skip the second message, then send the third. However, the third message would say “Test 2”, not “Test 3” — so it was sending an old message (even though Serial.print would show the correct number).

    I modified the script to print the status of sms.Ready() and sms.endSMS after each attempt to send a message (read more about these here http://arduino.cc/en/Reference/GSM). This showed that the message was getting hung up, would not send, but would send once the sms.endSMS() was called again in the next loop (or after multiple attempts). I created a while loop to keep trying to send a message until endSMS returned “1”, meaning it had successfully send the message (see code below).

    #include <GSM.h>
    
    int count = 0;
    
    int runTime;
    
    #define PINNUMBER ""
    
    // initialize the library instance
    GSM gsmAccess; // include a 'true' parameter for debug enabled
    GSM_SMS sms;
    
    // char array of the telephone number to send SMS
    // change the number 1-212-555-1212 to a number
    // you have access to
    char remoteNumber[20]= “xxxxxxxxxxx”;  
    
    // char array of the message
    // char startMsg[200]= "Temp is ";
    
    
    void setup(void) {
    
        // start serial port
        Serial.begin(9600);
    
        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");
           }
        }
        Serial.println("GSM initialized");
    }
    
    void loop() {
    
        delay(30000);
        ++count;     
        runTime = millis();
    
        Serial.print("Starting to send...");
        sms.beginSMS(remoteNumber);
        sms.print(“Test ");
        sms.print(count);
        sms.print("\n");
        sms.print(runTime);
        sms.endSMS();
        delay(15000);
        Serial.print("\n");
        Serial.print("Sent ");
        Serial.print(count);
        Serial.print("\n");   
    
        while (sms.endSMS() != 1) {
              sms.beginSMS(remoteNumber);
              sms.print("test ");
              sms.print(count);
              sms.print("\n");
              sms.print(runTime);
              sms.endSMS();
              Serial.print(". \n");
              Serial.print("SMS READY: ");
              Serial.print(sms.ready());
              Serial.print("\n");
              Serial.print("SMS SENT: ");
              Serial.print(sms.endSMS());
              Serial.print("\n");
              delay(4000);
        }
    
        Serial.print("\n");
        Serial.print("Count: ");
        Serial.print(count);
        Serial.print("\n");  
    
        Serial.print("\n");
        Serial.print("Run time: ");
        Serial.print(runTime);
        Serial.print("\n");  
    
        Serial.print("SMS READY: ");
        Serial.print(sms.ready());
        Serial.print("\n");
    
        Serial.print("SMS SENT: ");
        Serial.print(sms.endSMS());
        Serial.print("\n");
    
        Serial.print("\n");
        Serial.print("\n");
    
        delay(5000);
    
    }
    

    With the script above, it would successfully send a message each loop (sometimes taking a while to send) but instead of skipping messages, it would send me duplicate messages (i.e. instead of sending “Test 1”, no message, Test 2”, it would send “Test 1”, “Test 2”, Test 2”, Test 3”, “Test 4, “Test 5, ” Test 6”, “Test 6”, etc. This seemed to be very consistent and was out of sync with the actual count.

    I tried everything I could think of to get it to send each individual message in order (clearing message storage each loop, resetting the Arduino each loop, changing the storage from SIM to the device, etc.) with no luck. Different methods provided different results, but nothing would send the correct message in order constantly.

    I’m not sure if this is a bug with my specific device, the T-Mobile network, or whatever — but I was unable to resolve the issue.

    Hope this helps someone!

No public wish lists :(