2016-03-08 1 views
0

J'ai essayé d'envoyer des SMS en utilisant un module SIM300. Bien que le module fonctionne correctement lorsqu'il est essayé avec Hyper Terminal, mais je ne suis pas en mesure d'envoyer le SMS en utilisant PIC.SIM300 envoyer des sms dans Mikroc en utilisant PIC16f

est sous le code que j'ai essayé (LCD également inclus (Lcd fonctionne très bien)):

Programmation: MikroC
Controller: PIC16F877A
Module: SIM300

sbit LCD_RS at RB4_bit; 
sbit LCD_EN at RB5_bit; 
sbit LCD_D7 at RB3_bit; 
sbit LCD_D6 at RB2_bit; 
sbit LCD_D5 at RB1_bit; 
sbit LCD_D4 at RB0_bit; 

// Pin direction 

sbit LCD_RS_Direction at TRISB4_bit; 
sbit LCD_EN_Direction at TRISB5_bit; 
sbit LCD_D7_Direction at TRISB3_bit; 
sbit LCD_D6_Direction at TRISB2_bit; 
sbit LCD_D5_Direction at TRISB1_bit; 
sbit LCD_D4_Direction at TRISB0_bit; 

void main(){ 
//CMCON = 7;      //Disable Comparators 
Lcd_Init();      // Initialize LCD 
UART1_init(9600);     //Initiate baud rate to 9600 
Delay_ms(500);      //Delay 
UART1_Write_Text("AT+CMGF=1");  //Write "AT+CMGF=1" 
UART1_Write(0x0D);     // mean (ENTER) 
Delay_ms(500);      //Delay 
UART1_Write_Text("AT+CMGS=");  //Write "AT+CMGS=" 
UART1_Write(0x22);     //Write (") 
UART1_Write_Text("9449869619");  //Number SMS send to 
UART1_Write(0x22);     //Write (") 
UART1_Write(0x0D);     // mean (ENTER) 
Delay_ms(500);      //Delay 
UART1_Write_Text("WELCOME"); 
UART1_Write(0x0D);  //Words to be sent 
UART1_Write(0x1A); 
       //Write "ctrl+z" 
Delay_ms(500);      //Delay 
Lcd_Out(1,1,"MSG SENT SUCESSFULLY"); // Write text in first row 

} 
+0

Vous avez testé le module avec Hyperterminal? Avez-vous essayé de tester votre PIC avec Hyperterminal? –

Répondre

0

Vous devriez essayer

Uart1_Write_Text ("AT + CMGF = 1 \ r");

parce que le "\ r" représente "entrée" ou "retour" et parfois "0x0D" ne fonctionne pas dans les microcontrôleurs. Je l'ai utilisé et ça marche très bien pour moi.