Microcontroller › AVR › ATmega GSM
- This topic has 5 replies, 4 voices, and was last updated 5 years, 8 months ago by Saatwik.
-
AuthorPosts
-
July 12, 2017 at 6:34 pm #4675F206Participant
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 >> ; /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 modeusart_transmit_string("r"); // ctrl-Mdelay_ms(500);usart_transmit_string("AT+CMGS=""); // start SMS commandusart_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 #14624Hari Prasaath KParticipantAt 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 #14625F206Participantthe 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 #14626Hari Prasaath KParticipantCheck 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
July 16, 2017 at 11:57 am #14629Ashutosh BhattParticipantfirst 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 #15022SaatwikParticipantMake 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
-
AuthorPosts
- You must be logged in to reply to this topic.