Sunday, September 2, 2018

gsm module and arduino in iot


GSM MODULE






 GSM module here is used for sim to sim communication .GSM module can send messages received from arduino to any specified mobile number. And can also receive messages from any number and forward those messages to arduino. Thus it acts as a medium to initiate communication between mobile and arduino. In short, GSM actually acts as a mobile. It can also be used to dial calls and receive incoming calls.



We use SIM900 GSM Module – This means the module supports communication in 900MHz band. We are from India and most of the mobile network providers in this country operate in the 900Mhz band. If you are from another country, you have to check the mobile network band in your area. A majority of United States mobile networks operate in 850Mhz band (the band is either 850Mhz or 1900Mhz). Canada operates primarily on 1900 Mhz band.










Check the power requirements of GSM module – GSM modules are manufactured by different companies. They all have different input power supply specs. You need to double check your GSM modules power requirements. In this tutorial, our gsm module requires a 12 volts input. So we feed it using a 12V,1A DC power supply.



START the GSM Module:-

1. Insert the SIM card to GSM module and lock it.

2. Connect the adapter to GSM module and turn it ON!

3. Now wait for some time (say 1 minute) and see the blinking rate of ‘status LED’  or ‘network LED’ (GSM module will take some time to establish connection with mobile network)

4. Once the connection is established successfully, the status/network LED will blink continuously every 3 seconds. You may try making a call to the mobile number of the sim card inside GSM module. If you hear a ring back, the gsm module has successfully established network connection.



Connecting GSM Module to Arduino

For connecting GSM module to arduino.The communication between Arduino and GSM module is serial. So we are supposed to use serial pins of Arduino (Rx and Tx). So if you are going with this method, you may connect the Tx pin of GSM module to Rx pin of Arduino and Rx pin of GSM module to Tx pin of Arduino. You read it right ? GSM Tx –>Arduino Rx and GSM Rx –>ArduinoTx. Now connect the ground pin of arduino to ground pin of gsm module

Note:- The problem with this connection is that, while programming Arduino uses serial ports to load program from the Arduino IDE. If these pins are used in wiring,  the program will not be loaded successfully to Arduino. So you have to disconnect wiring in Rx and Tx each time you burn the program to arduino. Once the program is loaded successfully, you can reconnect these pins and have the system working!



HARDWARE CONNECTIONS-


PRACTICALS PERFORMED

1.  Dialing a number using gsm.

2.  Attend an incoming call on gsm

3.  Send a message to a particular number example:alert messages with help of gsm

4.  Recive a message from a number  with help of gsm and forward it to arduino.



CODES FOR GSM

GSM mainly works on AT commands. With the help of at commands we can put gsm in call mode or message mode. In case we are tosend or receive messages the gsm has to be in message mode. And in order to receive or dial calls gsm has to be in call mode.



SOME BASIC AT COMANDS FOR GSM:-

AT

AT+CMGF=1 /// to put gsm in message mode

AT+CMGF=0/// to put gsm in call mode

ATDXXXXXXXXXX; ////to dial a call using gsm. Xxxxxxxxxxx here is a 10 digit number to be dialed

ATA  ////to attend a received call

ATH ///// to halt a received call

AT+CMGS=”+91xxxxxxxxxx”   /////command to send a message on particular number



CODE TO DIAL A NUMBER:-





void setup()

{Serial.begin(9600);

Serial.println("AT");

delay(1200);

Serial.println("AT+CMGF=0");

delay(1200);

Serial.println("ATDXXXXXXXXXX;");  //ph no..





delay(5000);

}

void loop()

{Serial.println("ATA");

delay(5000);

Serial.println("ATH");

delay(1200);




}






CODE TO ATTEND A CALL





void setup()

{Serial.begin(9600);

Serial.println("AT");

delay(1200);

Serial.println("AT+CMGF=0");

delay(1200);



Serial.println("ATDXXXXXXXXXX;");  //ph no..





delay(5000);

}

void loop()

{Serial.println("ATA"); // call will be attend

delay(5000);




}



CODE TO HOLD A CALL:- 

void setup()

{Serial.begin(9600);

Serial.println("AT");

delay(1200);

Serial.println("AT+CMGF=0");

delay(1200);



Serial.println("ATDXXXXXXXXXX;");  //ph no..





delay(5000);

}

void loop()

{Serial.println("ATA");

delay(5000);

Serial.println("ATH"); // call will be hold after 5 seconds

delay(1200);





}




CODE TO SEND A MESSAGE-



void setup() {

  Serial.begin(9600);

Serial.println("AT");

delay(1200);

Serial.println("AT+CMGF=1");

delay(1200);

Serial.println("AT+CMGF=\"xxxxxxxxxx\  "");

delay(1200);

Serial.println("hello"); // write your message instead of hello

delay(500);



Serial.write(0x1A); //12

Serial.write(0x0D);  //10

Serial.write(0x0A); //26

}



void loop() {






}

Tech IOT Web Developer

No comments:

Post a Comment