Sei sulla pagina 1di 5

GSM

• GSMGlobal System for Mobile

• GSM module only understands AT commands

• AT commands should be followed by Carriage return i.e. \r (0D in hex), like “AT+CMGS\r”

• if your module has RX and TX (with GND) Pins on board then it can work on TTL logic

• Carriage return special code that moves the cursor (or print head) to the beginning of the current
line.

• AT+CMGF=1\r, put the modem in SMS text format mode.

• AT+CMGS=\”+ZZ XXXXXXXXXX\”\r, The SMS will send to the 10 digit number written as XXXXXXXXXX
with 2 digit country code ZZ

PROGRAM:

#include<reg51.h>

sbit rs=P1^0;

sbit rw=P1^1;

sbit en=P1^2;

sbit sensor=P1^5;

unsigned int cmd[]={0x38,0x0e,0x01,0x06,0x80};

unsigned char at1[]="AT";

unsigned char at2[]="AT+CMGF=1";

unsigned char at3[]={'A','T','+','C','M','G','S','=','"','+','9','1','9','8','6','1','2','0','2','0','3','1','"'};

unsigned char at4[]="ERROR DETECTED";

unsigned char lcdmsg[]="SENDING SMS";

unsigned int a,a1,b,c,d,e,f;

void delay()

{ for(a1=0;a1<32000;a1++); }

void cmmd()
{ rs=0;rw=0;en=1;delay();en=0; }

void dat()

{ rs=1;rw=0;en=1;delay();delay();en=0; }

void nexline()

{ SBUF=0x0d;while(TI==0);TI=0; }

void main()

while(1)

TMOD=0x20;

SCON=0x50;

TR1=1;

TH1=0xfd;

for(c=0;c<2;c++)

{ SBUF=at1[c];while(TI==0);TI=0; }

nexline();

delay();

for(c=0;c<9;c++)

{ SBUF=at2[c];while(TI==0);TI=0; }

nexline();

delay();
while (sensor==1);

for(c=0;c<23;c++)

{ SBUF=at3[c];while(TI==0);TI=0; }

nexline();

delay();

for(c=0;c<14;c++)

{ SBUF=at4[c];while(TI==0);TI=0; }

SBUF=0x1a;//used to send the control character called EOF (End of File) to mark the end
of message

while(TI==0);

TI=0;

delay();

for(a=0;a<5;a++)

{ P2=cmd[a];cmmd(); }

for(c=0;c<11;c++)

{ P2=lcdmsg[c];dat(); }

}
BLUETOOTH MODULE (HC-05)

* HC-05 module is an easy to use Bluetooth SPP (Serial Port


Protocol) module, designed for transparent wireless serial
connection setup.

* Standard: Bluetooth 4.2 core specification

* Frequency: 2.4GHz

* Range: 50-150m

* Data Rates: 1Mbps

* HC-05 is an easy to use Bluetooth SPP(serial port


protocol),designed for transparent wireless serial connection
setup.

* Can be used as both master and slave.

* HC-06 functions only as slave.

* ENABLE- when enable is pulled LOW, the module is disabled


which means the module will not turn on and it fails to
communicate. When enable is left open or connected to 3.3v, the
module is enabled i.e. the module remains on and communication
also takes place.

* Vcc- supply voltage 3.3v to 5v

* Gnd- gnd pin

* Txd & Rxd- These two pins acts as an UART interface for
communication
* STATE: It acts as a status indicator. When the module is not
connected to / paired with any other Bluetooth device, signal
goes Low. At this low state, the led flashes continuously which
denotes that the module is not paired with other device. When
this module is connected to/paired with any other Bluetooth
device, the signal goes High. At this high state, the led blinks with
a constant delay say for example 2s delay which indicates that the
module is paired.

Potrebbero piacerti anche