Twitter icon
Facebook icon
LinkedIn icon
Google icon
Reddit icon
StumbleUpon icon
Del.icio.us icon

Thermal Analysis of Heat Exchanger Using Azure IoT Hub

Added to IoTplaybook or last updated on: 02/17/2020
Thermal Analysis of Heat Exchanger Using Azure IoT Hub

Story

Heat exchanger considers one of the most common types of exchangers widely used in the industrial processes. This exchanger consists of a vessel with different sizes contains a number of tubes inside. The rate of transferred heat depends on several factors such as feed temperature and humidity, shell diameter, a number of tubes, tube geometry, baffle spacing and cutting spacing. So temperature analysis becomes very important in order to maintain the correct temperature in tubes and diagnose the faults in it. Correct measures taken can increase the fault tolerance of the device.

Wireless sensor networks have been installed in many industrial applications like structural monitoring of civil infrastructure, vibration analysis of hydro turbines, etc. and has done remarkably well in irradicating many of the industrial complications.

In this Instructable we will be going through wireless temperature and humidity sensors and its advantages in thermal analysis of heat exchanger. So here we will be demonstrating the following:

  • Wireless temperature and humidity sensors.
  • Temperature analysis using these sensors.
  • Gathering and analyzing the data using a wireless gateway device.
  • Publishing and subscribing to sensor data using Azure.

Things used in this project

Hardware components

 
National Control Devices ESP32
 
× 1

NCD

 
National Control Devices Wireless Temperature and Humidity Sensor
 
× 1

NCD

 
National Control Devices Azure Gateway
 
× 1

NCD

Software apps and online services

Arduino IDE
Arduino IDE
 
  Arduino
Microsoft Azure
Microsoft Azure
 
  Microsoft
LabVIEW Home Bundle
LabVIEW Home Bundle
 
 

Digilent

Hardware and Software Specifications

Software Specification

Hardware Specification

IoT Long Range Wireless Temperature Humidity Sensor

These are industrial grade long-range temperature and humidity sensors with a sensor resolution of ±1.7%RH ±0.6° C. Powered by just 2 AA batteries (included) with an operational lifetime of 500, 000 wireless transmissions, you can expect to achieve up to 10 years of battery life depending on environmental conditions and the transmission interval can be chosen by you. Optionally, this sensor may be externally powered. These sensors have a 2-mile range with an onboard antenna. The range can be boosted up to 28 miles using mesh networking architecture.

Getting the Temperature and Humidity Values

We are getting the following values from the wireless temperature and humidity sensors:

  • Temperature in Celcius
  • Temperature in Fahrenheit
  • Relative humidity
  • Battery usage

These data are then visualized and analyzed in Azure IoT hub. To get started with setting up an Azure IoT Hub, Go through this tutorial. The following procedure is to be followed in order to send the values Azure IoT hub.

Azure IoT hub follows the MQTT protocol in order to publish and subscribe to the data.

  • Azure functions are another important feature provided by the azure portal. Using Azure functions, we can write a piece of code or function in the cloud. In this project, we are parsing the JSON containing raw sensor data and getting the real temperature and Humidity values from it using Azure function. To set up Azure function follow this tutorial.
  • We will get the real temperature and humidity data using parsed JSON raw data
 public static async Task Run(HttpRequestMessage req, TraceWriter log)
{  
double humidity;  
int rawTemp;  
double Ctemp;  
double Ftemp;  
double voltage;  
string utcEnque;  
string devFormat;  
string utcProcess;  
log.Info("C# HTTP trigger function processed a request: " + content);  
JArray array = JArray.Parse($"{await req.Content.ReadAsStringAsync()}");//parsing the JSON array   
foreach(dynamic message in array){      
utcProcess = message.EventProcessedUtcTime;      
utcEnque = message.EventEnqueuedUtcTime;      
humidity = ((message.Humid1)*256 + (message.Humid2))/100;      
rawTemp = ((message.Temp1)*256 + (message.Temp2));      
Ctemp = rawTemp /100.0;         
Ftemp = Ctemp *1.8 + 32;       
int bat = ((message.Bat1)*256 + (message.Bat2));      
voltage = 0.00322 * bat;      
string utcTime = utcProcess.ToString();      
DateTime localDateTime = DateTime.Parse(utcTime);       
DateTime utcDateTime = localDateTime.ToUniversalTime();      
string usTimeZone = "US Eastern Standard Time";      
TimeZoneInfo ust = TimeZoneInfo.FindSystemTimeZoneById(usTimeZone);      
DateTime dateTime = TimeZoneInfo.ConvertTime(utcDateTime, ust);      
log.Info(dateTime.ToString("dd/MM/yyyy HH:mm:ss"));    }return req.CreateResponse(HttpStatusCode.OK, "Executed");  } public class Message{    
[JsonProperty("temp1")]    
public int temp1 { get; set; }    
[JsonProperty("temp2")]    
public int temp2 { get; set; }    
[JsonProperty("humid1")]    
public int humid1 { get; set; }    
[JsonProperty("humid2")]    
public int humid2 { get; set; }    
[JsonProperty("bat1")]    
public int bat1 { get; set; }    
[JsonProperty("bat2")]    
public int bat2 { get; set; }  }
  

 

Analyzing Data in PowerBi

We are using Power BI to visualize the data. It provides interactive ways to analyze data. This data can be interpreted in the form of Line charts, Bar graphs, Pie charts, etc. Start by creating an account in Power Bi and sign in into your account. In the last post, we had set up Power Bi and sent data to Power Bi using a stream analytics job. In this post, we are using Azure function to send the sensor data to power Bi. To set up Power Bi read this blog.

There are four methods to send the data to Power Bi:

  • Directly streaming the data to Power Bi from IoT hub.
  • Using API to send data to Power Bi.
  • Using web-hook functions
  • Using PubNub.

Here in our case we are using Power BI API and sending an HTTP response to Power BI from azure function. There are different graphs, line charts, Pi charts etc. listed in the Visualization panel. We can create the chart by selecting any of the graphs from the Visualization panel.

We can also export the data as an excel sheet or in CSV format. Which in later stages can be used for data analytics.

Azure Function Code for PowerBI

Parse all the JSON objects from the JSON, and get the real values of temperature, humidity, and others. Here the product is a Product class object where we are storing the parsed values.

 Product product = new Product();foreach(dynamic message in array){humidity = ((message.humid1)*256 + (message.humid2))/100;      
rawTemp = ((message.temp1)*256 + (message.temp2));      
Ctemp = rawTemp /100.0;         
Ftemp = Ctemp *1.8 + 32;       
int bat = ((message.bat1)*256 + (message.bat2));      
voltage = 0.00322 * bat;      
utcProcess = message.EventProcessedUtcTime;      
utcEnque = message.EventEnqueuedUtcTime;      
product.Ctemperature = Ctemp;      
product.Ftemperature = Ftemp;      
product.humid = humidity;      
product.battery = voltage;     
//product.dateTime = ;         
product.EventProcessedUtcTime=utcProcess;       
product.EventEnqueuedUtcTime=utcEnque;     }public class Product{  
public double Ctemperature{get; set;}  
public double humid{get; set;}  
public double battery{get; set;}  
//public double dateTime{get; set;}  
public string EventProcessedUtcTime { get; set; }  
public string EventEnqueuedUtcTime { get; set; }  
public double Ftemperature{get; set;}}
  • Now create a variable to store a connection string of Power Bi
  • Create an instance of HTTP client
string connString = "https://api.powerbi.com/beta/***************";  HttpClient client = new HttpClient();
  • We need to send JSON to power Bi. So, Serialize the Json using model class object.
  • Send the converted JSON to power bi as an HTTP request.
string output = JsonConvert.SerializeObject(product);     HttpContent httpContent = new StringContent("[" + output + "]");       
HttpResponseMessage response = await client.PostAsync(connString, httpContent);     response.EnsureSuccessStatusCode();
  

Data Visualization in Power BI

Here we are visualizing our sensor data at different dates and times. We can see the percentage change in Humidity, Temperature and Battery Usage during different days with there values respectively.


1/4


2/4


3/4


3/4

Azure Email Hosting for Wireless Temperature Sensor Using SendGrid

Software as a service(Saas application) provides another amazing feature called SendGrid. In Microsoft Azure, SendGrid support swiftly delivers Email notifications to different Users.

The setup for Send Grid is described in this blog.

Here We will be describing the code for sending email notification using Azure function.

  • Add these dependencies, "Send Grid" is used for accessing SendGrid mailing services.

 


1/3


2/3


3/3

 

#r "SendGrid"using Newtonsoft.Json;using Newtonsoft.Json.Linq;
using System.Net;using System.Net.Mail;
using SendGrid.Helpers.Mail;using Microsoft.Extensions.Logging;
  • Create variables for storing to mail, from mail, SMTP port, username, password, SMTP host, subject of mail and mail body.
string fromMail="enter from mail";string toMail="enter to mail";int smtpPort = 587;
string smtpUserName="Enter your smtp send grid username";  
string smtpPassword = "enter sendgrid password";  
string smtpHost = "smtp.sendgrid.net";  
string subject = "Temperature Alert!!!";  
string mailMessage = "Temperature has reached beyond 30";
  • Create an instance of MailMessage and SmtpClient
MailMessage mail = new MailMessage(fromMail,toMail);SmtpClient smtpClient = new SmtpClient();
  • Set the port, delivery method, SMTP host, user credentials mail body and subject to the Smtp client and mail Message object.
smtpClient.Port = smtpPort;smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.UseDefaultCredentials = false;
smtpClient.Host = smtpHost;
smtpClient.Credentials = new System.Net.NetworkCredential(smtpUserName,smtpPassword);
mail.Subject = subject;mail.Body = mailMessage;
  • Set the port, delivery method, SMTP host, user credentials mail body and subject to the Smtp client and mail Message object.
smtpClient.Port = smtpPort;smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.UseDefaultCredentials = false;
smtpClient.Host = smtpHost;
smtpClient.Credentials = new System.Net.NetworkCredential(smtpUserName,smtpPassword);
mail.Subject = subject;mail.Body = mailMessage;
  • Whenever the temperature crosses the 30 degrees threshold. The user will get a mail to the described email id.
if(product.Ctemperature > 30.00){              smtpClient.Send(mail);     }

Notification Outcomes

  • An automated email notification will be delivered to the user each time the temperature crosses 30 degrees mark.
  • Send Grid delivers the Email Notification to the same subject every time. We don't have to scroll down in the inbox in search of the last delivered message. Just search for the Temperature Alert!!! and you will get the list of messages.

Overall Code

The firmware of this setup can be found in this GitHub repository.

Code

Azure Wireless Temperature and Humidity Sensor

vbshightime / Azure-Wireless-Temperature-and-humidity-Sensor

Read More

Latest commit to the master branch on 1-4-2019 - Download as zip

Credits

vaibhav sharma

  vaibhav sharma

 

 

Hackster.io

This content is provided by our content partner Hackster.io, an Avnet developer community for learning, programming, and building hardware. Visit them online for more great content like this.

This article was originally published at Hackster.io. It was added to IoTplaybook or last modified on 02/17/2020.