Send a message from Arduino to your phone 📲

If your Arduino supports a phone chip, it means that you can use it in a variety of applications where you need to connect a SIM card to send and receive messages or make calls.


The SIM900 GSM module enables you to provide your Arduino with a SIM card to work like a cell phone!


This opens up a lot of ideas that you can implement, as you can control a lot of things from anywhere in the world. You can also use this system to have a message sent to your phone when a push button is pressed, and this is exactly what we will do in this tutorial!


Overview


This project will help you understand how to interface the SIM900 GSM module with your Arduino. You can use the SIM900 GSM module in many other advanced projects, like receiving important data from a sensor or monitoring a system status over a large communication range.


Let’s discover more together!


Getting the items


For this project you will need the following components you can buy them from our store.

Sale Off
Voltaat Arduino Uno R3 (Voltaat Version)
45 QAR
Sale Off
Voltaat SIM900 GSM Shield for Arduino
79 QAR
Sale Off
Voltaat AC/DC Power Adapter  - 5V 3A (Barrel Jack)
35 QAR
Sale Off
Voltaat Half-size Breadboard
15 QAR

Make sure you also have a breadboard and jumper wires to connect everything together

Sale Off
Voltaat Push button Switch (5 Pack) - 12mm
2 QAR
Sale Off
Voltaat 1/4 Watt Resistor (20 Pack)
2 QAR
Sale Off
Voltaat Jumper Wires - Male to Male (40 Pack)
10 QAR

Wiring it up


Before you begin wiring the shield with your Arduino, let's learn about the SIM900 GSM shield and setup it so that it works properly with you. The following image shows the most important components of the SIM900 GSM shield. Understanding the different parts of the shield will let you understand this tutorial much better.


You will also need a 5V/2A DC adapter to supply the shield with the necessary power through the DC jack. You must check the specifications of the adapter well.


Also, remember to insert the SIM card into the SIM card slot at the bottom of the shield and turn off the PIN lock before you start connecting it to the Arduino.


The shield has a power supply selection switch, which you must turn on when you use the adaptor. To startup the module, you must also push the power key in the side or 2 or 3 sec so it can connect to the network.


LED Status Indicators:


The SIM900 GSM/GPRS shield has three LEDs that show connectivity and power status. You may obtain visual feedback on what's going on with the shield by observing these LEDs.


PWR (power LED): This LED indicates that the shield is receiving power.


Status: This LED indicates SIM900’s working status. If this LED is on, the chip is in working mode.


Netlight: This LED indicates the status of your cellular network. It’ll blink at various rates to show what state it’s in.


Netlight status:

off: The SIM900 chip is not running.

64ms on, 800ms off: The SIM900 chip is running but not registered to the cellular network yet.

64ms on, 3 seconds off: The SIM900 chip is registered to the cellular network & can send/receive voice and SMS.

64ms on, 300ms off: The GPRS data connection you requested is active.


Wiring with Arduino:


You must make sure the jumper cap is connected as shown in the picture on the serial port select.


Connections from the Arduino to the breadboard:

• Arduino pin GND → Breadboard ground line

• Arduino pin 5V → Breadboard 5V line


Connections from the sim900 GSM module:

• GND pin→ Breadboard ground line

• TXD pin → Arduino pin 7

• RXD pin → Arduino pin 8


Connections from the push button:

• First pin→ Breadboard 5v line

• Second pin→ Arduino pin 2

• Second pin→10KΩ resistor → Breadboard GND line


Coding


The function of this code is to send an SMS message, "This message from your Arduino Uno," from your Arduino to your cell phone, The code is simple and straightforward; it may help you with more complex applications.


Let's have a look at the code, and then you should be able to understand it once you follow the instructions and read the comments.


/*
Voltaat learn (http://learn.voltaat.com/)
Link for full tutorial: https://bit.ly/3WDhJip

Tutorial: Send a message from Arduino to your phone

The function of this code is to send an SMS message,
"This message from your Arduino Uno,"
from your Arduino to your cell phone,
The code is simple and straightforward;
it may help you with more complex applications.

Connections from the Arduino to the breadboard:
• Arduino GND pin → Breadboard ground line
• Arduino 5V pin → Breadboard 5V line

Connections from the sim900 GSM module:
• TWO GND pin→ Breadboard ground line
• TXD pin → Arduino pin 7
• RXD pin → Arduino pin 8

Connections from the push button:
• First pin→ Breadboard 5v line
• Second pin→ Arduino pin 2
• Second pin→10KΩ resistor → Breadboard ground line
*/


//Allows serial communication on other digital pins of an Arduino board
#include < SoftwareSerial.h >

//Define push button to arduino digital pin 2
#define pushButton 2

//Configure software serial port with digital pins 7,8 (TR,RX)
SoftwareSerialSIM900(7,8);

//Commands inside void setup run once
void setup(){

//Arduino communicates with SIM900 GSM shield at a baud rate of 9600 (9600 bits per second)
SIM900.begin(9600);

//Start the serial monitor at 9600 baud rate (9600 bits per second)
Serial.begin(9600);

//pushButton is defined as an input
pinMode(pushButton,INPUT);

// Give time to your GSM shield log on to network
//delay(20000);


}

//Commands inside void setup run forever
void loop()
{
//If you press the push button
if(digitalRead(pushButton)==HIGH){

// Send the SMS
sendSMS();
Serial.println("This Message from your Arduino Uno");
delay(15000);
}
}

void sendSMS(){
// AT command to set SIM900 to SMS mode
SIM900.print("AT+CMGF=1\r");
delay(100);

//Replace the X's WITH THE recipient's mobile number - use the international fromat
SIM900.println("AT+CMGS=\"+201068421369\"");
delay(100);

//Send "This Message from your Arduino Uno" to your phone nubmer
SIM900.println("This Message from your Arduino Uno");
delay(100);
//End AT command with a ^Z, ASCII code 26
SIM900.println((char)26);
delay(100);
SIM900.println();
//Give module time to send SMS
delay(5000);
}

Testing it out



Now you must have correctly wired the SIM900 GSM module to the Arduino as we explained in the wiring section, as well as uploaded the code to your Arduino board.


When you press the push button, you will notice that your mobile device receives the following message: "This message from your Arduino UNO."


Resources 


Arduino Code

Related Tutorials


In this tutorial, we will use the PIR sensor with Arduino and the SIM900 GSM shield to send a message to your phone that alerts you when someone enters your house!


In this tutorial, we will learn more about bush buttons and how to use them. We'll use the push button in a simple project to control the Arduino's internal LED and print the current state of the button directly on your commuter.


In this tutorial, we will print data on your LCD using the Arduino. It is basic and straightforward. Let's find out more together!