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 / ATmega GSM

ATmega GSM

|

Microcontroller › AVR › ATmega GSM

  • This topic has 5 replies, 4 voices, and was last updated 6 years, 4 months ago by Saatwik.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • July 12, 2017 at 6:34 pm #4675
    F206
    Participant

    Hello, I am trying to configure an atmega microcontroller to be able to send sms messages through the gsm, I was able to do it with an AT32U3C, but I am runing into trouble with this board.

    my code goes as follows#include <asf.h>

    #include <avr/io.h>
    #include <util/delay.h>
    #include <stdlib.h>
    #include <usart_megarf.h>
     
    #define USART_BAUDRATE 9600
    #define BAUD_PRESCALE (F_CPU/ (USART_BAUDRATE *16UL)) -1)
     
    void usart_init();
    void usart_transmit(char data);
    void usart_transmit_string (char *str);
    void send_sms(char *number, char *text);
     
     
    int main (void)
    {
    board_init();
    usart_init();
    send_sms("3433339487",129", "Quectel M10");
    }
     
    void usart_init()
    {
    UBRR1H = (unsigned char) (BAUD_PRESCALE >> 8); /
    UBRR1L = (unsigned char)  BAUD_PRESCALE;
    UCSR1B = (1<<RXEN1)  | (1<<TXEN1);
    UCSR1C = (1<<UCSZ10) | (1<<UCSZ11);
    }
     
    void usart_transmit(char data)
    {
    while(!(UCSR1A & (1<<UDRE1)));
    UDR1 = data;
    }
     
    void usart_transmit_string (char *str)
    {
    while(*str)
    {
    usart_transmit(*str++);
    }
    }
     
    void send_sms(char *number, char *text)
    {
     
    usart_transmit_string("AT+IPR=57600");
    usart_transmit_string("r");
    delay_ms(500);
     
    usart_transmit_string("AT+CMGF=1"); // select text mode
    usart_transmit_string("r"); // ctrl-M
    delay_ms(500);
     
    usart_transmit_string("AT+CMGS="");            // start SMS command
    usart_transmit_string(number);
    usart_transmit_string("r");
    delay_ms(500);
     
    usart_transmit_string(text);
    usart_transmit_string("r");
    delay_ms(500);
     
    usart_transmit_string("x1a");     // ctrl-Z
     
    }
     
    anyone has any idea where I'm going wrong ?
    July 13, 2017 at 7:05 am #14624
    Hari Prasaath K
    Participant

    At which point you are facing a problem. like whether showing

    1 . error in the program or

    2. just message is not sending during operation

    If the second one is the case try to add more delays while GSM AT commands

    July 13, 2017 at 2:05 pm #14625
    F206
    Participant

    the error is that the message is not being sent, i had the same delays inanotehr microcontroller (AT32UC3C), so i think my problem is with initializing the usart

    July 14, 2017 at 5:42 am #14626
    Hari Prasaath K
    Participant

    Check with the network in GSM, Before sending a message using coding, use GSM AT command any terminal software to test to verify whether GSM is working properly, also check with your hardware connections.

    Check with below link it will help you, If u come again with the same problem, ask your querry

    https://www.engineersgarage.com/contribution/how-to-interface-GSM-SIM-300-modem-with-atmega32-to-send-and-receive-SMS

    July 16, 2017 at 11:57 am #14629
    Ashutosh Bhatt
    Participant

    first try to simulate your code using proteus

    in proteus u can find virtual serial terminal in which you can find out if your message or string is sent to GSM module or not?

    February 16, 2019 at 7:18 am #15022
    Saatwik
    Participant

    Make sure your GSM module is powered properly. just press reset button in MCU after the GSM module got network and nework led start blinking becouse GSM start work after getting network but MCU giving AT command at first before GSM got network may be that's a reason 

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

RSS Recent Posts

  • Saga 1400sv vinyl cutter motherboard issue June 20, 2025
  • PIC KIT 3 not able to program dsPIC June 20, 2025
  • Wideband matching an electrically short bowtie antenna; 50 ohm, 434 MHz June 20, 2025
  • using a RTC in SF basic June 20, 2025
  • Relay buzzing after transformer change? June 20, 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