Discussion in "Embedded GSM Development" started by    Ajay Bhargav    Feb 5, 2013.
Tue Feb 05 2013, 09:10 AM
#1
//You need two variables and a constant, one for storing constant string,
//second for an index pointer and a buffer to store recieved data
unsigned char code Response[] = "+CMTI";
unsigned char MyBuff[15], i = 0;
//we can also have a flag for new message
bit NewMessage = 0;

//consider this ISR function
//assuming ch is read character from SBUF
if((ch == Response[i]) || (i >
 4)){
	//if received character is there in Response or i is >
 4 which means
	// you already have the right string...
	if(ch != 0x0D) { // 0x0D means data received..
		//Store received data
		MyBuff[i++] = ch;
	} else {
		//seems like we have recieved our data
		//Now stop and indicate that new message has received
		MyBuff[i] = '\0';
		NewMessage = 1;
		
		//do not forget to reset i :)
		i = 0; // no more errors..
	}
} else {
	//there is a miss match
	//reset counter
	i = 0;
}

//Now in main loop you can just wait for New message flag

while(!NewMessage);
NewMessage = 0;

//Parse MyBuff, get the index and read message :)


After you go through this pseudo code.. Please read complete discussion in this thread:
http://www.8051projects.net/t41321-p30/embedded-gsm-development/gsm-modem-8051.htm#post_42097
 kirangowle like this.
Tags reading sms from gsm modemreading sms using 8051gsm modem read sms codegsm modem sms reading using interrupt
Tue Feb 05 2013, 10:48 AM
#2
Thanks Ajay Bhargav
Tue Feb 05 2013, 04:46 PM
#3
Thanks to Ajay for this complex logic with simple solution.
Thu Jan 15 2015, 10:43 AM
#4
Hi Ajay ,


I am trying to implement your logic for "Reading SMS from SIM900A GSM Module ". But
Could not succeed .

I have checked my 8051 Circuit and GSM module with Hyperterminal .

I am trying to print the "received string " on LCD and/or send back to hyperterminal

Can you just look in to it ..

Thanks in Advance..

#include<REG51.h>

#include<string.h>


#define dataport P2

sbit rs =	P0^3; 		 //Register select pin
sbit rw =	P0^0;  		 // Fake GND In Hardware
sbit en = 	P0^4;  		 //Enable pin

sbit LED1 =	P1^0;
sbit LED2 =	P1^1;

sbit LED3 =	P0^6;
sbit LED4 =	P0^7;

void rece_isr();

//You need two variables and a constant, one for storing constant string,
//second for an index pointer and a buffer to store recieved data
unsigned char code Response[] = "+CMTI";
unsigned char MyBuff[15], i = 0,ch;
//we can also have a flag for new message
bit NewMessage = 0;

void DelayMs(unsigned char k)
{
   unsigned int i,j;
   for(i=0;i<=k;i++)
   {
   		for(j=0;j<=150;j++) ;
   }
}
void delay(unsigned int msec)  // Function to provide time delay in msec.
{
	int i,j ;
	for(i=0;i<msec;i++)
		for(j=0;j<200;j++);
}
////////////////////////////////////LCD STARTS//////////////////////////////////////
void lcdcmd(unsigned char item)  //Function to send command to LCD
{
	dataport = item;
	rs= 0;
	rw=0;
	en=1;
	delay(1);
	en=0;
	delay(1);
}

void lcddata(unsigned char item)  //Function to send data to LCD
{
	dataport = item;
	rs= 1;
	rw=0;
	en=1;
	delay(1);
	en=0;
	delay(1);
}

int lcd_string(unsigned char *item)    // function to send string to LCD
{
	int x;
	for(x=0;item[x]!=0;x++)
		lcddata(item[x]);
	return(1);
}
void init_lcd()
{
	lcdcmd(0x38);
	delay(1);
	lcdcmd(0x0C);
	delay(1);
	lcdcmd(0x01);
	delay(1);
	lcdcmd(0x80);
	delay(1);
}
////////////////////////////////////LCD ENDS//////////////////////////////////////
////////////////////////////////Serial Program Starts/////////////////////////////
void SerialInit()
{
	EA=0;
	TH1 = 0xFD;
	SCON = 0x50;
	TR1 = 1;
	RI=0;
	TI=0;
	ES=1;
	TMOD = 0x26;
	EA = 1;
}// End of SerialInit
void string_to_pc(unsigned char *temp)
{
	while(*temp)
	{
		SBUF= *temp;
		DelayMs(100);
		temp++ ;
	 }
}


void ISR_sc(void) interrupt 4
{
		//consider this ISR function
		//assuming ch is read character from SBUF
	if((ch == Response[i]) || (i >
4))
		{
							//if received character is there in Response or i is >
 4 which means
				// you already have the right string...
						if(ch != 0x0D) 
						{ // 0x0D means data received..
									//Store received data
									MyBuff[i++] = ch;
									string_to_pc('E');
						} 
						else 
					  {
																	//seems like we have recieved our data
					                       	//Now stop and indicate that new message has received
				              MyBuff[i] = '\0';
				              NewMessage = 1;
											string_to_pc('F');
												//do not forget to reset i :)
										i = 0; // no more errors..
					}
		} else 
				{
							//there is a miss match
							//reset counter
					i = 0;
		    }
}
void rec_unread_sms()
{
	string_to_pc("AT+CMGR=1");
	delay(500);	
	SBUF=0x0D;
	delay(500);	
}

void delete_sms()
{
	delay(1500);	
	string_to_pc("AT+CMGD=1");
	delay(1500);	
	SBUF=0x0D;
	delay(1500);	
}
///////////////////////////////////////////////////

void main()
{

		SerialInit();
	  
	  init_lcd();		                       /* Function for Initlization LCD 16 x 2 */
	
		lcdcmd(0x80);
	
		lcd_string("GSM GATEWAY FOR") ;
	
		lcdcmd(0xC0)                   ;
	
		lcd_string("INDS. MONITORING") ;
	
	  
		lcdcmd(0x01);  
	
		Test_LEDs();
	 	
		while(!NewMessage);
			NewMessage = 0;
	
		lcdcmd(0xC0)                   ;
		lcd_string(MyBuff) ;

	  string_to_pc(MyBuff);
	
		while(1);
}

Sun Jan 18 2015, 05:58 AM
#5
@karan123 I suggest you to create a new thread for your problem.

Get Social

Information

Powered by e107 Forum System

Conversation

ExperimenterUK
Sat Oct 12 2019, 10:23 PM
Log in.. then post your code in the 8051 forum
Sat Oct 12 2019, 10:18 AM
Bhadra Sajikumar
i am doing a countdown timer with 8051 for my project, unfortunately our professor had to take a leave of absence before he could teach us most of it.. can someone explain the .asm code of it for me?
Mon Sep 23 2019, 07:37 AM
Nathaniel
I am doing a project for my schools wireless security system with cameras,sensors and spot lights using 8051 micro controller, could you help me out with the design and its source code.
Wed Sep 18 2019, 08:48 PM
Caryn Kover
Thank you for your time,
ExperimenterUK
Mon Aug 05 2019, 07:09 PM
@Ismail ..post in forum, give details
Mon Aug 05 2019, 04:33 PM
Ismail balghmi
Hello. Please I won't download
ExperimenterUK
Wed Jul 24 2019, 12:47 AM
@BUSTER123 Please post in the forum
Tue Jul 23 2019, 06:13 PM
BUSTER123
hello! newbie here. i am kind of a guy who hates using ready - made existing libraries, so this helped a lot as i was trying to control and write to a character lcd display. however, i can't figure out how to set the cursor position. for example, i want to set it to the 5th column in the first row, so position 5. so according to the table, i am sending 10000101 on the 8 data lines of the lcd (register select pulled low). the cursor does not move there however. and i cant move the cursor left or right too. is it something wrong that i am doing? thank you.
ExperimenterUK
Thu Jul 11 2019, 07:55 PM
@ramos https://www.theengineeringprojects.com/2017/09/l298-motor-driver-library-proteus.html
ExperimenterUK
Thu Jul 11 2019, 07:44 PM
@praveen123. Can you give a link to the project ?

Downloads

Comments

auwal
Tue Nov 19 2019, 03:13 PM
ANKITPATEL
Mon Nov 18 2019, 11:00 AM
Casmir
Wed Nov 13 2019, 06:25 AM
DeepakBGattani
Mon Nov 11 2019, 01:31 PM
Jeanbusatta
Sun Nov 10 2019, 04:42 AM
mdayaz
Sat Nov 09 2019, 03:41 PM
baoyen123
Fri Nov 08 2019, 10:06 AM
xiwang
Fri Nov 08 2019, 07:28 AM

Online

Guests: 29, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38105
Newest member: auwal
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Nov 19 2019, 10:44 PM
The 8051 has too little memory to do anything us...
ilylily07 Avatar
Posted By ilylily07
Mon Nov 18 2019, 09:54 AM
0v7670 camera interfacing with stc 8051.using asse...
Jeanbusatta Avatar
Posted By Jeanbusatta
Sun Nov 10 2019, 04:43 AM
ty, really needed it
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Oct 22 2019, 05:18 AM
wimac Avatar
Posted By wimac
Mon Oct 21 2019, 09:18 AM
I’ve been following this thread and looking at the...
s_dinesh40@yahoo.com Avatar
Posted By [email protected]
Sun Oct 20 2019, 03:09 PM
s_dinesh40@yahoo.com Avatar
Posted By [email protected]
Sun Oct 20 2019, 03:02 PM
sir, when i on display ,sometime 3rd display is no...
s_dinesh40@yahoo.com Avatar
Posted By [email protected]
Sun Oct 20 2019, 02:53 PM
sir, when i on display ,sometime 3rd display is no...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sun Oct 20 2019, 12:21 AM
Your code seems okay on my simulationTry my code o...
s_dinesh40@yahoo.com Avatar
Posted By [email protected]
Sat Oct 19 2019, 07:13 PM
please find video attachment. 3rd & 4th displa...