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.

[PIC] interfacing PIC16F877 with Sony Ericson T230 and temterature sensor LM35

Status
Not open for further replies.

elyanko

Newbie level 3
Joined
Aug 23, 2013
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Location
Bamenda
Activity points
66
Hi, i am currently doing a college project which has to be due by June. i actually want to design an alarm system to detect fire in a room and send text message to the owner. i have done all analysis and seem to be having problems with the code. Can some one help me out.
interfacing PIC16F877 with Sony Ericson T230 and temterature sensor LM35 to send text message to a specified number.
thanks
 

Can you upload the code and the circuit diagram?
 

Below you will find the code and as attachement my circuit diagram as u requested.
Part 1 of my code is the temperature monitoring system
Part 2 is the code to send SMS using sony erricson T230 as GSM module
my problem now is to harmonise the 2 sub codes to be able to send pre defined text message when temperature is too high. Message like FIRE!

Both codes are written in mikroC Pro

PART 1: TEMPERATURE MONITORING CODE

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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// initialisation afficheur LCD
  // Lcd pinout settings
sbit LCD_RS at RC4_bit;
sbit LCD_EN at RC5_bit;
sbit LCD_D7 at RC3_bit;
sbit LCD_D6 at RC2_bit;
sbit LCD_D5 at RC1_bit;
sbit LCD_D4 at RC0_bit;
 
// Pin direction
sbit LCD_RS_Direction at TRISC4_bit;
sbit LCD_EN_Direction at TRISC5_bit;
sbit LCD_D7_Direction at TRISC3_bit;
sbit LCD_D6_Direction at TRISC2_bit;
sbit LCD_D5_Direction at TRISC1_bit;
sbit LCD_D4_Direction at TRISC0_bit;
   unsigned char acqui ;
   // variables enables to store temperature and humidity digital values
   unsigned temp;
   float long temp_o; // originals values of temperature and humidity
   unsigned char i,j, valueT[7],testT[14];
   char *hu;
   void Move_Delay() {                  // Function used for text moving
  Delay_ms(200);                     // You can change the moving speed here
}
void main() {
TRISA=0xFF;
Lcd_Init();
 // displaying information of LCD screen
    Lcd_Cmd(_LCD_CLEAR);  LCD_cmd(_LCD_CURSOR_OFF);
    Lcd_Out(0, 6, "TEMP:");
 //######-- started sensor temperature
   temp = ADC_Read(0); // digital value ie InputValue/q  where q=5/1023
   temp_o = temp*(5.0/1023.0); //conversion for obtain the original input in volatge
   temp_o = temp_o * 100; // three ruler enable to obtain the corresponding degree
   temp = (int)temp_o ;
   temp = (temp> 5) ? (temp):(temp+1); // exact value of sensor
    LongToStr(temp,testT);
    j = 0;
  for(i = 0;i<=11;i++)
  {
   if(testT[i]!=' ')
   {
   valueT[j] = testT[i];
   j++;
   }
  }
  Lcd_Out(2,1,"   ");
  Lcd_Out(1,12,valueT);Lcd_Out(1,15,"C");
  /* the protocole that enable to send information between pic and Pc as follows:
    - when we send the temperature, we send firstly letter "T" like temperature
    - if a percent humidity, we send firstly letter "H"  */
    UART1_Write_Text("T");
  UART1_Write_Text(valueT);
  // UART1_Write_Text("°C");
   /*##########Interval testing started###########*/
   if( (temp >=0) && (temp < 36) ) {
             //enclosure is cool
       Lcd_Out(2,6, "         ") ;
        Lcd_Out(2,6, "Cool")  ;
   }
 
   else if((temp >=36) && (temp < 38)){
        // temperature is normal
        Lcd_Out(2,6, "         ") ;
        Lcd_Out(2,3, "Normal Temp")  ;
 
   }
   else {
        // temperature is too hot
        Lcd_Out(2,6, "         ") ;
        Lcd_Out(2,6, "Too Hot")  ;
        // Moving text
  while(1) {                         // Endless loop
 
 
    for(i=0; i<5; i++) {             // Move text to the right 7 times
      Lcd_Cmd(_LCD_SHIFT_RIGHT);
      Move_Delay();
    }
      for(i=0; i<5; i++) {             // Move text to the right 7 times
      Lcd_Cmd(_LCD_SHIFT_LEFT);
      Move_Delay();
    }
 
 
   }
     //###########---end sensor temperature----###########
     }
     while(1);
 
 
}



PART 2: CODE TO SEND SMS


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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
unsigned char* GSM_MSG1 = "AT\n";   //"ATQ0V1E1S0=0\r\n";
unsigned char* GSM_MSG16 = "\r";   //"ATQ0V1E1S0=0\r\n";
unsigned char* GSM_MSG6 = "0x0D\n";               //13   for enter
unsigned char* GSM_MSG20 = "ATD23779461880\n";
unsigned char* GSM_MSG8 = "AT+CFUN=0\n";
unsigned char* GSM_MSG9 = "AT+CFUN=1\n";
unsigned char* GSM_MSG10 = "AT+CMGF=1\n";
unsigned char* GSM_MSG11 = "AT+CMGS=\"23779461880\"\n";
unsigned char* GSM_MSG12 = "0x1a\n";
unsigned char* GSM_MSG13 = "ok 0X1a\n";
unsigned char* GSM_MSG14 = "AT+CMGS=1\n";
unsigned char* GSM_MSG15 = "AT+CMGS=1\n";
 
void main() {
int ctr;
TRISA= 0xff;      // Configuring PORTA as Input
TRISC=0x0;        // Configuring PORTC as Output
PORTC=0;
PORTA=0;
 
 while(1)
 {
if(PORTA==0x01)        // For the call command using AT commands.  The codes here are working...
{
 
      PORTC = 0X01;             // Test to see if programme started running.
      Delay_ms(1000);
 
 
      UART1_Init(9600);            // Initialize UART module at 9600 bps
      Delay_ms(1000);
 
      UART1_Write_Text(GSM_MSG1);
      Delay_ms(3000);
 
      UART1_Write_Text(GSM_MSG16);
      Delay_ms(2000);
 
      UART1_Write_Text(GSM_MSG20);
      Delay_ms(5000);
 
      UART1_Write_Text(GSM_MSG16);
      Delay_ms(15000);
 
      UART1_Write_Text(GSM_MSG6);
      Delay_ms(10000);
 
      UART1_Write_Text(GSM_MSG16);
      Delay_ms(5000);
 
      PORTC=0x00;
      Delay_ms(5000);
}
else if(PORTA==0x02)    //For the message sending using AT commands via UART... The codes here are not working...
{
      PORTC=0x02;
 
      UART1_Init(9600);                         // Initialize UART module at 9600 bps
      Delay_ms(1000);
 
     UART1_Write_Text(GSM_MSG1);
      Delay_ms(2000);
 
      UART1_Write_Text(GSM_MSG16);
      Delay_ms(3000);
 
      UART1_Write_Text(GSM_MSG10);
      Delay_ms(3000);
 
      UART1_Write_Text(GSM_MSG16);
      Delay_ms(3000);
 
      UART1_Write_Text(GSM_MSG11);
      Delay_ms(3000);
 
      UART1_Write_Text(GSM_MSG16);
      Delay_ms(4000);
 
      UART1_Write_Text(GSM_MSG13);
      Delay_ms(6000);
 
 
      PORTC=0x00;
      Delay_ms(5000);
}
 
 
else
{
PORTC=0;
}
 }
 
}

 

Attachments

  • isis_project.rar
    15.8 KB · Views: 102
Last edited by a moderator:

The first code...that is the one to display temperature and humidity looks correct.The second code....well I do not have any prior experience with GSM module interfacing..so I cannot comment.But...is the code not getting compiled?or if it _is_ getting compiled..it is not performing in the required manner?
 

the second is compiling, but the problem is that i am looking for a means to combine both codes to get my desired objective. my desired objective is to realise a GSM-MICROCONTROLLER BASED FIRE DETECTOR ALARM SYSTEM. I want that my system should be able to send SMS when there is a fire outbreak and the owner is not home. i dont know whether to use as sub-routines. i am hooked up at this point.
Udayan please post this problem to your other friends. you seem to be the only one wishing to help. please talk to others about this prob.
Both codes are compiling perfectly.
MEMBERS PLEASE HELP ME OUT
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top