Smart Temperature Monitoring System (Part-2) 


This is the second part of our series blog which discusses the Smart Temperature Monitoring Systems (STMS). In the first blog, we introduced TMS and its different features. In this second part we will dive into the numerous use cases of STMS along with a tutorial and a live demo. STMS is becoming an essential industrial requirement. It allows for the tracking and maintaining of the temperature of a product, a process, or a particular environment. In addition to tracking, a suitable STMS sends timely notifications and warnings in case of violations.

Learn more about IOT Services!

Learn More

Use Cases of STMS  

Different sensors can be used to measure temperature values for different applications. These measurements are then logged through a logger device that can store data locally or on cloud storage. However, the choice of a sensor is an essential part of STMS. The sensor must fulfill the application’s required temperature range. The following are some use cases and suitable sensors:

  • Liquid Temperature Measurement  

Whether it’s a laboratory, food, or any other manufacturing industry, temperature plays a vital role in defining the properties of fluids. Moreover, the processes where fluids are handled often require a strict temperature range to be maintained; otherwise, it can affect the efficiency of the process. In such situations, a waterproof temperature sensor is used to measure fluid temperature as the sensor needs to be submerged into the fluid. Standard sensors available for these applications are PT100, DS18B20, and K-type thermocouples.  

  • Supply Chain Temperature Measurement 

One key feature of supply chain applications is connecting manufacturers, distributors, and consumers. The changing environmental conditions can affect the quality of the shipped products. However, companies develop special containers to maintain a suitable environment for their products when shipped from one location to another. Additionally, STMS allows companies to track the environmental parameters in transit, even from a remote location. This IoT solution, along with advanced telemetry, establishes transparency in a supply chain [cold chain] and enables companies to deliver quality products. The most common sensors used for this application are RTD temperature probes, DS18B20, DHT11, DHT22, AM2301, AM2302, and AM2320.  


For better understanding, let’s integrate a sensor with a temperature monitoring device and get the temperature values from the sensor. This tutorial will use the DS181B20 temperature sensor connected with a raspberry pi to measure the air and water temperature.  

The following are the required items:  

  • Raspberry Pi  
  • Breadboard  
  • DS181B20 Sensor  
  • 10K resistor  
  • Jumper Wires  

Video Tutorial 

Setting up Hardware

Integrate the DS181B20 sensor with raspberry pi, as shown in fig 1. The red wire is VCC, black wire is GND, and yellow wire is the data out. We also need to connect a 10k resistor parallel to the red and yellow wire.  

Smart Temperature Monitoring System

Fig 1: Schematic Diagram 

Insert the sensor’s wires into the breadboard and connect it with a raspberry pi. 

Configuring The Sensor 

The DS18B20 is a temperature sensor that is 1-wire programmable and can measure a wide range of temperatures from -55°C to +125°. Each DS18B20 sensor has a unique address and requires only one DIO pin of the MCU to transfer data. To test this sensor in raspberry pi, first, you need to edit the config.txt file. For this, type sudo nano /boot/config.txt in the pi terminal, add a line: dtoverlay=w1-gpio in config.txt file, as shown in fig 2. After adding the line, save the file and reboot the Raspberry pi. 


Fig 2: Config.txt File 

Load the kernel modules by typing the following commands in the pi terminal. 

sudo modprobe w1-gpio 

sudo modprobe w1-therm 

Run the following commands to find your sensor device. 

cd /sys/bus/w1/devices 

ls -la 

This will show the device’s directory based on the given serial number. It should start with 28x: as shown in fig 3. 


Fig 3: Device Address 

cd into that directory, then type cat w1_slave.  

In fig 4, if crc=da is yes, it confirms the sensor is working, and t = (some value) shows celsius temperature x 1000. 


Fig 4: Sensor Test 

Python Script for Getting Temperature Readings 

To measure the temperature from the sensor, we need a python script. Here is the code: 

import os 

import glob 

import time 

os.system(‘modprobe w1-gpio’) 

os.system(‘modprobe w1-therm’) 

base_dir = ‘/sys/bus/w1/devices/’ 

device_folder = glob.glob(base_dir + ’28*’)[0] 

device_file = device_folder + ‘/w1_slave’ 


def read_temp_raw(): 

    f = open(device_file, ‘r’) 

    lines = f.readlines() 


    return lines 


def read_temp(): 

    lines = read_temp_raw() 

    while lines[0].strip()[-3:] != ‘YES’: 


        lines = read_temp_raw() 

    equals_pos = lines[1].find(‘t=’) 

    if equals_pos != -1: 

        temp_string = lines[1][equals_pos+2:] 

        temp_c = float(temp_string) / 1000.0 

        temp_f = temp_c * 9.0 / 5.0 + 32.0 

        return temp_c, temp_f 


while True: 



This script is simple to understand. Firstly, it loads in the kernel modules then reads the temperature sensor. The function read_temp() works so that it opens the sensor device and reads the raw temperature values. After that, it parse through the lines and gets Celsius and Fahrenheit values through a simple formula. Lastly, a while loop will print the temperature data every second.  

In the first step, place the sensor in the air, as shown in fig 5, and run the python script. The output is shown in fig 6. 


Fig 5: Sensor in Air 


Fig 6: Output 

Secondly, put the sensor into the hot water, as shown in fig 7, and run the script. The output is shown in fig 8. 


Fig 7: Sensor in Hot Water 


Fig 8: Output 

Explore Our Innovative IoT Solutions

Contact Us


In this article, we discussed how smart temperature monitoring systems can be used in an industry. The multiple use cases of STMS make it an essential part of the manufacturing processes. STMS can help companies achieve the quality they need to deliver. We will bring more blogs on this topic to give you a better understanding of temperature monitoring systems. 

If you are interested in learning more about Temperature Monitoring systems, contact us at [email protected] and follow our blogs for demo videos.