EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Replies / Please help me, i want to

Please help me, i want to

|

Microcontroller › AVR › By using GSM SIM 300M and Atmega8 , How to write coding for sending SMS to 3 Persons when any one the port pin gets high …? › Please help me, i want to

December 15, 2012 at 7:30 pm #8839
ahmed qureshi
Participant

Please help me, i want to send msg via gsm sim900D. I am unable to send txt using this code

 

 
#define F_CPU 11059200UL
 
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdio.h>
#include <stdlib.h>
#include “lcd.h”
 
#include <util/delay.h>
#include <inttypes.h>
#include <string.h>
 
void send_msg();
void init_USART();
void usart_send_string(char *str );
void usart_send(char data);
void gsm_cmd(char *cmd);
 
void init_USART()
{
 
unsigned int baud=71; //(UBRR= (Fos/ (16*baudrate) )-1  )
   UBRRH =(unsigned char)(baud>>8);
   UBRRL=(unsigned char)baud;
   UCSRC|=(1<<URSEL)|(3<<UCSZ0);
  //Enable The receiver and transmitter
   UCSRB |= (1<<RXCIE) | (1 << RXEN) | (1 << TXEN);   // Turn on the transmission reception .
 
sei();
}
ISR (USART_RXC_vect)
{
 
unsigned char value;
value = UDR; // Fetch the received byte value into the variable “value”
len_recieved++;
    recieved_msg[len_recieved]=value;
if(data_flag==-1)
data_flag=0;
}
 
}
void usart_send_string(char *str )
{
while((*str)!=’’)
{
if(*str==0x5C)
str++;
usart_send(*str);
str++;
}
}
 
void usart_send(char data)
{
while(!(UCSRA & (1<<UDRE)));
UDR=data;
}
 
void gsm_cmd(char *cmd)
{
usart_send_string(cmd);
usart_send(0x0D);
_delay_ms(500);
}

 

 

 

 

 

void send_msg()
{
 
 char cmd1[]=”AT+CMGF=1″;
 char cmd2[]=”AT+CMGS =“+923017698646″”;
 char msg[]=”msg sent from gsm”;
 
 
gsm_cmd(cmd1);
_delay_ms(3000);
 
 
gsm_cmd(cmd2);
_delay_ms(1000);
 
gsm_cmd(msg);
_delay_ms(100);
usart_send(0x1A);
 
LCD_write(‘S’);
LCD_write(‘E’);
LCD_write(‘N’);
LCD_write(‘T’);
 
}
int main(void)
{
DDRA=0xff; // making LCD_DATA port as output port
DDRB=0x07; // making signal as out pute
 
init_LCD(); // initialization of LCD
_delay_ms(50); // delay of 50 milli seconds
 
init_USART();
    
send_msg();
          
  while(1);  
}
 

RSS Recent Posts

  • Hitachi SuperScan Elite 802 CRT Monitor Issues (Model CM802U) December 7, 2025
  • Sanity Check – Peltier "Cooler" for Heating and Cooling December 7, 2025
  • My Advanced Realistic Humanoid Robots Project December 7, 2025
  • Funny Images Thread! December 7, 2025
  • I am ready to move from electrical and electronics field but confused where ? December 7, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise