Hello Friends,
This is the part of my project at "Arnium Technology Pvt. Ltd." start-up at IIT Kanpur. In this project I need to continuously collect incoming analog sensor value at ADC port of ATmega16 and send this value to a fixed mobile no. with an interval of 5mins.
AT Commands
AT Commands
These are the Attention Commands, used to control the many embedded systems. There are set of at commands for GSM modem.
So to send SMS we have to send set of AT commands to GSM modem.
Eclipse with ARM plug-in
ARM plug-in in Eclipse IDE gives very high end facility to write code and configure ATmega16. Please go through the link to configure Eclipse for embedded use.
http://www.bricsworld.com/?i=8a229cc7bde8eefc56bceba5afe84ef6f89e8379
UART (Universal Asynchronous Receiver and Transmitter) to RS 232 converter
Since the Operating Voltage level of ATmega16 and GSM modem is different; this converter is used to provide the synchronization between the two.
Embedded C code to configure ATmega 16
#include <avr/io.h>
#include "lcd_lib.h"
#include <util/delay.h>
#include<stdio.h>
#include<adc_lib.h>
#include<uart_lib.h>
int adcpin1,i;
char a[15];
int main(void )
{
LCDinit();
LCDclr();
ADCinit();// Initializes ADC in 10 bit mode
char b="*";
char d="*";
char q[]="at+cmgs=",p[]="+919005813359",r[]="IITK";
DDRB=0xff;
set_uartbaud(9600);
while(1){
LCDclr( );
adcpin1 = read_adc(0);// returns the digital value of the analog i/p connected to pin 0 of port A
LCDGotoXY(0,0); //LCD control command, used to set the position of cursor
sprintf(a," ADC Pin1 = %d",adcpin1);
LCDdisplay(a);
_delay_ms(3000);
sendstring_uart(q);
_delay_ms(1000);
sendchar_uart(0x22);
sendstring_uart(p); //sending AT Commands starts here
sendchar_uart(0x22);// actual command is : at+cmgs="mobileno"(return)message to be sent("ctrl+z") to complete the command.
sendchar_uart(0x0d);//sendchar is used to send character to atmega16 uart
_delay_ms(1000); //delay of 1 second
sendstring_uart(r);
_delay_ms(1000);
sendstring_uart(a);
sendstring_uart(" ");
_delay_ms(1000);
sendchar_uart(0x1a);
LCDclr( );
LCDGotoXY(0,0);
LCDdisplay("IITK");
sprintf(a,"ADCpin1= %d",adcpin1);
LCDGotoXY(5,0);
LCDdisplay(a);
LCDGotoXY(0,1);
for(i=0;i<50;i++)// approx 5 mins delay
_delay_ms(300000);
}
return 0;
}
So to send SMS we have to send set of AT commands to GSM modem.
Eclipse with ARM plug-in
ARM plug-in in Eclipse IDE gives very high end facility to write code and configure ATmega16. Please go through the link to configure Eclipse for embedded use.
http://www.bricsworld.com/?i=8a229cc7bde8eefc56bceba5afe84ef6f89e8379
UART (Universal Asynchronous Receiver and Transmitter) to RS 232 converter
Since the Operating Voltage level of ATmega16 and GSM modem is different; this converter is used to provide the synchronization between the two.
Embedded C code to configure ATmega 16
#include <avr/io.h>
#include "lcd_lib.h"
#include <util/delay.h>
#include<stdio.h>
#include<adc_lib.h>
#include<uart_lib.h>
int adcpin1,i;
char a[15];
int main(void )
{
LCDinit();
LCDclr();
ADCinit();// Initializes ADC in 10 bit mode
char b="*";
char d="*";
char q[]="at+cmgs=",p[]="+919005813359",r[]="IITK";
DDRB=0xff;
set_uartbaud(9600);
while(1){
LCDclr( );
adcpin1 = read_adc(0);// returns the digital value of the analog i/p connected to pin 0 of port A
LCDGotoXY(0,0); //LCD control command, used to set the position of cursor
sprintf(a," ADC Pin1 = %d",adcpin1);
LCDdisplay(a);
_delay_ms(3000);
sendstring_uart(q);
_delay_ms(1000);
sendchar_uart(0x22);
sendstring_uart(p); //sending AT Commands starts here
sendchar_uart(0x22);// actual command is : at+cmgs="mobileno"(return)message to be sent("ctrl+z") to complete the command.
sendchar_uart(0x0d);//sendchar is used to send character to atmega16 uart
_delay_ms(1000); //delay of 1 second
sendstring_uart(r);
_delay_ms(1000);
sendstring_uart(a);
sendstring_uart(" ");
_delay_ms(1000);
sendchar_uart(0x1a);
LCDclr( );
LCDGotoXY(0,0);
LCDdisplay("IITK");
sprintf(a,"ADCpin1= %d",adcpin1);
LCDGotoXY(5,0);
LCDdisplay(a);
LCDGotoXY(0,1);
for(i=0;i<50;i++)// approx 5 mins delay
_delay_ms(300000);
}
return 0;
}
To download complete project please go through the link:
http://www.giftjaipur.com/Naman/downloads/SMS sending using ATmega16 and GMS Modem.zip
Thank you