How to Receive SMS Using GSM Module With Arduino

July 18, 2019 | Author: Ubaid Saudagar | Category: N/A
Share Embed Donate


Short Description

Receive SMS using SMS900A...

Description

How to Receive SMS Using GSM Module with Arduino *============================ EG LABS ===================================// Demonstration on how to receive an SMS using GSM module The circuit: LCD: * LCD RS pin to digital pin 12 * LCD Enable pin to digital pin 11 * LCD D4 pin to digital pin 7 * LCD D5 pin to digital pin 6 * LCD D6 pin to digital pin 5 * LCD D7 pin to digital pin 4 * LCD R/W pin to ground * 10K resistor: * ends to +5V and ground * wiper to LCD pin 3 * LED anode attached to digital output 9 * LED cathode attached to ground through a 1K resistor GSM: RX PIN OF GSM TO TX0 PIN OF ARDUINO SHORT THE GROUND PINS OF ARDUINO AND XBEE ============================== EG LABS ===================================*/

#include // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 7, 6, 5, 4); // give the pin a name: int led = 9; // incoming serial byte int inByte = 0; void setup() {  pinMode(9, OUTPUT); OUTPUT); lcd.begin(16, 2); lcd.print("ENGINEERS GARAGE"); lcd.setCursor(0, 1); lcd.print(" GSM SMS "); delay(1000);

// initialize the led pin as an output.  pinMode(led, OUTPUT); // start serial port at 9600 bps Serial.begin(9600); // wait for a while till the serial port is ready delay(100); // send the initial data once // Serial.print("AT+CMGF=1\n\r"); delay(500); Serial.print("AT+CNMI=2,2,0,0,0\n\r"); delay(2000); digitalWrite(led, HIGH); } void loop() { do { while ( !Serial.available() ); } while ( '"' != Serial.read() ); do { while ( !Serial.available() ); } while ( '"' != Serial.read() ); do { while ( !Serial.available() ); } while ( '"' != Serial.read() ); do { while ( !Serial.available() ); } while ( '"' != Serial.read() ); while ( !Serial.available() ); inByte = Serial.read(); while ( !Serial.available() ); inByte = Serial.read(); lcd.clear(); while(1) { while ( !Serial.available() ); inByte = Serial.read(); if ( inByte == '\r' )

 

break; else; lcd.write ( inByte ); }

}

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF