Regarding Sending SMS

Everything about programming the platform and using the Waspmote API
Post Reply
Pankaj
Posts: 29
Joined: Tue Oct 04, 2016 9:55 am

Regarding Sending SMS

Post by Pankaj » Mon Oct 02, 2017 11:40 am

Hi, I have a 4G sim in my device but unable to send SMS after trying alot. always received same output. PSB -

H#
Start program
1. 4G module ready...
2.1. Error calling 'configureSMS' function. Code: 1
2.2. Sending SMS...error. Code: 5
3. Switch OFF 4G module
4. Enter deep sleep...

Pankaj
Posts: 29
Joined: Tue Oct 04, 2016 9:55 am

Re: Regarding Sending SMS

Post by Pankaj » Tue Oct 03, 2017 6:50 am

In waiting of your reply...

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Regarding Sending SMS

Post by libelium-dev » Tue Oct 03, 2017 9:59 am

Hi,

Could you please run this code? What output do you get? Just replace xxxxxx by your phone number

Code: Select all

uint8_t answer, pin;

void setup()
{
  USB.ON();

  // define object for UART0
  WaspUART uart = WaspUART();

    // init object in SOCKET1
    uart.setUART(SOCKET1);
    uart.setBaudrate(115200);

    // switch module OFF
    uart.closeUART();
    pinMode(GPRS_PW, OUTPUT);
    digitalWrite(GPRS_PW, LOW);
    delay(500);

    // select multiplexer
    Utils.setMuxSocket1();

    // begin serial communication
    uart.beginUART();

    // Power on the module
    digitalWrite(GPRS_PW, LOW);
    delay(500);
    digitalWrite(GPRS_PW, HIGH);
    delay(15000);
    serialFlush(SOCKET1);

    // send AT command
    answer = uart.sendCommand((char*)"AT\r", "OK", 1000);

    // send CPIN command
    pin = uart.sendCommand((char*)"AT+CPIN?\r", "+CPIN: READY", "ERROR", 1000);

    // check response:
    if (answer == 1)
    {
      USB.println(F("4G module is plugged on socket 1"));
      if (pin == 1){
        USB.println(F("SIM card: OK"));
      }
      else {
        USB.println(F("SIM card: ERROR"));
      }

      answer = uart.sendCommand((char*)"AT+CMGF=1\r", "OK", 1000);
      if (answer == 1){
        USB.println(F("SMS configured: OK"));
      }
      else {
        USB.println(F("SMS configured: ERROR"));
      }

      // ************************************************************************************
      // **** REPLACE xxxxxxxx BY YOUR PHONE NUMBER IN THE NEXT LINE ****
      // ************************************************************************************
      answer = uart.sendCommand((char*)"AT+CMGS=\"xxxxxxx\"\r", ">");
      if (answer == 1){
        USB.print(F("Sending SMS... "));

        char command_buffer[5];
        printString("Hello", 1);
        command_buffer[0] = 0x1A;
        command_buffer[1] = '\0';
        
        answer = uart.sendCommand(command_buffer, "OK");
        if (answer == 1){
          USB.println(F("DONE"));
        }
        else {
          USB.println(F("ERROR"));
        }
           
      }
      else {
        USB.println(F("Sending SMS: ERROR"));
      }

      
    }
    else{
      USB.println(F("No 4G module detected"));
    }

}

void loop()
{
}
Regards

Pankaj
Posts: 29
Joined: Tue Oct 04, 2016 9:55 am

Re: Regarding Sending SMS

Post by Pankaj » Tue Oct 03, 2017 11:33 am

After running the same. Received following output -

H#
4G module is plugged on socket 1
SIM card: OK
SMS configured: OK
Sending SMS... ERROR


Now what next ?

Pankaj
Posts: 29
Joined: Tue Oct 04, 2016 9:55 am

Re: Regarding Sending SMS

Post by Pankaj » Tue Oct 03, 2017 11:36 am

Is my way to given phone right ???? Pl confirm-

answer = uart.sendCommand((char*)"AT+CMGS=\"9406971272\"\r", ">");

or i'll have to add 00 or +91 before my mobile no ?

Pankaj
Posts: 29
Joined: Tue Oct 04, 2016 9:55 am

Re: Regarding Sending SMS

Post by Pankaj » Wed Oct 04, 2017 8:07 am

In waiting of your reply..

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Regarding Sending SMS

Post by libelium-dev » Wed Oct 04, 2017 3:55 pm

Hi,

Our colleagues from tech said us that you solved the issue. We are glad to hear that!

Regards

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest