Smart Temperature Monitoring System (Part-3) 


This is the third and last part of our series blog, discussing the Smart Temperature Monitoring Systems (STMS). In the first blog, we introduced STMS and its different features. In the second blog, we discussed multiple use cases of STMS along with a tutorial and a live demo. This last part will discuss the importance of telemetry in IoT, a brief comparison of the technology stack for telemetries visualization, and a video tutorial for streaming telemetries. 

Importance of Telemetry in IoT 

Telemetry is a process that collects raw data from sensors and then transmits it to a local or cloud server. Telemetry has been around since the 1800’s but its importance has increased due to the recent expansion of Internet of Things technology and Artificial Intelligence. 

Today’s telemetry can sense and transmit information based on different variables such as sound, vibration, airflow, fluid levels, torque, air composition, electrical currents, moisture, light, position, heat, speed, and other metrics. This information is processed through various data visualization solutions deployed locally or on the cloud. In addition, machine learning can be applied to collected data and convert it into useful insights, making things cheaper, better, faster, and more efficient. 

A Brief Comparison of Technology 

It can be quite challenging to choose the right framework for application development. There are multiple options available for streaming telemetry. However, the SocketIO and SignalR are the first and the most popular names that you will hear. 

Although there are similarities that SignalR and Socket IO share, both have their own benefits and usage. SignalR needs to be deployed on a server, and it works with the host of ASP.NET, OWIN, and the self-host. Hence you can consider using it with the windows service. The SignalR supports the clients for browsers like .NET, Silverlight, Windows Phone 7, etc. Moreover, it also helps to work with Mono Touch, iOS, etc. 

Unlike the SignalR, Socket IO is a detailed real-time application framework. It is highly efficient in enabling real-time bidirectional communication, which is event-based. In addition to this, Socket IO is highly capable of working on most platforms, devices, or on the browser. If you require better speed and reliability while developing, then the Socket IO can be a better choice than the SignalR. However, the SignalR is the top choice due to its reliability in working with the .NET server. 

Video Tutorial 


Python Script for Sending Temperature Telemetries on React App 

In the tutorial Smart Temperature Monitoring System Part 2, we demonstrated how to set up temperature sensor Ds18B20 with a raspberry pi and get temperature data. This tutorial covers script modification from the previous blog and send temperature telemetries to a node SocketIO server.  

We will need a few libraries to install before we proceed. Open the shell in raspberry pi and type the command (pip install “python-socketio[client]”) to install the python client. 


Fig 1: Installing socketio library 

To send temperature telemetries, we need a python script. Here is the code: 

import os 

import glob 

import time 

import json 

import configparser 

from datetime import datetime 

import socketio 


sio = socketio.AsyncClient() 


### Init Block### 

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’ 


#reading the raw values from w1_slave 

def read_temp_raw(): 

    f = open(device_file, ‘r’) 

    lines = f.readlines() 


    return lines 


– getting the raw temperature 

– parsing the raw reading 

– converting to degrees Celsius 

– connecting to socketio 

– emitting to socketio 



def read_and_publish_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  # degrees celsius conversion 

        float_temp_c_str = “{:.1f}”.format(temp_c)  # stringifying the temperature value 



    # date-parsing 

    now = 

    dt_string = now.strftime(“%m/%d/%Y %H:%M:%S”) 


    # preparing a message 

    msg = { 

        “temp”: float_temp_c_str, 

        “timeStamp”: dt_string, 



    # Connecting and emitting to socketio 


    sio.emit(‘SendMessage’, json.dumps(msg)) 



while True: 



    except Exception as e: 

        print(“Encountered an exception during processing. Details: ” + str(e)) 

This script is simple to understand. Firstly, it loads in the kernel modules then reads the temperature sensor. The function read_and_publish_temp () works to open the sensor device and reads the raw temperature values. After that, it parses through the lines and gets Celsius and Fahrenheit values through a simple formula. A message is formatted having temperature data and timestamp. Lastly, the connection is established with the socketio server, and the message is emitted. 

The temperature telemetries are received and visualized into a graph, as shown below. 



Our series of three blogs on Smart Temperature Monitoring System (STMS) has covered everything you need to know about STMS from their basic features to their industrial use cases, and all the demo tutorials for hardware and software applications. We have also discussed why STMS is an important industrial requirement. To further explore personalized STMS and its applications in different industries, please contact us at [email protected].