Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[AVR] sending and receiving sms with sim900 and avr

Status
Not open for further replies.

mohammad.habibi

Newbie level 6
Joined
Apr 9, 2015
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
94
hello all :)
I am new to this forum and this is my first post
I am using Sim900 for sending and receiving SMS with avr microcontroller atmega16
i programm this code thats write with codvision compilar
but this doesnt work :bang:
i dont know where is wrong,can u help me?
tnx all



Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*****************************************************
AVR Core Clock frequency: 11.059200 MHz
*****************************************************/
#include <mega16a.h>
#include <alcd.h>
#include <stdio.h>
#include <delay.h>
char at_cmgs[]={'A','T','+','C','M','G','S','=','"','0','9','1','1','8','5','3','0','9','6','1','"','\n'};
#define ctrl_z 0x1a
void main(void)
{
PORTC=0x00;
DDRC=0xFF;
PORTD=0x00;
DDRD=0x02;
// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud Rate: 9600
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x47;
// Alphanumeric LCD initialization
// Connections are specified in the
// Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu:
// RS - PORTC Bit 0
// RD - PORTC Bit 1
// EN - PORTC Bit 2
// D4 - PORTC Bit 4
// D5 - PORTC Bit 5
// D6 - PORTC Bit 6
// D7 - PORTC Bit 7
lcd_init(16);
while (1)
      {
       delay_ms(2000);
       puts("AT");
       delay_ms(2000);
       puts("AT");
       delay_ms(2000);
       puts("AT");
       delay_ms(4000);
       puts("ATE0");
       delay_ms(4000);
       puts("AT+CMGF=1");
       delay_ms(4000);
       puts(at_cmgs);
       delay_ms(1000);
       puts("this is test");
       delay_ms(1000);
       putchar(ctrl_z);
       lcd_clear();
       lcd_gotoxy(0,0);
       lcd_puts("message sent");
       }
}

 
Last edited by a moderator:

what is your observation about output?.Do test gsm module with hyper terminal first and check the avr and GSM RX,TX connections.
 
tnx for your helping
i connect the sim900 to pc with ft232 as you said and with hyper terminal first just i could get thise strings
RDY
CPUN: 1
CPIN: READY
CALL READY
but when in hyper terminal i want to send at command to sim900, doesnt sent any thing or sim900 doesnt sent anything... :(
 
Last edited by a moderator:

You should send CRLF after each command like "AT\r\n" or you can also send "AT\r" a delay of 1 sec and next command.
 
yes thats right
when i connect sim900 to atmega16 and sent CRLF(CRLF means enter) after each command,the sms sent
my code is here

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
printf("AT");
      putchar(enter);
      delay_ms(1500);
      printf("AT");
      putchar(enter);
      delay_ms(1500);
      printf("AT");
      putchar(enter);
      delay_ms(1500);
      printf("AT+CMGF=1");
      putchar(enter);
      delay_ms(1500);
      printf("AT+CMGS=\"09118530961\"");
      putchar(enter);
      delay_ms(1500);
      printf ("SMS SEND TEST ");
      putchar(ctrl_z);



enter is 0x0d and ctrl_z is 0x1a
now i want to try recieve the sms
tnx for your helping
 
Last edited by a moderator:

This is all you need.


Code C - [expand]
1
2
3
4
5
6
7
8
printf("AT\r\n");
      delay_ms(1000);
      printf("AT+CMGF=1\r\n");
      delay_ms(1000);
      printf("AT+CMGS=\"09118530961\"\r\n");
      delay_ms(2000);
      printf ("SMS SEND TEST ");
      putchar(ctrl_z);

 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top