السلام عليكم ورحمة الله وبركاته..
أود من حضراتكم المساعدة في تنفيذ مشروعي وهو عمل monitoring ل درجة الحرارة من خلال ال sms علما انني استفدت كثيرا من شرحكم في الموقع بخصوص الموضوع المذكور.
أولا : ما اريد تنفيذه هو ارسال رسالة لجوال مرتبط بالمتحكم مثلا ... "Send Temperature" للجوال ... الجوال اريدة ان يرد عليي برسالة "Temperature is 100"
مثلا ... انا قمت بكتابة كود ولكن اشك في صحته وكذلك رسمة البروتس
ها هو الكود:
// LCD module connections
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections
int temp;
char text1[]="Temperature= ";
char txt[17];
char terminator=0x1A;
// AT commands initialization
const char atc0[] = "AT"; // Every AT command starts with "AT"
const char atc1[] = "ATE0"; // Disable command echo
const char atc2[] = "AT+CMGF=1"; // TXT messages
const char atc3[] = "AT+CMGS=\"+972597233195"; // Send message to cell number : 0123456789 (Enter your cell phone number instead of 0123456789)
const char atc4[] = "AT+CMGR=1"; // Command for reading message from location 1 from inbox
const char atc5[] = "AT+CMGD=1,4"; // Erasing all messages from inbox
// temperature measurment function
void Read_temp (void)
{
temp = ADC_Read(0);
temp = temp*0.4887;
IntToStr(temp,txt);
Lcd_Out(1,1,text1);
Lcd_Out(1,13,Ltrim(txt));
Lcd_Chr_Cp(0xdf);
Lcd_Chr_Cp('C');
Lcd_Chr_Cp(' ');
}
void send_sms ()
{
UART1_Write_Text("AT");
UART1_Write(13); //Enter
UART1_Write(10) ; // CTRL+Z
UART1_Write_Text("AT+CMGF=1");
UART1_Write(13);
UART1_Write(10) ;
Delay_ms(2000);
UART1_Write_Text("AT+CMGS=");
UART1_Write(34);
UART1_Write_Text("+972597233195");
Delay_ms(100);
UART1_Write(34);
UART1_Write(13);
UART1_Write(10) ;
Delay_ms(1000);
UART1_Write_Text("Teperature is: ");
UART1_Write_Text(temp); // temperature sending
UART1_Write_Text('C');
UART1_Write_Text(0x6F); // ÚáÇãÉ ÇáÍÑÇÑÉ
UART1_Write(13);//Enter
UART1_Write(26);
UART1_Write(13);
}
void read_sms()
{
char uart_rd;
if (UART1_Data_Ready()) // If data is received,
{
uart_rd = UART1_Read(); // read the received data,
if(strcmp(uart_rd,"Temperature")==0)
{
send_sms ();
}
}
}
void main()
{
ADC_Init();
UART1_Init(9600); // Initialize hardware UART1 and establish communication at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
ADCON1 = 0b00001110; // Analog channel select * AN0
TRISA=0b00000001;
trisc=0;
portc=0;
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
while(1)
{
Read_temp();
delay_ms(100);
read_sms();
delay_ms(1000);
}
}