C program on MikroC to recieve SMS from modem and control it on PIC mcu

Status
Not open for further replies.

HammadLakhani

Junior Member level 2
Joined
Oct 7, 2013
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Location
Karachi, Pakistan, Pakistan
Visit site
Activity points
261
Hi there.. I have made my C programming code on MikroC which is able to communicate between Modem and Microcontroller PIC16f877a. It is successfully sending AT commands to modem and modem responds ok which is indicated by LED lights connected. I need some assistance on how I will program it to receive an SMS and control respective LEDs. IF we receive AT command response from AT+CMGR=1 it will give sms date ,time etc along with SMS. How will I make it read ONLY the sms and control an LED with that. I am going to update my code here. Please assist as possible SO MANY THANKS IN ADVANCE
 

there are functions in micro C already built for you. check those functions like UART READ UART SEND etc.

you can use those function to get the SMS to a string. a long string.

afterwards include string.h C library on top or by other means, check for some sent charactors in the string which is a replica of the SMS.

if the characters match, you can lighten up the LED.

You have to have good knowledge in C to do this.
If you are not in a hurry, I recommend you take some C courses such as in edx.org to get better at C programming.
 
Thanx alot my bro for helping... But yeah I am in REALLY hurry its LAST WEEK for submition. I am still stuck on how would I make an LED Light up by SMS. My Modem does communicate with MCU with responding to AT commands and indicating other LED lights. But I need to make it READ SMS in such a way for example I send a number "1" to modem so that then it turns on LED 1 on LED board. Can you or anyone PLEASE just give an idea if someone has done something alike..... THANKS SO ALOT IN ADVANCE. Heres my code:

#include "LCDdrive.h"
char uart_rd;
char output;



void main() {

LCD_initialise();
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize

TRISD=0x00;
TRISC6_bit = 0;
TRISC7_bit = 1;
//PORTC=0;
PORTD=0;
// U1MODEbits.ALTIO = 1; // un-comment this line to have Rx and Tx pins on their alternate
// locations. This is used to free the pins for other module, namely the SPI.



UART1_Write_Text("AT");
UART1_Write(10);
UART1_Write(13);
UART1_Read(); // read the received data,
UART1_Read_Text(output, "OK", 10); // reads text until 'OK' is found
UART1_Write_Text(output); // sends back text
PORTD=0x01;
LCD_putch(output); // Print the character. It can show a character or string typed in Send window on Receive window and LCD

UART1_Write_Text("AT+CMGF=1");
UART1_Write(10);
UART1_Write(13);
UART1_Read(); // read the received data,
UART1_Read_Text(output, "OK", 10); // reads text until 'OK' is found
UART1_Write_Text(output); // sends back text
PORTD=0x02;
LCD_putch(output); // Print the character. It can show a character or string typed in Send window on Receive window and LCD

UART1_Write_Text("AT+CMGD=1");
UART1_Write(10);
UART1_Write(13);
UART1_Read(); // read the received data,
UART1_Read_Text(output, "OK", 10); // reads text until 'OK' is found
UART1_Write_Text(output); // sends back text
PORTD=0x04;
LCD_putch(output); // Print the character. It can show a character or string typed in Send window on Receive window and LCD

UART1_Write_Text("AT+CMGR=1");
UART1_Write(10);
UART1_Write(13);
UART1_Read();

while (1) { // Endless loop
if (UART1_Data_Ready()) { // If data is received,
uart_rd = UART1_Read(); // read the received data,
UART1_Write(uart_rd); // and send data via UART
PORTD=0xFF;
LCD_putch(uart_rd); // Print the character. It can show a character or string typed in Send window on Receive window and LCD
}


}



}
#include"LCDdrive877A.c"
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…