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.

PIC16F877A + GSM Modem Simple Send SMS Program NOT working

Status
Not open for further replies.

trophy

Newbie level 2
Joined
May 17, 2011
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,303
Hey guys. I'm working on this design project and I'm having trouble using my GSM modem (SIM900D) to send a text message. I'm using PIC16F877A as my MCU and I'm using it's UART functionality.

TX (MCU) - RX (modem)
RX (MCU) - TX (modem)

Here's my code. I'm also using PIC C Compiler.

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
#include <stdio.h>
#include <pic.h>
#include <16F877A.h>
#device adc=16
 
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOBROWNOUT //No brownout reset
 
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bi ts=8,stream=PORT1)
 
 
void main()
{
SET_TRIS_A(0x01); //bit 0 as input
 
//i put a 10-second delay in here for the GSM Modem to initialize
 
printf("AT+CMGF=1\r\n"); //set to text mode
printf("AT+CMGS=\"xxxxxxxxxxx\"\r\n"); //put your number here
printf("this is a message!");
putchar(0x1A);
 
output_high(PIN_A2);
}


I put an LED at PIN A2 to see if my code reaches the end of the main function. It does light up after some delay and I think there must be something wrong with my code in the middle. Could you guys help me with this? I would greatly appreciate your help.
 
Last edited by a moderator:

search the forum.... already answered many times.....

---------- Post added at 17:18 ---------- Previous post was at 17:17 ----------

first test modem in hyperterminal, if it is working, then test your code with hyperterminal and then integrate both the hardwares...
 

It's working using HyperTerminal. If I use fprintf(PORT1, "....."); that would just be the same with my printf("....") commands, right? I'm thinking it's the putchar command. Should it be putc instead?
 

i solved the problem of hyperterminal and cntrl+Z. i changed the hyperterminal which i was using. I used puTTY a terminal software and by using it i could send the SMS from modem. actually the previous hyperterminal was not having all the facilities like(cntrl+Z).
but now Iam facing new problem. i have programed 8051 to send the commands to GSM modem to send SMS. I have connected the TX pin of 8051 board to RX pin of modem & the RX pin of 8051 board to TX pin.also i have short the GND pins.But there is no response. the controller is sending the instructions properly if we see it on hyperterminal. but the modem is not giving any response even for simple command like "AT".:-(

How sholud i connect the modem to 8051 board?????
should i keep open the other pins(RTS, CTS,DTR, DCD, DSR) of DB9 connector on modem?????
what should I do of flow control in modem???????????
or should I send some instruction to modem at first?????
 

Is there AT+CNMI command for SIM900D...check that...

This is SMS initialization:


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
bool gsmSMS::smsInit(){
 
    if(!sendRecQuickATCommand("AT+CMGF=1")) return 0;               // set tesxt mode not PDU   
    //Configuration for receive/send SMS
    if(!sendRecQuickATCommand("AT+CNMI=0,0,0,0,0")) return 0;   // set receive action, all quite on the western..
    //SET to no buffer no notification on recive using CNMI
    //USE AT+CNMI=2,2,2,1,0 to have messages send to DTE on reception.  
    //<buffer notification>, <no notification sent to DTE>, 
    //<no brodcast notification>,<no status notification>, 
    //<when buffering switches state flushes all stored notification to DTE >
    sendRecQuickATCommand("AT#SMSMODE=0");          // set extended smsmode off error
                                    // means not supported anyway   
return 1;
}

 
Last edited by a moderator:

try this code,,,,it's working perfectly,,,,,

Code:
#include <16F877A.h>
#include <stdio.h>
//#device adc=16
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOBROWNOUT //No brownout reset
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bi ts=8,stream=PORT1)
 
 
void main()
{
SET_TRIS_A(0x01); //bit 0 as input
 
//i put a 10-second delay in here for the GSM Modem to initialize
printf("AT\r"); 
delay_ms(100);
printf("AT+CMGF=1\r"); //set to text mode
delay_ms(100);
printf("AT+CMGS=+919788110130\r"); //put your number here
delay_ms(100);
printf("this is a message!");
putchar(0x1A);
 delay_ms(100);
output_high(PIN_A2);
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top