How to use sendSMS sketch?

Hi, everyone, I am trying to use the sketch (sendSMS) to send a message to my phone. But as the results shows, my phone didn't receive it. Do anybody know how to send an SMS by using this sketch or using AT command? Thanks in advance!

11:40:17.100 -> SMS Messages Sender
11:40:24.845 -> NB initialized
11:40:24.845 -> Enter a mobile number: +4407762311049
11:40:45.409 -> Now, enter SMS content: SENDING
11:41:11.497 -> 
11:41:11.497 -> Message:
11:41:11.497 -> 313131
11:44:11.518 -> 

Please post your code following the advice given in the link below

Here is the code

 SMS sender

 This sketch, for the MKR NB 1500 board, sends an SMS message
 you enter in the serial monitor. Connect your Arduino with the
 SIM card, open the serial monitor, and wait for
 the "READY" message to appear in the monitor. Next, type a
 message to send and press "return". Make sure the serial
 monitor is set to send a newline when you press return.

 * MKR NB 1500 board
 * Antenna
 * SIM card that can send SMS

 created 25 Feb 2012
 by Tom Igoe

// Include the NB library
#include <MKRNB.h>

#include "arduino_secrets.h" 
// Please enter your sensitive data in the Secret tab or arduino_secrets.h
// PIN Number

// initialize the library instance
NB nbAccess;
NB_SMS sms;

void setup() {
  // initialize serial communications and wait for port to open:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only

  Serial.println("SMS Messages Sender");

  // connection state
  bool connected = false;

  // Start NB module
  // If your SIM has PIN, pass it as a parameter of begin() in quotes
  while (!connected) {
    if (nbAccess.begin(PINNUMBER) == NB_READY) {
      connected = true;
    } else {
      Serial.println("Not connected");

  Serial.println("NB initialized");

void loop() {

  Serial.print("Enter a mobile number: ");
  char remoteNum[20];  // telephone number to send SMS

  // SMS text
  Serial.print("Now, enter SMS content: ");
  char txtMsg[200];

  // send the message

  Read input serial
int readSerial(char result[]) {
  int i = 0;
  while (1) {
    while (Serial.available() > 0) {
      char inChar =;
      if (inChar == '\n') {
        result[i] = '\0';
        return 0;
      if (inChar != '\r') {
        result[i] = inChar;

I tried to use AT+command to realize this function, the problem is when i am using AT+CGSM, after typing in my destination address and , I input the message I want to send and , I failed here. No response from my modem.

+CMGF: 1


> 31

What's wrong with it?

I'm throwing this out since no one has replied. I am using a different cellular modem, but in order to send the message, a Crtl+Z is used. So with my hardware, once I enter the phone number and receive the > response, I enter the message, then Ctrl+Z to send. This does not work with the serial monitor in the Arduino IDE. I connect using TeraTerm and it works fine.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.