Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

GSM SMS 8051 controlling relays

Status
Not open for further replies.

ronydc

Full Member level 3
Full Member level 3
Joined
Nov 17, 2005
Messages
166
Helped
4
Reputation
8
Reaction score
3
Trophy points
1,298
Activity points
2,612
gsm relay

DEAR FRIENDS,

OK .. THR IS A LOT OF DISCUSSIONS ON SENDING THE SMS THROUGH MOBILE PHONE

LETS NOW TALK ABT RECEIVING sms AND MAKING A RELAY ON WITH 8051 CONTROLLER.


IF SOME ONE HAS DONE ANYTHING.. ABOUT THIS USING at commands,
please share it

---> reply and share only -----> 8051 with GSM modem
( not with mobile phone and fbus)

waiting for some expert to break the silence on this topic.
my findings till now are below.

--reciving sms in text mode are not performing the job. to make the realay on with sms.

-- may be forcefully need to apply the PDU mode.

please comment and show the way THIS can help a lot of forum members.

- Rony
 

$crystal at+cmgf=1

ok ok.. friends..

no need to reply this post.
i have got the solution and i am able to make 8 relays on and off with SMS with IC 8051.

THANKS ANY WAY.
 

    V

    Points: 2
    Helpful Answer Positive Rating
sms control relay

hi

im new here, i just want know f anybody could help me. i want to send and receive sms from my computer using AT command,MScomm and writen into Visual basic 6. i am using sony ericsson for my modem attach to the computer using bluetooth.
could you help me guys?
please...? i realy dont have idea how to start or to finish the project.
i have only limited experience in vb and AT commands. i had a sample code in receiving sms but it display in none text format. i already set the format into
AT+CMGF=1
but still not text format.
thanks...

hope that their someone who could help me here coz, im gon from dfrnt forum already but i dnt get exact answers there. hope here i could..
you can reach me here

johndavediuyan@gmail.com

thanks
 

sms controling open the door

try this forumn by searching key words --> sms, vb
many times the vb code are discussed here.

and i am still not clear from ur message that either you are using a GSM modem OR using a sony phone for ur purpose.


all the best.
--Rony
 

gsm 8051 relay

Thank you ronydc ..

But can you me how you interface this circuit ..

please I need your help ..
 

on off relay through mobile sms

ronydc said:
ok ok.. friends..

no need to reply this post.
i have got the solution and i am able to make 8 relays on and off with SMS with IC 8051.

THANKS ANY WAY.

I was looking to c how will be implemented to perform the job, but since you got an answer you quited the discussion any way am doing a project to control a remote device using GSM phone so i have to work out how i can read sms from a modem (for my case it is a phone) then extract the sender number and verify it, then extract the sms content the interplate the command obtained in the sms.
For starting i need just to read a received. According to availability of electronics component to my area i can get a PIC 16F877, siemens of different numbered and ericsson A1018s which i have on hand but i tried to search for max233, 232 it is not there in electronic components shop, i started to write a program to control USART in basic to send AT commands to a phone and read sms from a phone.

Can you assist me cos i think this problem is similar to yours
 

c168i interface eda board

can upload the code ,and related information ,for referring. thank ya
 

gsm relay control

Dear friends
Things are not finished yet, but when it is done you will c every thing here.
 

t290i interface cable diagram

I think its no big deal.

Simply inteface a GSM modem with 8051 and use AT commands for sending and receiving SMS through modem controlled by 8051 microcontroller.

If you want to switch on/off a relay with SMS,you need to interface a GSM modem with 8051 and using 'AT Commands' make 8051 read SMS and perform relay on/off function according to SMS recived, with command written in SMS.

regards
m.yasir
 

gsm relays

ronydc said:
ok ok.. friends..

no need to reply this post.
i have got the solution and i am able to make 8 relays on and off with SMS with IC 8051.

THANKS ANY WAY.

please send me a code to do the same thing u do i.e., read sms and control the device according the message

bhas_r@yahoo.com
 

connecting rxd txd pin to gsm

Since you have to receive and send SMS you can do this by using only three modem signals instead of using all the modem handshake lines through AT commands to GSM modem

on modem physical interface you can do this by shortening the CTS and RTS lines with each other.

In this case you would need only three signal lines i.e. RxD,TxD and GND.

This should be one-to-one connection i.e. RxD of microcontroller connects with RxD of modem,TxD of microcontroller connects with Txd of modem interface and GND obviously is common

you need to keep reading the modem on polling fashion after a certain interval of time again and again

After you read a received SMS you should delete that SMS after executing the command accordingly.

I think you should use SMS mode instead of PDU mode,you can set the SMS format by sending the following command to modem from microcontroller:

AT+CMGF=1

AT Command for reading unread messages

AT+CMGL="REC UNREAD";

AT Command for deleting the messages

AT+CMGD=1,3;


AT command for sending SMS from modem to any mobile number on command
of microcontroller:

AT+CMGS="+913451234567"<CR>
>



This a brief description of how you can do this.

The rest of what is left would be explained in my next post...


regards
m.yasir
 
Last edited by a moderator:

edge modem + microcontroller

thanks yasir9909 for the reply
i started o write the code and i have used microbasic to write it which follow almost the some sequence your talking. Have a look on it.
sorry i think the algorithm of the program is the some even if using different uCU on my side it is difficult to get 8051 uC but i considered pic 16f877 this is my first project am not expert with uCs.
program smsController
'*************Variable declaration******************
Symbol LongDELAY = Delay_ms(500)
Symbol ShortDELAY = Delay_ms(50)
dim sms_receive, temp as byte
dim Sender_Num, phone_num as integer [12]
dim comm as byte [14]
dim a, i, j, k as byte

'**************variable and constant declaring and initializing**************
const CMD1 = "AT+CPMS=ME ,0x0d, 0" 'Select the phone memory ("ME")
const CMD2 = "AT+CMGR=1 ,0x0d, 0" 'read the received message(Memory possition 1)
const CMD3 = "AT+CMGD=1 ,0x0d, 0" 'delete the received message (Memory possition1)
const CMD4 = "AT+CMGF=1 ,0X0d, 0" 'set message format to text mode
const CMD5 = "ATEO ,0X0d, 0" 'Disable echo from modem
const defaultnum = "255714021335" 'default number to the system

sub procedure interrupt ' Interrupt service routine to register def No
if INTCON.RBIF = 1 then ' Changes on RB4-RB7 ?
INTCON.RBIF = 0
else if INTCON.INTF = 1 then ' External interupt (RB0 pin switch button) ?
phone_num = defaultnum ' Goto save the num to eeprom for
goto regista ' sender verification
INTCON.INTF = 0
else if INTCON.T0IF = 1 then ' TMR0 interrupt occurred ?
INTCON.T0IF = 0
else if INTCON.EEIF = 1 then ' Is EEPROM write cycle finished ?
INTCON.EEIF = 0

end if
end if
end if
end if
end sub

main: 'program start here
TRISB = %00111111 ' Pins RB6 and RB7 are output
OPTION_REG = %10000000 ' Turn off pull-up resistors
' and set interrupt on falling edge
' of RB0 signal
INTCON = %10010000 ' Enable external interrupts
PORTB = 0 ' Initial value on PORTB

'***********send command to initialize mobile phone***********
Usart_init(2400) 'initializing baud rate 4 rx and tx
Usart_Write_Text(CMD5) 'stop echos from modem
LongDelay
Usart_Write_Text(CMD1) 'initializing phone memory 1 for sms
LongDelay
Usart_Write_Text(CMD4) 'initiate modem to text mode

CheckSMS:
LongDELAY
Usart_Write_Text(CMD2) 'send command to read the sms from phone memory1
start_read:
if Usart_Data_Ready = 1 then
i = 0
j = 0
goto again
inc (j)
else if j = 4 then '\ =>if looped 4 times no sms
goto CheckSMS '/ ask modem for next time
else goto start_read
end if
end if
again:
sms_receive = Usart_Read
if sms_receive = $2B then'\ skip first + sign find next +
inc (i) '\ (2B="+")
else if i=2 then
i=0
goto save_num
else if sms_receive = $0A then'skip all other sms string
k=0
goto copy_comm '/ sms command
end if
end if
end if
ShortDELAY
goto again

save_num: 'saving sender number to ram
for i=0 to 11
Sender_Num= Usart_Read
Delay_ms(45)
next i
goto again

copy_comm:'copy a command and save to the uCU's ram
while true
sms_receive = Usart_Read
if sms_receive <> $0B then '=>(0B =11= CR) at the end of text sms
comm[k]= sms_receive
inc (k)
ShortDELAY
else goto sender_var
end if
wend

sender_var: 'do verification of sender number
for j=0 to 11
temp = eeprom_read(j)
if temp = Sender_Num[j] then
for a = 0 to 200
Delay_us(500)
next a
else if j=11 then
goto comm_interp 'if valid go to interplate the command
else goto clear_memory' => the number is invalid when j <> 11
end if
end if
next j

clear_memory: 'clear memory and delete message on modem
for i=0 to 11
Sender_Num=$0
next i
for j=0 to 13
comm[j]=$0
next j
Usart_Write_Text(CMD3)
goto start_read

comm_interp: 'interprate command
if comm[0]="o" then
goto openn
else if comm[0]="c" then
goto closse
else if comm[0]="r" then
j=0
phone_num = Sender_Num
goto regesta
goto clear_memory
else goto clear_memory
end if
end if
end if

openn: 'Open door
PORTB.1=1
LongDelay
PORTB.1=0
goto clear_memory

closse: 'Close door
PORTB.2=1
LongDelay
PORTB.2=0
goto clear_memory

regesta: 'Do register new number to the system that will be used to verify sms sender number
for i = 0 to 11
Eeprom_Write(i, phone_num)
for j = 0 to 200
Delay_us(500)
next j
next i
return
end.


Please it has not yet tested but still am suffering on some problem on it.
 

sending at commands to gsm using microcontroller

well,its ok to use any microcontroller either PIC,AVR,8051 or some else if it has built-in UART.Alternatively software UART may also be used.


PIC is better than 8051 in terms of functionality and features

why don't you better use 'C' language instead of basic

C is most widely used language for microcontroller programming

i would give more feed back after i go through your code in detail

what problems you are facing

regards
m.yasir
 

sms control gsm through microcontroller

while am waiting to hear from yasir9909 i had little question about clock on PIC uCs
if i need to use baudrate of the followinglisted below what frequency of a clock cystal do i need to choose
Baudrate cystal Clock
1. 1200 @ ? Mhz
2. 2400 @? Mhz
3. 4800 @? Mhz
4. 9600 @? Mhz

yasir9909 said:
why don't you better use 'C' language instead of basic

C is most widely used language for microcontroller programming
yasir: ths is my first project the the person who encouraged me to get into this world of PIC programming adviced me to start with Basic so after i finish this i will do next project in C but i am new to this world.

Added after 1 minutes:

while am waiting to hear from yasir9909 i had little question about clock on PIC uCs
if i need to use baud rate of the following listed below what frequency of a clock cystal do i need to choose
Baudrate cystal Clock
1. 1200 @ ? Mhz
2. 2400 @? Mhz
3. 4800 @? Mhz
4. 9600 @? Mhz

yasir9909 said:
why don't you better use 'C' language instead of basic

C is most widely used language for microcontroller programming
yasir: ths is my first project the the person who encouraged me to get into this world of PIC programming advised me to start with Basic so after i finish this i will do next project in C but i am new to this world.
 

interface relay to 8051

I mostly work on AVR microcontroller and has also good understanding of 8051.
I have little exposure to PIC.However, based upon my experience on AVR i don't think so you would have any trouble in generating those baud rates with a crystal of clock frequency of 8MHz.

Also there is a limitation of every microcontroller as to how much is the highest frequency of the crystal oscillator you can connect with the microcontroller
you can have such information by consulting the data sheet of the microcontroller

- 8051 divides the crystal clock frequency by 12 for execution of its program
instructions
- If i am not mistaken, PIC divides the crystal clock frequency by 5 for execution
of its program instructions
- AVR does not divide the cystal clock frequency for execution of its program
instructions.AVR operates at the clock frequency of external crystal
oscillator.AVR is faster than the above two microcontrollers

what compiler are you using.For PIC i think mikroC and mikroBasic are good compilers

You also consult the data sheet of microcontroller.I would let you know after consulting the data sheet.

also to have some understanding of AT commands you may consult the following website :

https://www.smssolutions.net/tutorials/


regards
m.yasir
 

control device with sms 8051

One more thing that i would like you to learn is Proteus VSM.
Protues is a very good simulation software for simulating and testing codes,algorithms and circuits built around microcontroller

I have developed a protues simulation for sending SMS and reading SMS through modem,connected physcially to the serial port of the PC, controlled by protues simuation models of microcontroller and serial port in Proteus

I have used AVR microcontroller ATmega32.

I have implemented following AT commands:

- AT+CGMM
- AT+CMGL="ALL"
- AT+CMGS="+913451234567"

I have shortened RTS to CTS and used only three signal lines: RxD,TxD and GND
for implementing above AT commands

The link to this circuit schemetic is:

https://obrazki.elektroda.pl/11_1245691863.jpg


I have utilized Image Craft Compiler for AVR

regards
m.yasir
 
Last edited by a moderator:

gsm ic to microcontroller

Thanks yasir for the picture,
i have got Proteus VSM but am not good enough to do as you did there, the other thing is do you mean that if i connect the phone to serial and simulate it will work the some as a really connected device on a real circuit with my modem?

if my program is perfect it will be able to read and send command to modem?

also can you send you design via my email geev8 at yahoo dot com
 

how to read sms from 8051

geev,well Proteus is not difficult to learn,it is quite simple if you have got practical understanding of microcontroller programming and electronics.

Yes you have rightly judged if you connect GSM modem (i have used WISMO QUIK Q2403A GSM modem) physically to the serial port of the PC and run this Proteus simulation by setting the parameters of COMPIM and virtual terminals according to the physical serial port,i.e. whether it is COM1,baud rate matching with actual serial port for COMPIM (both virtual and real) and for virtual terminals.You can make the modem, connected physically to the serial port of PC,operate like it is actually connected to the microcontroller in hardware

I have implemented a few commands just to have an idea of how this idea of operating modem through Proteus simulation may be materialized.

Further AT commands and operations may also be tested based on this idea.

i would upload the code here

regards
m.yasir
 

sms command in t290i

The code for above simulation is given below.This code has been written in Image Craft compiler for AVR.

Code:
//ICC-AVR application builder : 6/22/2009 9:22:22 AM
// Target : M32
// Crystal: 7.3728Mhz

#include <iom32v.h>
#include <macros.h>

unsigned char SMSFlag=0,SMSReadFlag=0,ButtonPressed=0;
unsigned int timer0_counter=0;
unsigned int i=0,j=0,k=0;

unsigned char cmd_cmgf[]="AT+CMGF=1\r";
unsigned char cmd_cmgl[]="AT+CMGL=\"ALL\"";
unsigned char cReturn[]="\r";
unsigned char cmd_cmgs[]="AT+CMGS=\"+913451234567\"";
unsigned char cmd_AT[]="AT\r";
unsigned char cmd_cgmm[]="AT+CGMM\r";

unsigned char testMessage[]="Hello! this is Test Message!!!";

unsigned char ctrlZ=0x1A;
 /***********************************************************************************************/
void delay_1uSec(unsigned int);
 
 void delay_1uSec(unsigned int m) // approximately m*1uSec Delay
 {
      for(j=0;j<m;j++)
	  {
	   	  for(k=0;k<8;k++)
	      asm("nop");
      }
}
//**********************************************************************************************//

void port_init(void)
{
 	 PORTA = 0x00;
 	 DDRA  = 0x00;
 	 PORTB = 0x01;
 	 DDRB  = 0x00;
 	 PORTC = 0x00; 
 	 DDRC  = 0x0F;
 	 PORTD = 0x00;
 	 DDRD  = 0x00;
}

//TIMER0 initialize - prescale:8
// desired value: 8KHz
// actual value:  8.014KHz (0.2%)
void timer0_init(void)
{
 	 TCCR0 = 0x00; //stop
 	 TCNT0 = 0x8D; //set count
 	 OCR0  = 0x73;  //set compare
 	 TCCR0 = 0x02; //start timer
}

#pragma interrupt_handler timer0_ovf_isr:12
void timer0_ovf_isr(void)
{
 	 TCNT0 = 0x8D; //reload counter value
	 timer0_counter++;
	 
	 if(ButtonPressed==1)
	 PORTC = 0x0F|PORTC;
	 
	 
}

//UART0 initialize
// desired baud rate: 57600
/* ************************************************************************ */

void uart0_init(void)
{
 	 UCSRB = 0x00; //disable while setting baud rate
 	 UCSRA = 0x00;
 	 UCSRC = BIT(URSEL) | 0x06;
 	 UBRRL = 0x07; //set baud rate lo
 	 UBRRH = 0x00; //set baud rate hi
 	 UCSRB = 0x18;
}

///////////////////////// UART data receive routine //////////////////////////
unsigned char ReceiveByte(void)
{
	  while(!(UCSRA & BIT(RXC)));
	  return UDR;
}
///////////////////////// UART data transmit routine //////////////////////////
void SEND_CHAR_UART(char ch)
{
      while(!(UCSRA & BIT(UDRE))) ;
      UDR = ch;
}
//*----------------------------------------------------------------------------*//
void SendStr(char *ch)
{
      while(*ch != 0x00) 
	  SEND_CHAR_UART(*ch++);
}
/*------------------------------------*/


//call this routine to initialize all peripherals
void init_devices(void)
{
 	 //stop errant interrupts until set up
 	 CLI(); //disable all interrupts
 	 port_init();
 	 timer0_init();
 	 uart0_init();

 	 MCUCR = 0x00;
 	 GICR  = 0x00;
 	 TIMSK = 0x01; //timer interrupt sources
 	 SEI(); //re-enable interrupts
 	 //all peripherals are now initialized
}
//
void main(void)
{
 	  init_devices();
 	  //insert your functional code here...
	 
	  //*************************************
	  // Set Text Mode
	  //*************************************
	  for(i=0;i<sizeof(cmd_cmgf);i++)	
	  SEND_CHAR_UART(cmd_cmgf[i]);	
	  //*************************************	
	  for(i=0;i<sizeof(cmd_AT);i++)	
	  SEND_CHAR_UART(cmd_AT[i]);	
	  //*************************************
	  for(i=0;i<sizeof(cmd_cgmm);i++)	
	  SEND_CHAR_UART(cmd_cgmm[i]);
	  //*************************************
	  delay_1uSec(90000);
	  
	  // AT+CMGL="ALL"
	  	 
	  SEND_CHAR_UART('A');
	  SEND_CHAR_UART('T');
	  SEND_CHAR_UART('+');
	  SEND_CHAR_UART('C');
	  SEND_CHAR_UART('M');
	  SEND_CHAR_UART('G');
	  SEND_CHAR_UART('L');
	  SEND_CHAR_UART('=');
	  SEND_CHAR_UART('"');
	  SEND_CHAR_UART('A');
	  SEND_CHAR_UART('L');
	  SEND_CHAR_UART('L');
	  SEND_CHAR_UART('"');
	 
	  for(i=0;i<sizeof(cReturn);i++)	
	  SEND_CHAR_UART(cReturn[i]);
	 
	 //***************************************
	  delay_1uSec(90000);
	  delay_1uSec(90000);
	  // AT+CMGS="+913451234567" 	 
	  SEND_CHAR_UART('A');
	  SEND_CHAR_UART('T');
	  SEND_CHAR_UART('+');
	  SEND_CHAR_UART('C');
	  SEND_CHAR_UART('M');
	  SEND_CHAR_UART('G');
	  SEND_CHAR_UART('S');
	  SEND_CHAR_UART('=');
	  SEND_CHAR_UART('"');
	  SEND_CHAR_UART('+');
	  SEND_CHAR_UART('9');
	  SEND_CHAR_UART('1');
	  SEND_CHAR_UART('3');
	  SEND_CHAR_UART('4');
	  SEND_CHAR_UART('5');
	  SEND_CHAR_UART('1');
	  SEND_CHAR_UART('2');
	  SEND_CHAR_UART('3');
	  SEND_CHAR_UART('4');
	  SEND_CHAR_UART('5');
	  SEND_CHAR_UART('6');
	  SEND_CHAR_UART('7');
	  SEND_CHAR_UART('"');
	 	 
	  SEND_CHAR_UART(13); //Carriage Return
	 
	  delay_1uSec(90000);
	 
	  for(i=0;i<sizeof(testMessage);i++)	
	  SEND_CHAR_UART(testMessage[i]);
	 
	  SEND_CHAR_UART(26); //CTRL-Z
	 
	 
	 //***************************************
	 while(1)
	 {
	  	 
	 }
	 
}
 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top