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.

this is my code in MICRO C. i don't know how to put the read temperature in the UART_

Status
Not open for further replies.

Neil Paloma

Newbie level 1
Newbie level 1
Joined
Jan 30, 2014
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
4
Code:
void GSM_Init(void);
void GSM_send(void);
void GSM_receive(void);
// LCD module connections
sbit LCD_RS at RB0_bit;    // rs connection at rb2
sbit LCD_EN at RB1_bit;    // en connection at rb3
sbit LCD_D4 at RB2_bit;    // d4 connection at rb4
sbit LCD_D5 at RB3_bit;    // d5 connection at rb5
sbit LCD_D6 at RB4_bit;    // d6 connection at rb6
sbit LCD_D7 at RB5_bit;    // d7 connection at rb7


sbit LCD_RS_Direction at TRISB0_bit;    // data direction setting
sbit LCD_EN_Direction at TRISB1_bit;    // data direction setting
sbit LCD_D4_Direction at TRISB2_bit;    // data direction setting
sbit LCD_D5_Direction at TRISB3_bit;    // data direction setting
sbit LCD_D6_Direction at TRISB4_bit;    // data direction setting
sbit LCD_D7_Direction at TRISB5_bit;    // data direction setting
// End LCD module connections

unsigned char x;
float volt,temp;                  // VARIABLE FOR READING AND STORING VALUES
unsigned char   volt_char[15];    // STRING (ARRAY OF CHARACTERS) VARIABLE FOR LCD DISPLAY
//char temp_c[2];



void init() // initialization routine definition (register

{
 adcon1=0   ;    // configure all portA and portE chanels as analog
 trisa.f2=1 ;    // set ra2 data direction as incoming
 trisc.f3=0;
 portc.f3=0;


 lcd_init() ;    // initialize lcd connections
 lcd_cmd(_lcd_clear)     ;// clear lcd
 lcd_cmd(_lcd_cursor_off);// turne off hte cursor
}




void main() // main routine definition
{

 init();    // call the initialization routine
 lcd_out(1,3,"temp"); // show <voltmeter> on 3rd column of first row of

 lcd_out(2,15,"c");        // show <V> on 15th column of 2nd row of lcd
 UART1_Init(9600);     //Initialize and establish communication at 9600 bps
Delay_ms(50);
UART1_Write_Text("AT+CMGD=1");  //Delete mesage sotred in inbox1
UART1_Write(0x0D);

 while(1)   // step into infinite loop
   {
    volt=adc_read(2); // take the analog signal value fron analog channel

    volt=volt/1024;   // extracting voltage value from 10 bit resolution
    volt=volt*5000;   // extracting voltage value from 10 bit resolution
    temp=volt/10;     // CONVERTING THE VOLTAGE VALUE TO CENTIGRADE SCALE




    floattostr(temp,volt_char);// convert the voltage value to string for

    lcd_out(2,1,volt_char);    // show the string (voltage value) on

    delay_ms(300);
    lcd_cmd(_lcd_clear);
    lcd_out(1,3,"temp"); // show <voltmeter> on 3rd column of first row

    lcd_out(2,15,"c");   // show <V> on 15th column of 2nd row of lcd
    if(temp>=29)     // if temperature rises TO OR above 32
      {
       portc.f3=1; // switch on the dc motor CONNECTED TO RC3 PIN OF MCU
       GSM_Init();                   //calls GSM_Init function
  GSM_send();              //calls GSM_send function
      }
    else if(temp<29) // if temperature falls bellow 32
      {
       portc.f3=0; // switch off the dc motor CONNECTED TO RC3 PIN OF MCU
      }
   }
}
void GSM_Init(void)
{
  UART1_Write_Text("AT\r");
  UART1_Write_Text("AT+CMGF=1");      //Text Mode
  UART1_Write(0x0D);                                //<CR>
  Delay_ms(100);
  UART1_Write_Text("AT+CMEE=2");      //Write Mode
  UART1_Write(0x0D);                               //<CR>
  Delay_ms(100);
  UART1_Write_Text("AT+CFUN=1");      //Full Phone Functionality
  UART1_Write(0x0D);                               //<CR>
  Delay_ms(100);
}



void GSM_send(void)
{

  UART1_Write_Text("AT+CMGS=\"09239164284\"");    //send SMS to this number
  UART1_Write(0x0D);                              //<CR>
  Delay_ms(100);
  UART1_Write_Text("WARNING! Temperature is:"  );
  UART1_Write_Text(volt_char);  //message to be sent
  UART1_Write(0x1A);                                  //<CTRL+Z>
  Delay_ms(100);
}
 
Last edited by a moderator:

Mention which modem you are using. Do you want to send Temperature data as SMS? When do you want to send data as SMS, only when data changes?

Zip and post your mikroC project files. I will modify it.
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top