Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Wireless Temperature Monitoring System Using Bluetooth

By Ganesh Selvaraj September 14, 2013

 

Monitoring temperature of a particular place directly is difficult and sometimes impossible (ex: places where humans cannot be). So there is a necessity for wireless monitoring system which enables the user to track the temperature from a remote location.

In this article we’ll learn how to build a wireless temperature indicator which sends the temperature value to a PC/Laptop through Bluetooth.

Components Required

1. Atmega16 development board with 16MHz crystal

2. Serial Bluetooth Module(AUBTM/HC-05/HC-04/BLUSMIRF)

3.   PC/Laptop running Windows XP/7/8

4.USB Bluetooth(Not required if you laptop/PC has inbuilt hardware)

5.LM35 Temperature Sensor

6.Breadboard

7. Solid Wires

Software Required

Your own software (Refer my previous tutorial) or any Serial Port Software on your PC (RealTerm/HyperTerminal/TeraTerm/Putty)

Block-Diagram

Block Diagram of AVR ATMega16 based Wireless Temperature Monitor

Fig. 1: Block Diagram of AVR ATMega16 based Wireless Temperature Monitor

Process Explanation:

—->The Temperature sensor LM35 produces an output voltage which is directly proportional to its surrounding temperature. For every 1°C of rise/fall in temperature, the output voltage of the sensor varies by 10mV.

        

Pin Diagram of LM35 Temperature Sensor

Fig. 2: Pin Diagram of LM35 Temperature Sensor

—->The output of this sensor is analog in nature which needs to be converted into a digital value using an Analog to Digital Converter (ADC) so it is fed into 37th pin (PA3) of PORT A of the ATmega16 microcontroller. ATmega16 consists of 8 channels ADC (PA0-PA7) with a maximum resolution of 10 bits. So the analog input is converted into a discreet value within a range of 0 to 1023 (210  discreet values)

Pin Diagram of AVR ATMega16

Fig. 4: Pin Diagram of AVR ATMega16

 —-> This discreet value needs to be converted into the Celsius scale value which is done by adding a conversion formula in the program:

((X/1023.00)*500.00)

Where “X” is an output value from the ADC and its range is 0 to 1023.

EXAMPLE:

Image Showing Working Principle of LM35 Temperature Sensor

Fig. 5: Image showing working principle of LM35 Temperature Sensor

 —–> Next, the obtained temperature value is transmitted to the PC by using the USART feature of the microcontroller.

  ——> PC receives this data through Bluetooth and displays it on screen.

 

Code Explanation:

Basically, the code involves two parts:

1.   ADC implementation

2.  USART implementation

FUNCTIONS USED:

1.      BlueInit()

It is used for initializing the USART function and setting the baud rate.

2.     BlueRdChar()

Wait till a data is received at the RX pin. Once the data arrives it returns the data to the called function.

3.     BlueWrChar(unsigned char d)

Writes the character stored in variable “d” into USART line which in turn transmits it to TX pin of controller.

4.   BlueWrString(const char *msg)

This function is used when a group of characters (string) have to be transmitted.

5.  BlueWrInt(int val,unsigned int field_length)

This function is used to transmit an integer value stored at “val” through the USART. The “field_length” is used to specify the number of digits.

6.    SetADC()

This is used to enable the ADC feature of the controller.

7. ReadADC(uint8_t ch)

This function is used to read the analog voltage value at the particular ADC channel specified by the value at “ch” and then convert it into a discreet value of range 0 to 1023.

Algorithm and Circuit Set-up

ALGORITHM:

Step 1: Initialize the ADC function and USART function with 9600 baud rate.

Step 2: Enter into an infinite loop

Step 3: Wait for a character to be available at RX pin of the controller using the BlueRdChar() function. If character is available, go to step 4 else wait.

Step 4: Store the available character in the variable named “value”.

Step 5: If the character stored in “value” is “s” or “S” then go to Step 6 else go to Step 3.

Step 6: Enter into the second infinite loop.

Step 7: Obtain the analog value at 3rd channel of ADC and convert it into discreet value between 0 and 1023 using ReadADC(3) function.

Step 8: Convert the discreet value into Celsius scale value using the conversion formula and store it a variable name “temp”.

Step 9: Send the string “The Current Temperature is:” using BlueWrString() function followed by the temperature value present at “temp” using BlueWrInt().

Step 10: Wait for 2 seconds and go back to Step 7.

Circuit Setup:

Prototype of AVR ATMega16 based Wireless Temperature Monitor

Fig. 6: Prototype of AVR ATMega16 based Wireless Temperature Monitor

Setup Instructions:

        1.    Burn the hex file generated through the given C program. Remember that we need to run the controller using a external 16MHz crystal so change the fuse settings as follows:

High fuse=0xC9

Low fuse=0xFF

(Warning: Be very careful while programming the fuse bits. If you set it with wrong values then the microcontroller may be permanently disabled.)

 2.  Turn ON the Bluetooth on your computer and the circuit setup. Wait a moment to allow them to connect (Refer the previous tutorial if you are establishing a connection for the first time.)

3.    Open the serial communication software on your PC and configure it as follows:

Baud: 9600

Port: <The port where the Serial Bluetooth Modem is virtually connected to>

Data bits: 8

Parity: None

Stop bits: 1

Hardware Flow Control: None

       4. Enter the character ‘S’ or ‘s’ and press send. After a moment you should see the computer screen being updated with the temperature value in Celsius scale. Something like this:

Screenshot of Serial Terminal for Temperature Reading over Bluetooth

                    Fig. 7: Screenshot of Serial Terminal for temperature reading over Bluetooth

Project Source Code

###

/*
* BlueTemp.c
*
* Created: 8/23/2013 10:40:30 AM
*  Author: GANESH SELVARAJ
*/ 

#define F_CPU 16000000UL

#define USART_BAUDRATE 9600
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)
#include <avr/io.h>
#include <util/delay.h>

void BlueInit()
{
UCSRB |= (1 << RXEN) | (1 << TXEN); // Enable transmission and reception

UCSRC |= (1 << URSEL) | (1<<USBS) | (1 << UCSZ0) | (1 << UCSZ1);
// Use 8-bit character sizes

UBRRL = BAUD_PRESCALE;

UBRRH = (BAUD_PRESCALE >> 8);

}
unsigned int BlueRdChar()
{
while ((UCSRA & (1 << RXC)) == 0); // wait until data has been received

return(UDR); // return the byte
}

void BlueWrChar(unsigned char d)
{
while ((UCSRA & (1 << UDRE)) == 0); // wait till UDR is ready

UDR = d; // send data
}
void BlueWrString(const char *msg)
{
while(*msg!='')
{
BlueWrChar(*msg);
msg++;
}

}
void BlueWrInt(int val,unsigned int field_length)
{

char str[5]={0,0,0,0,0};
int i=4,j=0;
while(val)
{
str[i]=val%10;
val=val/10;
i--;
}
if(field_length==-1)
while(str[j]==0) j++;
else
j=5-field_length;

if(val<0) BlueWrChar('-');
for(i=j;i<5;i++)
{
BlueWrChar(48+str[i]);
}
}

void SetADC()
{
ADMUX|=(1<<REFS0);
ADCSRA=(1<<ADEN)|(7<<ADPS0);
}

uint16_t ReadADC(uint8_t ch)
{
//Select ADC Channel ch must be 0-7
ch=ch&0b00000111;
ADMUX|=ch;

//Start Single conversion
ADCSRA|=(1<<ADSC);

//Wait for conversion to complete
while(!(ADCSRA & (1<<ADIF)));

//Clear ADIF by writing one to it
ADCSRA|=(1<<ADIF);

return(ADC);
}
void Waiting(int j) // simple delay function
{
uint8_t i;
for(i=0;i<j;i++)
_delay_ms(200);
}

int main(void)
{
uint8_t temp;
unsigned char value;
_delay_ms(50); // delay of 50 milliseconds
SetADC();

_delay_ms(50); // delay of 50 milliseconds
BlueInit(); // initialization of USART

while(1)
{
value=BlueRdChar();
if(value=='s' || value=='S')
{
while(1)
{
temp=((ReadADC(3)/1023.00)*500.00);
BlueWrString("The Current Temperature is:");
BlueWrInt(temp,3);
BlueWrChar('r');
BlueWrChar('n');
Waiting(10);
}
}

}
}

###

 


Circuit Diagrams

Circuit-Diagram-AVR-ATMega16-Wireless-Temperature-Monitor

Project Video


Filed Under: Electronic Projects
Tagged With: bluetooth, temperature monitoring
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: 5G Technology
This Tech Toolbox covers the basics of 5G technology plus a story about how engineers designed and built a prototype DSL router mostly from old cellphone parts. Download this first 5G/wired/wireless communications Tech Toolbox to learn more!

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Redundant XORs
  • No Output Voltage from Voltage Doubler Circuit in Ansys Nexxim (Harmonic Balance Simulation)
  • Discrete IrDA receiver circuit
  • ISL8117 buck converter blowing up
  • I²C Ground Isolation with Series Battery Cells (ULIN13-01 + PIC18LF4520)

RSS Electro-Tech-Online.com Discussions

  • Help with finding unique wire lug(s)
  • Simple LED Analog Clock Idea
  • Kawai KDP 80 Electronic Piano Dead
  • Saga 1400sv vinyl cutter motherboard issue
  • using a RTC in SF basic

Featured – LoRa/LoRaWan Series

  • What is the LoRaWAN network and how does it work?
  • Understanding LoRa architecture: nodes, gateways, and servers
  • Revolutionizing RF: LoRa applications and advantages
  • How to build a LoRa gateway using Raspberry Pi
  • How LoRa enables long-range communication
  • How communication works between two LoRa end-node devices

Recent Articles

  • What is the LoRaWAN network and how does it work?
  • Understanding LoRa architecture: nodes, gateways, and servers
  • Revolutionizing RF: LoRa applications and advantages
  • How to build a LoRa gateway using Raspberry Pi
  • How LoRa enables long-range communication

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe