gsm project
You have asked multiple questions in this regard.SO,i would reply one by one
1. I favor your idea to use old mobile phone instead of GSM modem as old mobile phone would cost you lesser than GSM modem or OEM GSM module and GSM modem may not be easily available in local market.
But interfacing mobile phone with microcontroller has its own issues,intricacies and complications that you need to address before going for this idea, as you would have to understand the protocol to get the mobile phone communicate with microcontroller.
GSM modem with RS-232 compatible interface is quite easy to interface with microcontroller and most of the GSM modems support almost all AT commands and mobile phone may not support all AT commands.
I mostly work on interfacing of GSM modem with microcontroller and controlling it through AT commands.
Any ways regarding your issue i have come across two solutions:
i. You may use USB to serial converter cable so that mobile may be
interfaced with USB to serial converter cable.However,this feature
needs to be explored and practically analyzed as i have perceived
this idea based on my simulation using bluetooth serial
communication link.
ii. Alternatively,you may look out for an old mobile phone like motorola
C168i which may be directly interfaced with microcontroller and
supports AT commands as well.
2. I have made a simulation in Proteus VSM that controls the mobile phone connected with serial port of my PC through AT commands through COMPIM proteus model.
I have used dual SIM chinese mobile NKTEL N-66 for this purpose,it supports almost all AT commands.
The mobile phone is connected with PC through BlueTooth device plugged into my PC and communicates with bluetooth device through serial communication wireless link established by blue tooth plugged into my PC with blue tooth of my mobile.This Bluetooth-to-Bluetooth wireless serial communcation link between PC and mobile phone works like a GSM modem (built inside mobile phone) connected with PC through a wired RS-232 link.
3. I have used following command:
AT+CMGL="REC UNREAD" <CR>
This commands reads the unread messages from the mobile phone and switches the LED off as per command code set in new SMS received in mobile phone.
you can connect relays instead of mobile LEDs.
This is a very basic or crude form of simulation to demonstrate how the relays may be operated through SMS using mobile phone.There may be scores of other ways doing this.
The code for this simulation is :
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 flag1=0,flag2=0,flag3=0,flag4=0,flag5=0,flag6=0;
unsigned char inputBuffer[500];
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
//delay_1uSec(90000);
//
//***************************************
delay_1uSec(90000);
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('R');
SEND_CHAR_UART('E');
SEND_CHAR_UART('C');
SEND_CHAR_UART(' ');
SEND_CHAR_UART('U');
SEND_CHAR_UART('N');
SEND_CHAR_UART('R');
SEND_CHAR_UART('E');
SEND_CHAR_UART('A');
SEND_CHAR_UART('D');
SEND_CHAR_UART('"');
SEND_CHAR_UART(13); //Carriage Return
delay_1uSec(90000);
j=0;
while(1)
{
inputBuffer[j]=ReceiveByte();
if(inputBuffer[j]=='@')
flag1=1;
if( (inputBuffer[j]=='@')&& (flag1==1) )
flag2=1;
if( (inputBuffer[j]=='@')&& (flag2==1) )
flag3=1;
if( (inputBuffer[j]=='O')&& (flag3==1) )
flag4=1;
if( (inputBuffer[j]=='F')&& (flag4==1) )
flag5=1;
if( (inputBuffer[j]=='F')&& (flag5==1) )
flag6=1;
j++;
if(flag6==1)
break;
}
delay_1uSec(90000);
if(flag6==1)
{
PORTC |=0x0F;
flag1=0;
flag2=0;
flag3=0;
flag4=0;
flag5=0;
flag6=0;
}
delay_1uSec(90000);
//delay_1uSec(90000);
//delay_1uSec(90000);
PORTC =PORTC&0x00;
while(1)
{
}
}
The circuit diagram for this simulation in Proteus VSM is :
4. I have done all this simulation using Text mode.I would comment further in my
next post
regards
m.yasir