Joke Collection Website - Blessing messages - I'm doing a single-chip computer to write instructions to send SMS to the designated mobile phone number for information or QQ for help.

I'm doing a single-chip computer to write instructions to send SMS to the designated mobile phone number for information or QQ for help.

I once wrote that 5 1 single chip microcomputer sends the collected temperature to the set TCP server through GPRS through SIM300 module. You can have a look. Sending text messages is very simple. Just modify the previous code according to the AT instruction.

/*8-bit * * * positive digital tube, 18b20 connected to P3^3, 1 1.0592 crystal oscillator */

# include & ltreg52.h & gt

# include & ltintrins.h & gt

# Define uchar unsigned characters

# Define uint unsigned integer

uchar th,TL; //The storage and acquisition temperature is 8 bits higher and 8 bits lower.

Uchar temp_int, temp _ dot// stores the integer part and decimal part of the converted temperature.

sbit dq=p3^3; // 18b20 data interface

bit stat _ 18b 20; // 18b20 initialization return status

uchar ctrl _ z = 0x 1a; //GPRS data transmission terminal identification CTRL+Z key 16 binary code

Uchar ATC lport [] = "at+clport = \" TCP \ ",\" 5256 \ "\ r// Set the local GPRS communication protocol and port number.

Uchar atcipstart [] = "at+CIP start = \" TCP \ ",\"121.233.142.158 \ ",\" 6000 \ "

uchar ATCIPSEND[]= " AT+CIP send \ r "; //Start the data sending command

void UART _ init(); //Serial port initialization

void dela Yus(uint xus); //delay microseconds

void delay ms(uint xms); //Delay milliseconds

init _ 18b 20(); // 18b20 initialization

read char(); //Read a byte

void write char(uchar dat); //Write a byte

void get _ temp(); //Measure the temperature

void temp _ convert(); //conversion temperature

void send _ string(uchar * GPRS _ string); //Send the string to the GPRS module.

void send _ char(uchar);

void GPRS _ init(); //GPRS module initialization

void send _ temp(); //Send the temperature through GPRS module.

//-The following are the main functions.

Invalid master (invalid)

{

UART _ init();

GPRS _ init();

while( 1)

{

get _ temp();

temp _ convert();

send _ temp();

}

}

void uart_init()

{

TMOD = 0x 20;

SCON = 0x 50;

th 1 = 0x FD;

TL 1 = 0x FD;

tr 1 = 1;

}

//-The following are the delayed operation functions.

void delayus(uint xus)

{

for(; xus & gt0; xus-);

}

Invalid delay (uintms)

{

uint I;

uchar j;

for(I = 0; I & ltxmsi++)

for(j = 0; j & lt 1 12; j++);

}

//-The following are the operating functions of DS 18B20.

init_ 18b20()

{

stat _ 18b 20 = 1;

dq = 1;

Draeus (5);

dq = 0;

Draeus (50);

dq = 1;

Draeus (5);

stat _ 18b 20 = dq;

Draeus (60);

dq = 1;

return(stat _ 18b 20);

write char(0x4e);

write char(0x 02);

write char(0x 0 1);

write char(0x7f);

}

readchar()

{

uchar i,dat

for(I = 8; I>0; I-)

{

dq = 0;

dat = dat & gt& gt 1;

dq = 1;

Intermediate frequency (dq)

dat = dat | 0x80

Draeus (4);

}

return(dat);

}

void writechar(uchar dat)

{

Ucal I;

for(I = 8; I>0; I-)

{

dq = 0;

dq = dat & amp0x 0 1;

Draeus (5);

dq = 1;

dat = dat & gt& gt 1;

}

}

void get_temp()

{

init _ 18b 20();

if(stat_ 18b20==0)

{

write char(0x cc);

write char(0x 44);

Delems (50);

init _ 18b 20();

write char(0x cc);

write char(0x be);

TL = read char();

th = read char();

}

other

{

; //Error handling module

}

}

void temp_convert()

{

temp _ int =((th & amp; 0x 07)& lt; & lt4)|((TL & amp; 0xf0)>& gt4);

Temporary point = tl & amp0x0f

}

//-The following are the operating functions of the SIM300.

Voidsend _ string (uchar * GPRS _ string)//instruction string Send instruction.

{

while(*gprs_string)

{

SBUF = * gprs _ string

while(TI = = 0);

TI = 0;

GPRS _ string++;

}

}

void send_char(uchar x)

{

SBUF = x;

while(TI = = 0);

TI = 0;

}

void gprs_init()

{

send _ string(ATCLPORT);

delayms( 1000);

send _ string(atci pstart);

delayms( 1000);

}

void send_temp()

{

send _ string(ATCIPSEND);

send _ char(temp _ int);

Send_char (temporary point);

send _ char(ctrl _ z);

delayms( 1000);

}