Make Voice Call using Arduino

Make Voice Call

This sketch connects a voice call from your GSM shield and Arduino to a remote phone number entered through the serial monitor. You’ll need to attach a speaker and microphone to hear the connected phone and send your voice.

Make Voice Call First, import the GSM library

#include <GSM.h>

SIM cards may have a PIN number that unlocks their functionality. Define the PIN for your SIM. If your SIM has no PIN, you can leave it blank :

#define PINNUMBER ""

Initialize instances of the classes you’re going to use. You’re going to need both the GSM and GSMVoiceCall class.

 

GSM gsmAccess;
GSMVoiceCall vcs;

Create some variables to store the phone number you want to call :

 

String remoteNumber = “”;
char charbuffer[20];

In setup, open a serial connection to the computer. You’ll use this to send a phone number to the Arduino. After opening the connection, send a message to the Serial Monitor indicating the sketch has started.

 

void setup(){

Serial.begin(9600);
Serial.println(“Make Voice Call”);

Create a local variable to track the connection status. You’ll use this to keep the sketch from starting until the SIM is connected to the network :

 

boolean notConnected = true;

Connect to the network by calling gsmAccess.begin(). It takes the SIM card’s PIN as an argument. By placing this inside a while() loop, you can continually check the status of the connection. When the modem does connect, gsmAccess() will return GSM_READY. Use this as a flag to set the notConnected variable to true or false. Once connected, the remainder of setup will run.

 

Circuit

Make Voice Call  Circuit (1)

a

image of the Arduino GSM Shield on top of an Arduino Uno

while(notConnected)
{
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
notConnected = false;
else
{
Serial.println(“Not connected”);
delay(1000);
}
}

Code

First, import the GSM library

#include <GSM.h>

SIM cards may have a PIN number that unlocks their functionality. Define the PIN for your SIM. If your SIM has no PIN, you can leave it blank :

#define PINNUMBER ""

Initialize instances of the classes you’re going to use. You’re going to need both the GSM and GSMVoiceCall class.


Leave a Comment

Your email address will not be published. Required fields are marked *