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 :

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 [email protected]***************
//****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.

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.
Muy buena la pagina web muchas gracias
Hi;
how can I use this code with MPlab MCC18 compiler; can you help me because I try to used with C18 compiler I can not succeeded.
Thanks;
That is great, please send to me this project (source code and simulation)
Thanks
Plz send me project report and coding , circuit diagramand block diagram on this project.
hiiiiiiii,,,,
I am use sim300 gsm module. this module connect with computer through hyper terminal successfully but when it connect with PIC16f877a then there is no response from gsm modem plzzz give solution….
i am waiting u r valuable reply…….
have you solved your problem.. i am als0 facing same problem. kindly help me
which problem?
Sir this a great work may u please me a source code and simulation.
Thank in advance
Source code and circuit is given in post
pls give mi source code and simulation
hi, contact me
need some development.
HI Sir, Could you tell how to receive characters using GSM?
simply through serial communication
Good post and very helpful.But can I have a code written in Mplab
Tq sir
Hi, how do you locate gsm module (SIM900D) in proteus?
if we dont want to use the LCD which codes should we omit?…great project btw…
when i try to build the codes it gives an error saying that main function not defined…please help
hello! am asking the cost of the project might be?
hello. nice piece. i would like to know if the gsm module requires airtime to be in the sim card while it repeatedly sends the data? secondly, i would like to know if it is possible to still send data back to the gsm module and receive data from the pIC . if this is possible, could i get a sample code? i want to constantly receive measurements from the PIC and monitor it on my mobile phone and be able to control some peripherals at will from my mobile phone
yes it is possible contact me at [email protected]
Thank u for code
hey guys i am working on project
ldr sensor using pic16f877a and gsm sim 900 to send a text to recipient
im using hi tech as my compiler can someone help me with the code
Check you email
Hello sir..plz sent me complete coding and simulation kindly..i have no time for longtime for my graduation project …kindly sir????
may i please get the link where you found those gsm libraries for proeus 7. i cant seem to find them anyyywhere.
please
Can you show me how can I send pH data by using gsm sim800