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 / Topics / Sending message from AVR atmega32 using sim900D

Sending message from AVR atmega32 using sim900D

|

Microcontroller › AVR › Sending message from AVR atmega32 using sim900D

  • This topic has 2 replies, 3 voices, and was last updated 12 years, 6 months ago by Hemraj.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • December 15, 2012 at 9:42 pm #2023
    ahmed qureshi
    Participant

    Please help me in sending txt via gsm sim900D using AVR.

    I am using following 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); 
    }

    December 17, 2012 at 6:07 am #8842
    AJISH ALFRED
    Participant

    Hi Ahmed,

    You haven’t mentioned the issue you are facing with the project. I guess your code is not working

    Before testing the code make sure that your GSM module is working, connect it to the serial port of PC and try the AT commands for SMS manually using hyperterminal.

    December 18, 2012 at 9:04 am #8845
    Hemraj
    Participant

    If your code is not working then you can do one modification in function:

     

    void gsm_cmd(char *cmd)
    {
    usart_send_string(cmd);

    usart_send(0x0A);
    usart_send(0x0D);
    _delay_ms(500);
    }

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Can I make two inputs from one?? July 9, 2025
  • The Analog Gods Hate Me July 9, 2025
  • How to make string LEDs? July 9, 2025
  • Fixing board, Easy question HEX SCHMITT July 9, 2025
  • It's Amazing What A Buck And A Quarter.... July 8, 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