Go Down

Topic: Ardunio Uno R3 with Seeed GSM Shield v1.0 Phone working, but no SMS (Read 326 times) previous topic - next topic

I am trying to setup my Ardunio Uno R3 with a Seeed GSM Shield. I am getting an error when trying to dial a number in the United States. I am at my wits end on what could be the issue. If I put in an international number it appears to be working, but if I use a US number I get error 0.

Output:
Starting...
AT
AT+CPIN=****
Connecting to the network...
AT+CREG?
Setting SMS mode...AT+CMGF=1
Sending SMS
AT+CMGS="5672750001"b
error 0

If I add a +1 it strips off the last 0 but it acts like it completes?
Starting...
AT
AT
AT+CPIN=****
Connecting to the network...
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
Setting SMS mode...AT+CMGF=1
Sending SMS
AT+CMGS="+1567275000?"
Test-Arduino-Hello World

Sent

Any help would be great!.. Code below...

int8_t answer;
int onModulePin= 2;
char aux_string[20];
char phone_number[]="+15672750001";

void setup(){

    pinMode(onModulePin, OUTPUT);
    Serial.begin(115200);   
       
    Serial.println("Starting...");
    power_on();
   
    delay(3000);
   
    // sets the PIN code
    sendATcommand("AT+CPIN=****", "OK", 2000);
   
    delay(3000);
   
    Serial.println("Connecting to the network...");

    while( (sendATcommand("AT+CREG?", "+CREG: 0,1", 500) || sendATcommand("AT+CREG?", "+CREG: 0,5", 500)) == 0 );

    Serial.print("Setting SMS mode...");
    sendATcommand("AT+CMGF=1", "OK", 1000);    // sets the SMS mode to text
    Serial.println("Sending SMS");
   
    sprintf(aux_string,"AT+CMGS=\"%s\"", phone_number);
    answer = sendATcommand(aux_string, ">", 2000);    // send the SMS number
    if (answer == 1)
    {
        Serial.println("Test-Arduino-Hello World");
        Serial.write(0x1A);
        answer = sendATcommand("", "OK", 20000);
        if (answer == 1)
        {
            Serial.print("Sent ");   
        }
        else
        {
            Serial.print("error ");
        }
    }
    else
    {
        Serial.print("error ");
        Serial.println(answer, DEC);
    }

}


void loop(){

}

void power_on(){

    uint8_t answer=0;
   
    // checks if the module is started
    answer = sendATcommand("AT", "OK", 2000);
    if (answer == 0)
    {
        // power on pulse
        digitalWrite(onModulePin,HIGH);
        delay(3000);
        digitalWrite(onModulePin,LOW);
   
        // waits for an answer from the module
        while(answer == 0){     // Send AT every two seconds and wait for the answer
            answer = sendATcommand("AT", "OK", 2000);   
        }
    }
   
}

int8_t sendATcommand(char* ATcommand, char* expected_answer, unsigned int timeout){

    uint8_t x=0,  answer=0;
    char response[100];
    unsigned long previous;

    memset(response, '\0', 100);    // Initialice the string
   
    delay(100);
   
    while( Serial.available() > 0) Serial.read();    // Clean the input buffer
   
    Serial.println(ATcommand);    // Send the AT command


    x = 0;
    previous = millis();

    // this loop waits for the answer
    do{
        if(Serial.available() != 0){    // if there are data in the UART input buffer, reads it and checks for the asnwer
            response
  • = Serial.read();
                x++;
                if (strstr(response, expected_answer) != NULL)    // check if the desired answer is in the response of the module
                {
                    answer = 1;
                }
            }
        }while((answer == 0) && ((millis() - previous) < timeout));    // Waits for the asnwer with time out

        return answer;
    }




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