Skip to main content

GSM message sending system






  • Aim: To send a message using gsm module from microcontroller to phone.
  • Code:
#define F_CPU 8000000UL
#define BAUD RATE 9600
#include<avr/io.h>
#include<util/delay.h>


void lcd_cmd(char value);
void lcd_data(char value);
void lcd_string(char *str);
void lcd_num(unsigned int number);
void usart_init();
void usart_transmit(char x);
char usart_recieve();
int j=0;
void initialize()
{
lcd_cmd(0x01); //clear LCD
lcd_cmd(0x02);    //home position
lcd_cmd(0x06);    //L-R
//lcd_cmd(0x04);
lcd_cmd(0x28); //4 bit mode
lcd_cmd(0x0C);    //character generation
}

void lcd_cmd(char value)
{
int un,ln; // pc7-pc4 = un ; pc3-pc4 =ln
un=value&0xF0; // & is anding function
PORTC=0x04|un;
_delay_ms(2);
PORTC=0x00|un;
_delay_ms(2);
ln=(value<<4)&0xF0; //<<=left shif by 4 bits
_delay_ms(2);
PORTC=0x04|ln;
_delay_ms(2);
PORTC=0x00|ln;
}

void lcd_data(char value)
{
int un,ln; // pc7-pc4 = un ; pc3-pc4 =ln
un=value&0xF0; // & is anding function
PORTC=0x05|un;
_delay_ms(2);
PORTC=0x01|un;
_delay_ms(2);
ln=(value<<4)&0xF0; //<<=left shif by 4 bits
_delay_ms(2);
PORTC=0x05|ln;
_delay_ms(2);
PORTC=0x01|ln;
}

void lcd_string(char *str)
{
int i=0;
while(str[i]!='\0')
{
lcd_data(str[i]);
i++;
}
}



void lcd_num(unsigned int number)
{
lcd_cmd(0x04);
int d=0;
if(number>0){
while(number!=0)
{
d=number%10;
lcd_data(d+48);
number=number/10;
}}
else lcd_string("0");
}


void usart_init(){
UBRRH=0;
UBRRL=51; // or 0x33
UCSRB=0x18;
UCSRC=0x86;
}

void usart_transmit(char x){
UDR=x; //data gets stored in UDR
lcd_cmd(0x80+j);
lcd_data(x);
j++;
while((UCSRA&0x20)==0);
}

char usart_recieve(){
while((UCSRA&0x80)==0);//Till it gets overflow
return UDR;
}

void read(char *str){
int i=0;
while(str[i]!='\0')
{
usart_transmit(str[i]);

i++;
}
}

int main(){
DDRC=0xFF;
initialize();
_delay_ms(2);
usart_init();

int k=0;
while(1){
k++;
if(k==1){
read("AT");
usart_transmit(0x2B);
read("CMGF");
usart_transmit(0x3D);
read("1");
usart_transmit(0x0D);
_delay_ms(10);
read("AT");
usart_transmit(0x2B);
read("CMGS");
usart_transmit(0x3D);
usart_transmit(0x22);
usart_transmit(0x2B);
read("916380327990");
usart_transmit(0x22);
usart_transmit(0x0D);
_delay_ms(10);
read("HELLO");
usart_transmit(0x1A);
usart_transmit(0x0D);
_delay_ms(100);
break;
}
}}



  • Hardware information: 
sim900 GSM module is used.
  • GSM Module







  •  Additional Information
1)Compatible with only 2g/3g networks.
2) one major application is that it can be used for automation of home. It can be used to control various devices using messages.
  • Conclusion: 
Message "hello" has been sent on the given phone number and this program was created using C programming in Avr studio software.

Comments

Popular posts from this blog

Python Ping Pong Game

Game: Ping Pong Libraries used: 1) pygame  2) Math 3) Random Version: Python 3.7 Python Code: -------------------------------------------------------------------------------------------------------------------------- import pygame import math import random pygame.init() dis=pygame.display.set_mode((600,400)) gameover=False white=(255,255,255) black=(0,0,0) red=(255,0,0) blue=(0,0,255) col=(0,255,0) x1=575 y1=200 dx1=0 dy1=0 x2=25 y2=185 dx2=1 dy2=0 c=0 t=0 font_style = pygame.font.SysFont(None, 50) def message(msg,color):     mesg = font_style.render(msg, True, color)     dis.blit(mesg, [300, 200]) font_style1 = pygame.font.SysFont(None, 30)    def show(msg,color):     mesg = font_style1.render(msg, True, color)     dis.blit(mesg, [300, 10])    clock=pygame.time.Clock() while not gameover:     for event in pygame.event.get():       ...

The Projectile Motion

GRAVITY This is a projectile motion simulator. It takes velocity and angle as input and gives an animated projectile motion with time of flight and range Time of flight: seconds Max height: meters Select option: Velocity(m/s): Angle: degrees Action

Lighting of a marriage garden

Aim: To design a basic lighting system for a standard marriage garden. Software: Autodesk Revit 2019 Plan of the Garden: Entrance: Stage: Food Area: 3D View of Stage: