Category: GSM


SIM808 is all in one module with GSM , GPRS,GPS & BLUETOOTH.SIM808 is advanced compared to SIM908.

SIM808 has GNSS receiver which enables easy GPS FIX.

In this post we explore how to parse GPS data ( without using TNYGPS library) & send it through inbuilt GSM

SIM 808 has 2 antenna sockets one  for GSM  & other for GPS. A stub antenna is used for GSM & a magnetic external patch antenna is used for GPS.

Do not interchange these 2 antennae. The antenna socket nearest to SIM808 chip is for GPS.

IMG_20180502_112731

 

Connection between Arduino UNO & SIM808 is simple.

Gnd to Gnd

Tx of SIM808 to Rx of Arduino (soft serial digital pin 7)

Rx of SIM808 toTx of Arduino (soft serial digital pin 8)

A separate power adapter of 12v 2amp is required for SIM808 board.

Insert valid SIM on to the slot at the  back of SIM808 board

Power on & notice the NETWORK LED .It blinks fast initially & when it gets network it blinks slowly ,once per second.

 

sim808_2_ok

 

We’ll use a serial to usb cable to monitor SIM808 serial port. We can also test AT commands through this port ,before uploading Arduino code.

Connect the cable to PC & note the COM port allotted under Device Manager .

Another COM port is allotted to Arduino board.Note this also.

img1

Before uploading code on to Arduino , let us check the AT commands.

For this open a PUTTY Terminal & select SERIAL.

Feed in the COM port of the USB-RS232 cable &baud rate as 9600. & click open.

Image 1

 

Type in AT ,the SIM808 module responds with OK.

ATD is the command to dial a number

AT+CMGF=1 , AT+CMGS=”phone no.” are for sending SMS.

All GSM related commands are similar to that of SIM800 or SIM900.

Some cases of empty SMS delivery is reported .i.e you receive SMS on mobile but has got no message.

To solve this problem set the following parameter.

AT+CSMP=17,167,0,0

This has to be done before you set the module to Text mode using AT_CMGF=1

Image 2

GPS related AT Commands are similar to that of SIM 908.

 

GPS_AT

AT+CGPSPWR=1 sets the GPS engine ON

AT+CGPSRST=0 gives a COLD RESTART to GPS

AT+CGSINF=0 returns a single NMEA sentence of GPS.

AT+CGPSSTATUS?   returns the Status of GPS whether it has got FIX or not.

If GPS has not received FIX , the NMEA sentence will read all  0 s

Relocate the GPS antenna & wait for some time to get a FIX. If the GPS antenna faces open SKY you get a FIX within seconds.

Image 3

Once GPS gets a FIX , AT+CGPSINF=0 returns a valid NMEA sentence.

AT+CGPSINF=32  returns a single GPRMC sentence

 

Image 4

 

Now let us see the SIM808 specific GPS commands

SIM808 has inbuilt GNSS receiver

AT+CGNSPWR=1  turns on the GNSS power

AT+CGNSSEQ=”RMC”  parses the NMEA sentence related to GPRMC

Now issuing the command AT_CGNSINF returns a valid NMEA  GPRMC sentence

SIM808_GPS

 

Image 5

 

Now let us upload the code that parses RMC data &sends SMS with google maps link

 

Arduino code Download :

 

http://www.alselectro.com/files/SIM808.zip

 

—————————————————

#include <SoftwareSerial.h>
SoftwareSerial sim808(7,8);

char phone_no[] = “xxxxxxx”; // replace with your phone no.
String data[5];
#define DEBUG true
String state,timegps,latitude,longitude;

void setup() {
sim808.begin(9600);
Serial.begin(9600);
delay(50);

sim808.print(“AT+CSMP=17,167,0,0”);  // set this parameter if empty SMS received
delay(100);
sim808.print(“AT+CMGF=1\r”);
delay(400);

sendData(“AT+CGNSPWR=1”,1000,DEBUG);
delay(50);
sendData(“AT+CGNSSEQ=RMC”,1000,DEBUG);
delay(150);

}

void loop() {
sendTabData(“AT+CGNSINF”,1000,DEBUG);
if (state !=0) {
Serial.println(“State  :”+state);
Serial.println(“Time  :”+timegps);
Serial.println(“Latitude  :”+latitude);
Serial.println(“Longitude  :”+longitude);

sim808.print(“AT+CMGS=\””);
sim808.print(phone_no);
sim808.println(“\””);

delay(300);

sim808.print(“http://maps.google.com/maps?q=loc:”);
sim808.print(latitude);
sim808.print(“,”);
sim808.print (longitude);
delay(200);
sim808.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(200);
sim808.println();
delay(20000);
sim808.flush();

} else {
Serial.println(“GPS Initializing…”);
}
}

void sendTabData(String command , const int timeout , boolean debug){

sim808.println(command);
long int time = millis();
int i = 0;

while((time+timeout) > millis()){
while(sim808.available()){
char c = sim808.read();
if (c != ‘,’) {
data[i] +=c;
delay(100);
} else {
i++;
}
if (i == 5) {
delay(100);
goto exitL;
}
}
}exitL:
if (debug) {
state = data[1];
timegps = data[2];
latitude = data[3];
longitude =data[4];
}
}
String sendData (String command , const int timeout ,boolean debug){
String response = “”;
sim808.println(command);
long int time = millis();
int i = 0;

while ( (time+timeout ) > millis()){
while (sim808.available()){
char c = sim808.read();
response +=c;
}
}
if (debug) {
Serial.print(response);
}
return response;
}

——————————————————-

Following is the serial port monitor screenshot.

Once the command AT+CGNSINF is issued ,it returns a valid RMC sentence.

The latitude,longitude is then parsed

SMS is then sent with parsed data appended to google maps link.

Image 7

 

Pleae note Code is written to send SMS every 20 secs.

phone1

phone6

VIDEO :

 

 

blog_image

GSM controlled RELAY with Arduino

In this post we ‘ll control a relay through GSM by sending message.

Parts required  :

GSM SIM900 or SIM800

Relay board  (12v board with active HIGH , i.e if you send HIGH from Arduino then Rlay will be ON)

Arduino UNO

DC connector cable & 12v adapter

We’ll make it simple   By sending SMS $a1 Relay is made ON

BY sending SMS $a0 the Relay is switched OFF

GSM SIM900 board is used in this demo , but you can use SIM800 also. A valid SIM to be inserted in to the slot on GSM board. Do not use 4G SIM like JIO , as the SIM 800 / 900 is 2G /3G enabled.

GSM2

 

A 1 channel relay board is used which is a 12v relay & needs a HIGH to enable the relay. Note that if you use a relay board with opto coupler , it needs a LOW to switch ON the relay .In this demo we use a 12v , HIGH enable relay which uses a simple NPN transistor to switch ON the relay.

 

GSM3

i.e from Arduino Digital pin you send a HIGH to switch ON the relay.

 

Connection

Digital pin 8 of Arduino is connected to Relay board INPUT

Rx of Arduino to Tx of GSM , Tx of Arduino to Rx of GSM

GND of Arduino to GND of GSM

12V Adapter is used as power source. Power socket is provided on GSM & Arduino boards . DC connectors are used to power up GSM & Arduino .As Arduino has 5v regulator on board you can safely use 12v at power socket.

The +ve pin of Relay board is looped with +12v of adapter & -ve to GND of Relay board.

Ensure that all GND pins are made common , that of GSM , Arduino & Relay boards.

 

GSM5

 

Following is the Arduino code to be uploaded. Remember to disconnect wires at Rx/Tx while uploading code to Arduino.

You can Download the Code HERE

 

——————————

char inchar; // variable to store the incoming character

int Relay = 8;

 

void setup()

{

pinMode(Relay, OUTPUT);

digitalWrite(Relay, LOW);

Serial.begin(9600);

delay(2000);

Serial.println(“AT+CMGF=1”); // set mode to text

delay(100);

Serial.println(“AT+CNMI=2,2,0,0,0”);

// just to get a notification when SMS arrives &direct out SMS upon receipt to the GSM serial out

delay(100);

}

 

void loop()

{

//If a character comes in from the GSM…

if(Serial.available() >0)

{

inchar=Serial.read();

if (inchar==’$’)

{

delay(10);

inchar=Serial.read();

if (inchar==’a’)

{

delay(10);

inchar=Serial.read();

if (inchar==’0′)

{

digitalWrite(Relay, LOW);

Serial.println(“Relay OFF”);

}

else if (inchar==’1′)

{

Serial.println(“Relay ON”);

digitalWrite(Relay, HIGH);

}

delay(100);

Serial.println(“AT+CMGD=1,4”); // delete all SMS

delay(2000);

}

}

}

}

———————————–

A char variable inchar is used to store the incoming SMS

The relay pin is defined as DIGITAL pin 8

Inside setup function , the Relay pin is declared as OUTPUT using pinMode & then initially it is made LOW

Serial.begin(9600) ; starts Serial communication at baud 9600.

AT+CMGF=1 confirms TEXT mode operation of GSM .Notice the use of SerialPrintln which provides a Carriage Return

Serial.println(“AT+CNMI=2,2,0,0,0”);

// just to get a notification when SMS arrives &direct out SMS upon receipt to the GSM serial out

The AT command +CNMI is used to specify how newly arrived SMS messages should be handled. You can tell the GSM/GPRS modem or mobile phone either to forward newly arrived SMS messages directly to the PC, or to save them in message storage and then notify the PC about their locations in message storage.

Syntax: AT+CNMI=<mode>,<mt>,<bm>,<ds>,<bfr>

Description:

This command selects the procedure for message reception from the network.

Values:

<mode>: controls the processing of unsolicited result codes

Note: Only <mode>=2 is supported.

<mt>: sets the result code indication routing for SMS-DELIVERs. Default is 0.

0: No SMS-DELIVER indications are routed.

1: SMS-DELIVERs are routed using unsolicited code: +CMTI: “SM”,<index>

2: SMS-DELIVERs (except class 2 messages) are routed using unsolicited code: +CMT:…….

AT+CNMI is used anyway just to get a notification when a SMS arrives, in order to read the content of the stored SMS you have to use AT+CMGL= or AT+CMGR=…

 

Inside Loop

If any serial data is available it is assigned to inchar variable

If the first character is $ , the inchar variable is replaced with next Serial character

If the next character is a , again the inchar is replaced with next serial character

Finally , if the character is 1 , the pin 8 is made HIGH & relay is made ON

If the final character is 0 , pin 8 is made LOW , thus making the relay OFF.

SMS $a1 makes the Relay ON

SMS $a0 makes the Relay OFF

Only basic code is explained in this post to just ON or OFF the relay. Further improvements can be done like :

1. Relay status sent back as SMS to the caller

2. Programming can be done so that SMS from particular Master number only is considered

& SMS from other number will not control the relay

3. Pump starter can be made ON / OFF by using 2 relays .One relay contact used to START the motor & other to STOP .While connected with STARTER we need to momentarily switch ON / OFF the relays. This is similar to manually pressing the START or STOP button of the motor starter.

Support video :

blog_image

 

In the previous post part-1 I explained the initial setup of starting a Server on PC on a port , setting the Windows firewall to allow the port for external communication , PORT FORWARDING set up in the Router config, etc..

https://alselectro.wordpress.com/2016/09/25/gsm-connecting-to-a-server-on-a-port-by-tcpip-part-1/

In this part 2 I’ll show a practical demo of sending Temperature data to the Server.

As given in part 1 , start a server on distant PC on port 350 & do the port forwarding settings in Router config as explained.

A LM35 sensor is connected to pin A0 of Arduino & a GSM SIM900A is connected to pins 7 , 8 , Gnd of Arduino. As Soft Serial library is used in the code , pins 7 & 8 are declared as soft Rx & Tx.

The Rx pin goes to Tx of GSM , Tx connected to Rx of GSM , GND is made common.An external power source of 12v 1A is used for the GSM.

Download the Arduino code HERE

————————————-

#include <SoftwareSerial.h>
SoftwareSerial myGsm(7,8);
float temp;
int tempPin = 0;
void setup()
{
myGsm.begin(9600);
Serial.begin(9600);
delay(500);

myGsm.println(“AT+CIPSHUT”);
delay(1000);
printSerialData();

myGsm.println(“AT+CIPMUX=0”);
delay(2000);
printSerialData();

myGsm.println(“AT+CGATT=1”);
delay(1000);
printSerialData();

myGsm.println(“AT+CSTT=\”bsnlnet\”,\”\”,\”\””);//setting the APN,username & password
delay(5000);
printSerialData();

myGsm.println();
myGsm.println(“AT+CIICR”);
delay(6000);
printSerialData();

myGsm.println(“AT+CIFSR”); //get IP address
delay(2000);
printSerialData();

myGsm.println(“AT+CIPSTART=\”TCP\”,\”122.178.80.228\”,\”350\””);
delay(5000);
printSerialData();
delay(5000);

myGsm.println(“AT+CIPSEND”);
delay(2000);
printSerialData();

sendtemp();
delay(3000);
myGsm.println(“AT+CIPCLOSE”);
printSerialData();

myGsm.println(“AT+CIPSHUT”);
delay(1000);
printSerialData();
}

void loop()
{
}

void printSerialData()
{
while(myGsm.available()!=0)
Serial.write(myGsm.read());
}

 

void sendtemp()
{
temp = analogRead(tempPin);
temp = temp * 0.48828125;
Serial.print(“TEMPERATURE = “);
Serial.print(temp);
Serial.print(“*C”);
Serial.println();
delay(5000);
myGsm.println(temp);
delay(3000);
printSerialData();
myGsm.write(0x1A);
delay(3000);
printSerialData();

}

———————————————-

The Analog pin A0 is assigned as tempPin to read the LM 35 sensor data.

Initially any previous IP connection is SHUT  using the command

AT+CIPSHUT

This is essential to start a fresh TCP/IP comnnection.

Single IP connection mode is set by

AT+CIPMUX=0

GPRS is attached using

AT+CGATT=1

Task is started with the command

AT+CSTT=”APN”,”USER NAME”,”PASSWORD”

The Access Point Name of the mobile service provider can be known  by placing the SIM on your Android mobile. It’s shown under

Settings  –> More..  –>  Cellular Networks –> Access Point Names

In my case the APN is bsnlnet , user name & password are empty

AT+CSTT=”bsnlnet”,””,””

 

Then we bring up the Wireless connection with GPRS using

AT+CIICR

This takes a little moment , so a delay of 6 secs is a must in the code.

The IP address assigned by GPRS is obtained by

AT+CIFSR

Now we start up TCP connection with Server IP address & Port number of distant server

AT+CIPSTART=”TCP”,”122.178.80.228″,”350”

Once the connection is established , we send data using

AT+CIPSEND

A CTRL+Z is required to send data which is executed using hex 1A

 

Upload the code to Arduino & open the Serial monitor to watch the AT commands executed

tcp_list

 

Following is the screen shot at the Server side.

 

Image 3

 

 

cooltext753793315

This tutorial is of 2 parts.

First part explains the following :

–Starting a Server on your PC  & start listening on a port (say 350) . For this we use SOCKET TEST or HERCULES software

— Once the port is listening , we test communication locally using PuTty

— Windows Firewall setting has to be done for a NEW INBOUND RULE allowing port 350 for communication.

— For connecting to this port from external world , PORT FORWARDING to be done in Router’s Virtual Server setting so that any contact to the public IP is routed to the PORT 350 .

 

Second part is practical demo using GSM SIM900 or ESP8266 with Arduino.

 

The following picture shows my simple home network connections.A BINATONE make Router is used to connect to the Internet provider Airtel Broadband.The IP address of the Router is

192.168.1.1

which is the Gateway IP address used to access the settings on Router.My Laptop is connected over WIFI to this Router.The Router assigns a local IP address to my PC which is

192.168.1.150

Apart from these, the Internet Provider assigns a Public IP to my Network which is

122.178.80.228

This is the IP by which external world can contact my network.

Note that all these IP addresses are DYNAMIC & changes every time I power up the Router.

In another post I’ll explain how to make these IP addresses STATIC , so that the IP remain the same always.

set1

 

All the Network Tools I’ve used for this demo can be downloaded HERE.

Let us start  a server on port 350 using the SOCKET TEST tool.

This tool allows us to start a server easily.Click on the SERVER Tab & then feed in the port number where you want to listen.

Click on START LISTENING.

soc1

Now the server is up & running.It starts listening on port 350.

Remember to avoid the standard ports like 80 ( http) , 21 (FTP), 23 (TELNET), 22 (SSH) ,etc which are well known ports ,pre assigned for the particular protocol.

The dynamic range of port number you can assign goes up to 65535 or 2^16-1 (16 bits).

The IP address of the router can be known from the command window

RUN –> CMD –> ipconfig

The Default Gateway IP is the address of the Router.

RUN1

 

LOCAL TESTING TOOLS (optional)

 

Once the port is assigned for the server , you can use the ADVANCED PORT SCANNER tool to verify the port on the particular IP.

In the screen shot below you can see that the port number 350 is discovered as a TCP Server port on my PC whose local IP is 192.168.1.150

 

port_scanner

While the port scanner is scanning , you get messages on your SOCKET TEST window.

Here you can see the Port scanner software connecting to the port & then disconnecting after scanning.

port_message

 

Alternatively you can use a PUTTY serial port tool to test local communication.

Select the connection type as RAW & provide the host IP which is 192.168.1.150 & thtn the port number 350

putty1

Click on open , to see the New client connection on the Socket test window.

putty4

 

Now you can test two way communication between  socket test (server) & putty ( client).

putty2

 

WINDOWS FIREWALL SETTINGS

 

The Windows Firewall settings has to be done to allow the port 350 to listen from outside.

Open the Windows Firewall & Advanced Security window.

Click on Inbound Rules & then New Rule.

windows1

 

Select the Rule Type as PORT & in the next screen select protocol as TCP.

Under Specified local ports feed the port number as 350

windows2

 

Under Action window select Allow the Connection

Next window is Profile window , here tick mark all – Domain,Public & Private.

Provide a name to the Rule & save it.

Now your PORT 350 is allowed to listen by the Windows Firewall.

windows3

 

PORT FORWARDING

This step is final where you redirect the incoming request to the port number of local IP where the server is started.

Here my local PC’s IP is 192.168.1.150   &  server is started on port 350.

Anyone from external world connecting to my public IP has to be directed to the port 350 on local IP 192.168.1.150.

This is called PORT FORWARDING , which is very widely used in CCTV Remote viewing & in Gaming.

The setting has to be done in your Router.

Type in the Gateway IP of your Router , here it is 192.168.1.1 , on your browser & provide the user name & password.

Here is an excellent website showing all screen shots of almost all Routers in the world

https://portforward.com/router.htm

 

Mine is BINATONE Router.

You’ve to search for something called VIRTUAL SERVER on the router setting.

 

ROUTER1

 

For my Router it’s hidden under ADVANCED SETUP –> NAT –> VIRTUAL SERVER

For more details you can visit the above portforward link

Create a new Virtual server listing by entering the

— Port number , which is 350 .Enter same number at all fields like start & stop.

— Local IP address , here you provide the IP where server is started , 192.168.1.150

— save the listing

router3

 

Once saved , the port number 350 is open to outside world.

Online port open test tools are available

www.canyouseeme.org

www.yougetsignal.com

 

Once you open the link , your public IP will be automatically shown.

Fill in the PORT number to be checked & click on CHECK button.

If you see SUCCESS , then you’re done with PORT FORWARDING

 

canyou1

 

port_open

 

Following is the list of AT commands used by the GSM SIM900A to contact the server.

This is for part 2 of the post.PART 2 LINK HERE

gsm1

gsm2

cooltext753793315   cooltext753790696

 

 

This post is on retrieving particular Data from a web page using SIM900A & Arduino.

For e.g we shall retrieve the Blog Status hits of my blog in which you’re reading this.

We’ve to create an API link for this data so that data can be retrieved using SIM900A.

To create API link we use the THINGSPEAK.com website.

First let us read the XPATH details of the data wanted as below :

The procedure is related to Google Chrome WebBrowser

 

Image 1

 

Right click on the data to be retrieved & click on INSPECT .

 

inspect

 

A highlighted code will be displayed on which Right click & then select COPY  –> COPY XPATH

XPATH

 

The copied XPATH detail has to be used in THINSPEAK account to create the API link.

Open your thingspeak account & click on APPS –> THINGHTTP

 

thing1

Click on NEW THINGSPEAK to create a new “thing”.

thing2

 

You can provide a suitable Name for the App & under URL provide the website link from where you want the data from.

Method is GET & version is 1.1

thing3

 

Scroll down to bottom & under the PARSE STRING field paste the XPATH copied from the website.

thing4

Click on SAVE & you see the API LINK generated.

thing5

 

You can use this API link in your browser to confirm the data retrieved.

Image 15

Now let us see the practical application using SIN900A GSM & ARDUINO.

The connections between Arduino & GSM are :

Rx of GSM —> pin 8 (Tx) of Arduino   (since we use the SoftSerial in Arduino code , we declare pins 7 & 8 for Serial communication)

Tx of GSM –> pin 7 (Rx) of Arduino

GND –> GND

A separate power source is required for the GSM.

Following are the AT commands used

http

DOWNLOAD Arduino code HERE

————————————————————

#include <SoftwareSerial.h>
SoftwareSerial myGsm(7,8);

void setup()
{
myGsm.begin(9600);
Serial.begin(9600);
delay(500);

myGsm.println(“AT+CGATT=1”);
delay(200);
printSerialData();

myGsm.println(“AT+SAPBR=3,1,\”CONTYPE\”,\”GPRS\””);//setting the SAPBR,connection type is GPRS
delay(1000);
printSerialData();

myGsm.println(“AT+SAPBR=3,1,\”APN\”,\”\””);//setting the APN,2nd parameter empty works for all networks
delay(5000);
printSerialData();

myGsm.println();
myGsm.println(“AT+SAPBR=1,1”);
delay(10000);
printSerialData();

myGsm.println(“AT+HTTPINIT”); //init the HTTP request
delay(2000);
printSerialData();

myGsm.println(“AT+HTTPPARA=\”URL\”,\”http://api.thingspeak.com/apps/thinghttp/send_request?api_key=VV7WQ9DS19E2BNNI\””);// setting the httppara,
//the second parameter is the website from where you want to access data
delay(1000);
printSerialData();

myGsm.println();
myGsm.println(“AT+HTTPACTION=0”);//submit the GET request
delay(8000);//the delay is important if the return datas are very large, the time required longer.
printSerialData();
myGsm.println(“AT+HTTPREAD=0,20”);// read the data from the website you access
delay(3000);
printSerialData();

myGsm.println(“”);
delay(1000);
myGsm.println(“AT+HTTPTERM”);// terminate HTTP service
printSerialData();

}

void loop()
{
}

void printSerialData()
{
while(myGsm.available()!=0)
Serial.write(myGsm.read());
}

—————————————————————-

AT+CGATT=1  enables the GPRS CONNECTION

AT+SAPBR is used to declare the Connection Type as GPRS

& Then the APN –Access Point Name of the mobile service provider is given.

An empty string also will work.Or you can slide the SIM into your Android mobile

under Settings –. More –> Cellular Networks  –> Access Point Names

you get the APN details

AT+SAPBR=1,1  enables the GPRS & APN settings & then HTTP is initialized with AT+HTTPINIT

HTTP parameters are then provided as “URL” & the API link we created earlier.

Note to use HTTP ( not HTTPS) in the link, as we use AT commands for HTTP only here.

AT+HTTPACTION=0 enables GET action

The GSM respons with

+HTTPACTION:0,200,12

Here 0 means GET action & 200 means OK , 12 bytes are retrieved.

If you get 600 instaed of 200 ,then it means a Network Error.

AT+HTTPREAD command is used to read the Data.

 

Image 11

cooltext753793315   cooltext753790696

 

A6 GSM  is introduced by the makers of ESP8266 , AI-THINKER.

The module is much cheaper than SIM900 & connections are quite simple.In this post we shall see how to connect with Arduino to make a call & send SMS.

A mobile adapter is enough to power up the A6 GSM module.The Vcc pin of GSM must be looped with PWR_KEY pin.This acts as a chip enable.You can leave this connected or remove after a moment.The module just requires a HIGH trigger at PWR_KEY pin while started.

A valid SIM is used at the back side of the module.The SIM slot provided is for a Micro SIM.If you ‘ve a Nano SIM you need to use a converter to fit the slot.

The RxD pin of A6 GSM is connected to Tx of Arduino

The TxD pin of A6 goes to Rx of Arduino.

GND pin of A6 to GND of Arduino.

 

Connection

 

 

PIN_DETAILS_A6

Initial TESTING

Power up the module & then after a moment make a call to the SIM number used in the GSM module from another phone.If you get the RING Back tone , it means the module is ready.As there is no LED indication provided , this initial step is required to confirm working.

 

Making a CALL

 

Connect the USB cable of PC to Arduino & upload this code for making a call.Remember to disconnect connections at Rx/Tx before uploading the code.

Image 1

 

The mobile number to be called is stored in an Array of char variable.

In the void setup() code we begin Serial communication at 9600 baud.Though the default baud rate of A6 GSM is 115200 , it is effective to use 9600 baud .

ATD command followed by the number to be called is used to make a call.

A semicolon at the end is not a must as in SIM900.The call will be made even if you do not use a semicolon.

After a delay of 8 secs ATH command is sent to terminate the call.

You can open the Serial monitor of Arduino & watch the AT commands landing.You should set the baud rate as 9600 in the Serial monitor as well.

The void loop() function is left empty.In case you try the code inside loop , the call will be repeatedly

made for ever.

 

Sending SMS

Now let us see the method to send SMS.

Following screenshot shows the code for sending SMS.

Image 2

 

DOWNLOAD Arduino code HERE

AT+CMGF=1

which will allow you to read and write SMS messages as strings instead of hexadecimal characters.

Serial.println is used to send the AT command with a New line (Enter).

After a delay of 2 seconds next command

AT+CMGS=”phone_no.”

is sent.The target phone number is to be given within double quotes. Note the usage of

Serial.write(0x22)  which is the ASCII equivalent for double quotes.

0D followed by 0A are the ASCII equivalents for  CARRIAGE RETURN & LINE FEED.

The delay of 2 seconds is a must after setting the GSM to text mode AT+CMGF=1

Try this code without the delay , you won’t get response.

After the 0D , 0A a delay of 2 seconds is provided & then the message to be sent is given.

CTRL+Z is finally given to send the message.

This is provided by the ASCII equivalent 1A or char(26)

Watch this video :

 

 

cooltext753793315    cooltext753790696

 

After the huge success of the ESP8266 IOT modules , the AI-THINKER company now introduces the new GSM Module A6.In near future this module will be available at half the price of SIM900.

 

GSM_3

 

This is mini GSM / GPRS core development board based on GPRS A6 module. It supports dual-band GSM/GPRS network, available for GPRS and SMS message data remote transmission.
The board features compact size and low current consumption. With power saving technique, the current consumption is as low as 3mA in sleep mode.

Features:
– Working frequency: quad-band network, 850 / 900 / 1800 / 1900MHz
– Working voltage: 4.5~5.5V DC (On-board voltage regulator circuit supply power for A6 module)
– Working current: maximum of 2A
– Sleep current: 5mA
– Onboard Micro SIM card holder, you can install Micro SIM card
– Onboard Micro USB interface for external power supply
– Communication Interface: TTL serial port
– Baud rate: 115200bps and it can also be set by AT command.
– Interface logic voltage: 3.3V
– Make and answer phone calls using a headset and electret microphone.
– Send and receive SMS messages.
– Send and receive GPRS data (TCP/IP, HTTP, etc.) .

PIN DETAILS OF A6 GSM :

PINOUT_ALS

 

To test the module we make use of an USB-TTL module built on CP2102 .

CP2102

 

The connections between A6 GSM & CP2102 module are :

A6 GSM             USB-TTL Board

———-       ————

UART_TXD    —>  Rx

UART_RXD    —>  Tx

GND            –>    GND

The A6 GSM can be powered up with a cell phone charger for which a mini usb socket is provided at the back side.Its advisable to use 5v 2Amp adapter.

Insert a valid SIM to the SIM holder seen at the bottom side of the module.

 

A6_BACK

 

Connect the USB-TTL board to the PC & open the Device Manager to note the COM port alloted.

Open the TERMINAL Software & select this port .Select baud rate as 115200 & click connect.

TERMINAL SOFTWARE Download

 

ter1

 

The GSM module takes around 10 secs to boot up & finally you get CREG 1.

Now you can type in AT commands.The GSM A6 module requires a Carriage Return after every AT command .You can tick mark the CR found at the bottom right of Terminal before sending any command.Or you can make use of the SET MACROS function .Here you store the AT commands followed by $ sign & then 0D .

The $ sign is to Append & the 0D is the ASCII for Carriage Return.

ser3

AT commands are stored in M1,M2,M3,… as shown in screen shot above.

Now if you click on M1 , AT command is sent with CR & you get OK response.

Clicking M2 will send ATDxxxx to dial a number . The semicolon after the number is not a must as in SIM900.

ATH disconnects the call.

To send SMS

AT+CMGF=1  to set the TEXT Mode

AT+CMGS=”phone_no.”

Now you get a  >   symbol & the module waits for you to type in the message.

After typing the test message a CTRL+Z is to be sent .This is done by appending 1A which is the ASCII for the CTRL+Z

Watch this demo video :

 

 

 

 

http://www.alselectro.com/gsm-a6-board.html

http://www.alselectro.com/gsm-a6-full-kit-with-lcd—keypad.html

 

cooltext753793315    cooltext753790696

GSM BASED CONTROL BOARDS

This post introduces the GSM based project boards developed by NSK ELECTRONICS  & marketed by www.alselectro.com .

GSM BASED MOTOR CONTROL BOARD

GSM BASED RELAY CONTROL

GSM BASED SECURITY SYSTEM

The boards are designed to industry standards . Students can watch the videos to understand the functioning of the boards & can implement in their projects using Arduino , PIC , ARM  or 8051 controllers.

cooltext753793315_thumb.png      cooltext753790696.png

SIM908 – GSM ,GPRS & GPS All In One

This GPS/GPRS/GSM all-in-one board  uses an embedded SIM908 chip from SIMCOM.

Featuring an industry-standard interface and GPS function, the combination of both technologies allows goods, vehicles and people to be tracked seamlessly at any location and anytime with signal coverage.

Although the module is capable of dual UART , only a single UART   is used in this board.Through AT commands the GPS Engine is switched ON to get the NMEA sentence.GSM is controlled through same UART by AT commands.

Individual Antennas are provided , a STUB Antenna for GSM & an external Magnetic PATCH Antenna for the GPS.The position of Antennas is important , the one near the LM317 regulator is for GSM & the one in middle is for GPS.

sim908_11

The board must  be powered by an external adapter of 12v 1.5amps.Do not try to power this board from your Arduino or any uC board.

The board is best suited for Microcontrollers like 89S52 or PIC16F877A which have only single UART.

With SIM908 you can avail both GSM & GPS on a single UART.

To test the board with PC , we make use of a USB-UART board built on CP2102 Silicon Labs IC .The M908 board is connected to USB-UART board with a STAIGHT type of RS232 cable.

On connecting the USB cable to PC , a COM port is allotted ( which you can note down from the Device Manager) .This port number is used to communicate from PC to SIM9908 using a Terminal Software like PUTTY or HyperTerminal or TERATERM.

In this demo we shall use PUTTY on serial Baud Rate 9600.

Following snapshot shows the setup for testing.Note that the GPS Antenna should be left outside window .GPS gets a FIX immediately only when the Antenna faces SKY directly.Otherwise it takes more time to get a FIX.

STARTUP TESTING

Insert a valid SIM to the SIMHOLDER on the  back of the board.On powering up the SIM908 , the SIGNAL LED blinks fast initially & after short time it stops & then blinks slowly.

This indicates that the NETWORK is received.

Now from your mobile , dial the number of the SIM you’ve inserted on the SIM908 board.You get the Ring Back tone & the RING LED on the board glows.

WP_20150921_002

Note the COM Port allotted under the Device Manager & then open the PUTTY.

Select Serial , feed in the COM Port ( here its COM11) & baud rate as 9600.

Type in AT , the SIM908 module will respond with OK.

AT+CPIN?     returns the SIM STATUS . +CPIN: READY indicates SIM is inserted.

AT+CSQ       returns the SIGNAL QUALITY. 31 is the maximum level.

AT+COPS?    returns the SERVICE PROVIDER of your SIM.

AT+CGSN    gives the IMEI number of the SIM908 module which is Unique to every module.

gsm1

The default BAUD RATE is 9600.

If you wish to change baud , use the command AT+IPR

gsm5

To dial a number

ATD944xxxxx;        ATD followed by the number to be called & then a semicolon ; is a must.

ATH  to terminate the call

If you call the SIM number from another mobile , you get RING , RING  display.

ATA   To attend the call   & ATH to terminate the call.

If you want the caller ID to be displayed

AT+CLIP=1     enables caller ID.

GSM2

To send a message , first enable TEXT MODE ,

AT+CMGF=1

Now assign the target number to which message has to be sent

AT+CMGS=”944xxx”

A >    symbol appears , after which you’ve type the Message to be sent.

CTRL+Z has to be pressed to send the message .  0x1A is  the Hex code used to represent CTRL+Z within your C code.

gsm3

GPS AT COMMANDS

AT+CGPSPWR=1  enables GPS engine

AT+CGPSRST=0    COLD starts GPS.

AT+CGPSINF=0    returns a single NMEA sentence

GPS1

AT+CGPSSTATUS?     indicates whether GPS has got a FIX. If ERROR is the response , then relocate the GPS Antenna , wait for some time & then retry.

gps_3

AT+CGPSINF=32    returns the GPRMC NMEA sentence , from which you can parse the latitude,longitude

Generally the CGPSINF is assigned value  2 ( 2 power 1) to get GPGGA sentence

4  ( 2 power 2 ) to get GPGLL sentence

32 ( 2 power 5) to get GPRMC sentence.

gps_cgp1

gps_cgp2

Widely used value for CGPSINF is 32 which returns the GPRMC Sentence.

In your C code , look out for the value 32 & then count the occurrence of comma .After  second comma is the FIX data ( A means FIX , V means VOID- no fix)  ,after 3rd  comma is the longitude, etc..

GPS2

Watch the Support video for this post :

For availability of this Module contact :

LOGO2

cooltext753793315  cooltext753790696