Table of Contents
Introduction
Hey guys, we are back with another new post. Do you know what a GSM module is? Well in this article we are going to make calls and message using Arduino and the gsm module. If you don’t know how a GSM module work with Arduino then goes through it first. Make the connections properly and then upload the given code to the Arduino. You can also check out more articles on Arduino and IoT published by us.
Description
- In this project we can make a phone call or send an SMS to any one using a GSM module in this arduino gsm project.
- There are two push buttons, you can press the first push button and make a phone call.
- For this you have you provide the mobile number on which you want to make a call.
- You can also view the status of the executing task on the serial monitor screen.
- The LED will glow and then turn off automatically once you press the push button which indicates that the task is under process .
- You can also check the digitalize GSM based forest fire alert system made by us.
Components Required in GSM project
- Arduino UNO
- Sim 900 GSM module
- Two push buttons
- 220 ohm resistors
- Two LEDs
- Jumper wires and a breadboard
- USB cable for uploading the code
Arduino with GSM Module Circuit
Arduino UNO | LED 1 | LED 2 | 220 Ohm Resistor |
4 Pin | Anode Terminal | ||
5 Pin | Anode Terminal | ||
GND | Terminal 1 | ||
Cathode Terminal | Cathode Terminal | Terminal 2 | |
Arduino UNO | Button 1 | Button 2 | 220 Ohm Resistor |
7 Pin | Terminal 1 | ||
8 Pin | Terminal 1 | ||
GND | Terminal 2 | Terminal 2 | Terminal 1 |
Terminal 1 | Terminal 2 | ||
Terminal 1 | Terminal 2 |
- Connect a 12 volts 2 amp DC supply to the GSM module.
- Join the digital-10 pin of the Arduino with the Tx pin of the GSM module.
- Connect the GND pin of the Arduino with the GND pin of the GSM module.
- Attach the digital-11 pin of the Arduino with the Rx pin of the GSM module.
- Now take two LEDs and join their negative legs with the GND pin of the Arduino via a 220-ohm resistor.
- Connect the positive leg of the one LED with the digital-4 pin of the Arduino and the positive leg of the other LED with the digital-5 pin of the Arduino.
- Then take a push button and connect its one pin with the 5 volts pin of the Arduino. Join the other pin of the push button with the digital-8 pin of the Arduino.
- Do the same for the second push button and connect it with the digital-7 pin of the Arduino.
- Your circuit is complete now.
- Also you can check the GSM based Home Automation.
Code for gsm and Arduino
NOTE: Please upload this code to the Arduino. You have to install <SoftwareSerial.h> library first. If you don’t know how to add a zip library to the Arduino IDE then do check it out here.
// TECHATRONIC.COM
// Download Library of SoftwareSerial link given
// https://github.com/PaulStoffregen/SoftwareSerial
#include<SoftwareSerial.h>
SoftwareSerial gsm(10,11); // SoftSerial( RX , TX );
// 10 pin connect to TX of GSM SIM 900 Module
// 11 pin connect to RX of GSM SIM 900 Module
const int buttonPin1 = 7; // Push Button 1
const int buttonPin2 = 8; // Push Button 2
int buttonState1 = 0;
int buttonState2 = 0;
void setup()
{
delay(10000);
Serial.begin(9600);
gsm.begin(9600);
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(5,OUTPUT); // LED1 pin D5
pinMode(4,OUTPUT); // LED2 pin D4
}
void loop()
{
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
if (Serial.available()>0)
switch(Serial.read())
{
case 'r':
RecieveMessage();
break;
}
if (gsm.available()>0)
Serial.write(gsm.read());
if (buttonState1 == HIGH)
{
gsm.println("ATD7007651787;"); //replace x by your number
delay(100);
digitalWrite(5,HIGH); // LED1 ON
gsm.println("ATH");
delay(2000);
Serial.println("calling.....");
digitalWrite(5,LOW); // LED1 OFF
}
if (buttonState2 == HIGH)
{
Serial.println ("Sending Message");
digitalWrite(4,HIGH); // LED2 ON
gsm.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
delay(1000);
Serial.println ("Set SMS Number");
gsm.println("AT+CMGS=\"7007651787\"\r"); //Mobile phone number to send message, replace x by your number
delay(1000);
Serial.println ("Set SMS Content");
gsm.println("Techatronic.com");// Messsage content
delay(100);
Serial.println ("Finish");
gsm.println((char)26);// ASCII code of CTRL+Z
delay(1000);
Serial.println ("Message has been sent ");
digitalWrite(4,LOW); // LED2 ON
}
}
void RecieveMessage()
{
Serial.println ("gsm RECEIVE SMS");
delay (1000);
gsm.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
delay(1000);
Serial.write ("Unread Message done");
}
We hope that you liked this call and message using arduino and gsm module project and understand it’s working completely. If you have any doubts regarding this gsm project then feel free to post them in the comments section given below. Also, do check out more articles on Arduino and Raspberry Pi.
Thanks for reading.
Hi If got a “sim900 gsm/gsm shield development board quad-band module” and I want it to be able to use 4 buttons to call 4 deferent callers. I cant find a Code on it on the net or YouTube, is there a possibility you can help my. I’m super new at Arduino.