lockman_akim
Advanced Member level 1
Hi all,
i already spent almost a week to figure it out this problem. I try to communicate between pic with gsm modem. PIC seem likes sending the correct AT command to GSM modem. but it not received properly by the gsm modem. watch the simulation below. in the schematic, the DB9 connector is the virtual serial port which have a link to real physical GSM modem. please check my code also which written in Mikro-C.
i already spent almost a week to figure it out this problem. I try to communicate between pic with gsm modem. PIC seem likes sending the correct AT command to GSM modem. but it not received properly by the gsm modem. watch the simulation below. in the schematic, the DB9 connector is the virtual serial port which have a link to real physical GSM modem. please check my code also which written in Mikro-C.
Code:
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
// End LCD module connections
//Declare Function
void read_sensor();
void send_msg();
//Declare Variable
int analog_data;
void main()
{
Uart1_init(9600);
delay_ms(100);
ADCON1=0b10000010;
TRISA=0b111111;
ADC_Init();
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Cmd(_LCD_CLEAR);
analog_data = 0;
do
{
Lcd_Out(1,1,"Smart Detection");
Lcd_Out(2,1,"System");
read_sensor();
}
while (1);
}
void read_sensor()
{
analog_data = ADC_Read(0);
if (analog_data > 700)
{
send_msg();
}
}
void send_msg()
{
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"Sending Report");
Uart1_Write_Text("AT+CMGS=");
delay_ms(100);
Uart1_write(0x22);
delay_ms(100);
Uart1_Write_Text("0176052241");
delay_ms(100);
Uart1_write(0x22);
delay_ms(100);
Uart1_Write(0x0D);
delay_ms(100);
Uart1_write_Text("9 Jln Tasek Barat 9, Taman Anda 31400, Ipoh Perak");
delay_ms(100);
Uart1_Write(0x0D);
delay_ms(100);
Uart1_Write(26);
delay_ms(100);
Uart1_Write(0x0D);
delay_ms(100);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"Report Sent");
delay_ms(60000);
}