Lesson 24: How to Send SMS

 

Written by Jonathan Sim

You can find this lesson and more in the Arduino IDE (File -> Examples -> Andee). If you are unable to find them, you will need to install the Andee Library for Arduino IDE.

Works on Android
Did you know that you can use the Annikken Andee to send an SMS through the connected smartphone to another recipient?

This is very useful if you want to monitor certain processes and be notified via SMS while you're out.

Here's how you can get Annikken Andee to send the SMS!

Contents

Compatibility

Unfortunately with the strict security feature imposed by Apple. You are unable to send SMS out through your iOS devices.

Important Notice

You could programme Arduino x Annikken Andee to automatically send an SMS when sensor readings are of a certain level. But if you intend to do that, be sure to use a flag to prevent the Arduino x Annikken Andee from automatically sending repeatedly.

Top of the Code

#include <SPI.h>
#include <Andee.h>

// We'll use a button to send the message
AndeeHelper sendMessage;
AndeeHelper SMSobject; // The message and recipient must be declared as an object

// You can use the text input button to get the user to set the
// recipient number and even the message itself!
char messageRecipient[] = "+6587654321";
char message[] = "Hello World!";

setup()

void setup()
{
  Andee.begin();  // Setup communication between Annikken Andee and Arduino
  Andee.clear();  // Clear the screen of any previous displays
  setInitialData(); // Define object types and their appearance
}

setInitialData()

void setInitialData()
{
  sendMessage.setId(0);
  sendMessage.setType(BUTTON_IN);
  sendMessage.setLocation(0,0,FULL);
  sendMessage.setTitle("Send SMS");
  
  SMSobject.setId(1);
  SMSobject.setType(SMS_SENDER); // Sets object as an SMS object
  SMSobject.setRecipient(messageRecipient);
  SMSobject.setMessage(message);
}

loop()

void loop()
{
  if( sendMessage.isPressed() ) // When user presses the send button on phone
  {
    sendMessage.ack(); // Acknowledge button press
    SMSobject.send(); // Sends the SMS to the recipient
  }

  sendMessage.update();
  // Do not update SMS objects!
  
  delay(500); // Always leave a short delay for Bluetooth communication
}
comments powered by Disqus