Wireless temperature sensor using gsm and microcontroller

Wireless temperature sensor using gsm and microcontroller is designed to measure temperature from remote location and then send it to any where you want on your mobile through SIM900D gsm module.PIC16F877A microcontroller is used to measure temperature from LM35 temperature sensor and then microcontroller is interfaced with SIM900D gsm module to send temperature through sms to a recipient. You can also also use more than one sensors to measure other physical parameters from remote location and then send them to any number you want.

Circuit diagram

I have already posted articles on digital temperature sensor using pic microcontroller and how to send sms using gsm module and pic microcontroller. I recommend you to go through these articles before reading this article further. If you have gone through these articles, now you have knowledge about, how to measure temperature using pic microcontroller and lm35 sensor and how to send sms using gsm and pic microcontroller. I have just combined coding and circuit diagram of those two articles.Circuit Diagram of wireless temperature sensor using pic microcontroller is shown below :




wireless temperature sensor using gsm

wireless temperature sensor using gsm

In above circuit diagram temperature sensor can be located at remote location and you can connect more than one sensor like light sensor, motion sensor ,pressure sensor according to requirement of your project. Lcd is use optional. Gsm module is used to send sms to any mobile number.you can also use other wire less communication source like Bluetooth if distance is not more than 5 meter.This project have many applications in remote monitoring systems.you can change it with ease according to your specifications.

 Components list

The following bill of material doesn't include power supply components for microcontroller and gsm module :
Resistors,"R2",2k,72-0502
Resistors,"R3",10k,
Capacitors,"C1",22pF,
Capacitors,"C2",22pF,
Integrated Circuits,"U1",PIC16F877A,
Integrated Circuits,"U2",LM35,
Diodes,"D1",DIODE,
Diodes,"D2",DIODE,
Diodes,"D3",DIODE,
Diodes,"D4",DIODE,
Miscellaneous,"LCD1",LM016L,
Miscellaneous,"X1",8MHz,
GSM MODULE SIM900D

 

Coding

Following code is written in MIKRO C and it is self explantory. I have also give comment on each line of code for your understanding.

// *****************written by Bilalmalikuet@gmail.com***************
//****You can also email me to fire me for your project/organzation**
// LCD module connections
sbit LCD_D7 at RB2_bit;
sbit LCD_D6 at RB3_bit;
sbit LCD_D5 at RB4_bit;
sbit LCD_D4 at RB5_bit;
sbit LCD_EN at RB6_bit;
sbit LCD_RS at RB7_bit;

sbit LCD_D7_Direction at TRISB2_bit;
sbit LCD_D6_Direction at TRISB3_bit;
sbit LCD_D5_Direction at TRISB4_bit;
sbit LCD_D4_Direction at TRISB5_bit;
sbit LCD_EN_Direction at TRISB6_bit;
sbit LCD_RS_Direction at TRISB7_bit;
//************************temperature variables****************
int temp;
char txt [7];
//**************************************************************
//**********************AT commands initialization**************
char AT[]=”AT”;
char noecho[]=”ATE0″;
char mode_text[]=”AT+CMGF=1″;
char mobile_no[]=”AT+CMGS=\”+92090078601\””;
char terminator=0x1A;
char text1[]=”temperature=”;
//*******************temperature measurement funtion*************************************
void READ_temp(void)
{
temp = ADC_Read(0);
temp = temp * 0.4887;




}
void data_converstion(void)
{

inttostr(temp,txt);
}
void display(void)
{
lcd_out(1,1,”TEMPERATURE=”);
lcd_out(1,13, Ltrim(txt));
Lcd_Chr_Cp(0xdf);
Lcd_Chr_Cp(‘C’);
Lcd_Chr_Cp(‘ ‘);

}
//********************String transmit function****************
void send_to_modem(char *s)
{
while(*s)
{
UART1_WRITE(*s++);
}
UART1_WRITE(0X0D);
}
void send_to_modem1(char *s)
{
while(*s)
UART1_WRITE(*s++);
}
void send_sms()
{
send_to_modem1(text1);
delay_ms(1000);
send_to_modem1(txt);
delay_ms(1000);
uart1_write(terminator);
delay_ms(1000);
}
void main()
{
lcd_init();
ADC_Init();
Uart1_Init(9600);
while(1)
{ READ_temp();
delay_ms(100);
data_converstion();
delay_ms(100);
display();
delay_ms(100);
send_to_modem(AT);
delay_ms(1000);
send_to_modem(noecho);
delay_ms(1000);
send_to_modem(mode_text);
delay_ms(1000);
send_to_modem(mobile_no);
delay_ms(1000);
send_sms(); // funtion to send temperature value
delay_ms(10000); // send sms afer every 10 seconds
}
}
Above code send temperature value to given number after every 10 seconds. you can also make this code more flexible by adding interrupts instead of adding delay function so that microcontroller keep doing other things if you are using same microcontroller for other application as well.Below is a circuit diagram to test either microcntroller is sending data or not.I have test this code on many gsm modules and its work perfectly.

wireless temperature sensor

wireless temperature sensor

If you have any issue after reading this article, you are welcome to comment your problems on this post. Also subscribe to my blog to get updates of my upcoming articles in your inbox.

18 Comments

  1. juan manuel October 22, 2014
  2. aab November 2, 2014
  3. Tung January 22, 2015
  4. Sud0811 April 6, 2015
    • Hari January 18, 2016
      • BILAL Malik January 18, 2016
  5. Fatuma Shariff May 18, 2015
    • BILAL Malik May 18, 2015
  6. sujit September 24, 2015
  7. Gaurav Mathur December 31, 2015
  8. PK January 14, 2016
    • BILAL Malik January 14, 2016
  9. Abunaw January 25, 2016
  10. SIRANJEEVI March 8, 2016
  11. peter kamau March 14, 2016
  12. timothy March 24, 2016
  13. Tyler March 24, 2016
  14. yusuf April 25, 2016

Add Comment

Subscribe to our blog to get updates in your email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 901 other subscribers