Project tutorial
Contactless Smart Thermometer using Arduino, MLX90615 IR ...

Contactless Smart Thermometer using Arduino, MLX90615 IR ...

Simple Feature-rich Smart Contactless thermometer using Arduino and MLX90615. Can Take pictures and share scan data as Excel file

  • 4,199 views
  • 4 comments
  • 1 respect

Components and supplies

About this project

The current COVID-19 scenario needs no introduction. While everyone is giving their best to move forward, it is important to act responsibly and tackle this problem collectively. Today in many public places and in other gatherings, it has become common to screen individuals for body temperature, as a preventive measure to check for fever. The device that is used to do this is called a Contactless Infrared Thermometer. As many might have noticed, there is a huge surge in demand for this product, but it is not very hard to build one on your own which could not only serve its purpose but also provide more useful features than the commercial ones. Previously (long back before the outbreak) we have also built a handheld contactless IR thermometer gun, you can also check that out if interested.

So, the objective of this tutorial is to design a Low cost, Easy to build Contactless Thermometer that can measure body temperature, log them into an excel along with the picture of the individuals so that the record can be easily shared with concerned authorities. Intriguing right!! let’s get started….

Low Cost and Easy to Build – Android App for Rescue

On a quick look, we can distinct some of the important parts on a thermometer, namely the IR temperature sensor, microcontroller, Display, Display driver, and the Battery. Now our objective here is to reduce the cost and the most expensive material (at the time of documentation) is the IR temperature sensor itself. Sadly, though as a maker, there are not many options here that you can reach out quickly other than MLX90614 and MLX90615. On the other hand, if you are okay with using an Analog sensor, you will have many cheaper alternatives but it won’t be easy to build and calibrate your device, the choice is yours here. For this tutorial, we will be using the MLX90615 sensor from Melexis.

With the sensor selected, we are only left with Microcontroller, Display, and Battery. So we decided to cut down the cost of all these three parts by leveraging an Android Mobile Phone. Today almost everyone has a good android phone with a decent camera. We can create a simple Android application that can communicate with our thermometer and perform other activities like data logging and image capture. This way we can not only make it work faster but can also increase its potential application by instantaneously sharing log results with pictures on WhatsApp, Gmail, or any other preferred platform. This is why we created our Android application called “Easy Scan” which is open-sourced and the APK is also free to download, more on this later. So the only material required for this project is-

Why TCRT5000 and Arduino Nano?

For many people, this question would have popped up. The reason for using a TCRT5000 IR sensor is to detect the position of the thermometer and take temperature reading automatically. This way you would never have to do anything with the application once it is launched making it easy to use. Also, the reading will be taken only when the sensor is in the right distance from the person so we not worry about false readings.   

The reason for using Arduino Nano is that it has an in-built USB interface which is important to communicate between the controller and the phone. If you do not have one, you can also use the Mega or even the UNO. But speaking on cost terms, you can even use a much low power microcontroller like STM8S or any other controller that supports I2C, ADC, and UART will work fine for this project.

Interfacing MLX90615 and TCRT5000 with Arduino

The circuit diagram of our project is very simple, we only have to connect the MLX90615 and TCRT5000 sensor with our Arduino nano board. The complete circuit diagram for Contactless Body Thermometer is given below.

The MLX90615 and TCRT500 operate on 3.3V and 5V respectively so we can power it accordingly. I2C communication pins A4 (SDA) and A5 (SCL) are used to communicate with the MLX90615 sensor. It is common to use TCRT5000 with an Op-Amp in comparator mode like we did in our BLDC remote car project but here we need it to be more reliable and our IR sensor should be immune to sunlight. So I have connected the IR diode to a digital pin and the Photodiode to an Analog pin of the Arduino. This way we can measure the value from photodiode during the normal stage and then measure again after turning on the IR LED, the difference between these two values should help us deal with noise. More on this will be discussed in the programming section.

You can build a PCB for this if required but for quick prototyping, I have directly soldered the components on a perf board. My set-up looks like this when completed, we will be building a 3D printed case for this, so try following the same component spacing when you are building your protoboard.  

Contactless Smart Thermometer – Arduino Program

The Arduino program for this project is very simple, thanks to the Arduino community. You can download the header file for MLX90615 provided by Sergey Kiselev from the below link.

The complete Arduino program for this project can be found at the bottom of this page, the explanation of this code is as follows.

We begin our program by adding the required header files and declaring the variables. There are two important variables here once is the error_correction value and other is the range sensitivity value. Even though the MLX90615 is factory calibrated, I found that the values were sensible only if I add an error correction value to it. In my case, I had to add 3.2 to the value I obtained from the sensor to get reliable values. I tested my values against a handheld thermometer and found that after adding this error correction value and found it to be reliable. The next variable is the Range sensitivity if we decrease this value, we can increase the range of our thermometer. Although the values are reliable, I am not sure if this is the best way to do it, any comment on this is welcomed.


float calibration = 3.2; //add this to actual value
int Range_sensitivity = 200; //Decrease this value to increase range
#include <Wire.h>
#include "MLX90615.h"
MLX90615 mlx = MLX90615();

Avoiding False Trigger Due to Sunlight with IR Sensor: 

The next set of code that needs error correction is the way TCRT5000 is used in this project. It is possible to use it as a simple position sensor, but then the biggest drawback with the IR position sensor is that it will get triggered if IR rays from the sun directly fall on it.

To avoid this problem, we measure two values from our TCRT5000 sensor as explained in the circuit, the emitter LED of the IR sensor is connected to a digital pin and the receiver LED is connected to the Analog pin. Now in our program, we will read two values from our IR sensor, one is Noise and the other is Noise plus Signal. The Noise value will be measured while keeping the emitter IR LED turned off, so that the receiver IR LED will only tell about the sunlight intensity present in the environment. Then we will measure the Noise Plus signal after turning on the IR LED. Then in the program, we only have to subtract Noise from Noise Plus Signal and we will get our Signal value. The code to do that is shown below.


digitalWrite(2,HIGH);    // Turn on IR LED
delayMicroseconds(500);  // Forward rise time of IR LED
Noise_P_Signal=analogRead(A7);        // Read value from A0 => noise+signal
digitalWrite(2,LOW);     // Turn off IR LED
delayMicroseconds(500);  // Fall time of IR LED
Noise=analogRead(A7);        // Read value from A0 => noise only
Signal = Noise - Noise_P_Signal;

Once we know the Signal and Noise value, we can compare it to our Range_sensitivity value to check if the sensor is in close proximity to skin and if yes, we can send the temperature value through serial communication if not, we will just send position_error as output. If the noise value is very high (in this case greater than 500), it means the sensor is facing direct sunlight and we will not read the temperature in this case because I found the sensor values very unreliable when it is facing direct sunlight. Again, this should help avoid false readings.   


if (Signal>Range_sensitivity && Noise >500) //dec. signal to increase rage
{
  if (trigger == true)
   Serial.println("start");
   digitalWrite(13,HIGH);
   temperature = (mlx.get_object_temp()) + error_correction;
  Serial.println(temperature,1);
  delay(100);
  trigger = false;
}
else
{
  delay(100);
  trigger = true;
  digitalWrite(13,LOW);
  Serial.println("position_error");
}

Easy Scan Android Application

The most feature rich part of this project is the Easy Scan Android Application. You can download this application APK file from the below link.

Download Easy Scan Android Application

We will not be getting into details on how we developed this application since it is out of the scope of this article but if you are a developer, feel free to get the fork the Easy Scan Android application on Github and add new features or tweak according to your requirements.

As mentioned earlier, the Android application allows us to store all the temperature values with a photograph and also share it as an excel file through Whatsapp E-mail, etc. Few screenshots of the applications are shown below.

3D Printed Enclosure for Contactless IR Thermometer

The idea of the project is to make the thermometer compact enough to mount it along with our phone. We designed a CAD model to fit all the electronics into a neat little box used paper clip to secure the device with the phone. The CAD model is shown below.

The design is very simple, it just houses all the electronics and provides an opening to mount the IR sensor and temperature sensor and also a slot to connect the programming cable to Arduino nano USB port. The sensor mounting is tilted buy 30 degree so that it gets mostly perpendicular when a user is holding it against another person’s forehead. We have used a simple sliding top piece to act as a cover. You can also download the complete cad file and STL from the below link to print the same enclosure if required.

Download STL files from Thingiverse

Note that the design was made to suit my perf board, you might have to tweak it a bit to match your board. Maybe in the future, we will have a PCB board and design a better casing. But for now, you can use the CAD model as a reference and make your own. Feel free to share your designs.

Testing Contactless Smart IR Thermometer with Easy Scan Android Application

Once the hardware is ready, upload the Arduino code given below. Then open the serial monitor and you see position error being displayed. If you bring your hand close to the sensor, you will see the value of temperature. You can use any existing IR thermometer to check if the values are correct if not you have to change your error correction value. My Serial monitor screenshot is given below.

This will help us make sure the hardware and program are working as expected. After that use an OTG connector and connect your device to mobile phone. Both mobiles, with Type-C and micro USB port, were tested and found to be working. Make sure you turn on OTG in your mobile phone under setting options. Not all phones ask for this, but it never hurts to check.

After making the connection, install the Easy Scan application using the APK shared earlier and launch the Application. Place the device against an object and if everything is working as expected, you should see the temperature value on the application.

The application allows you to set threshold temperature, if the temperature is more than this threshold value, it will prompt you to take a picture. All the scanned records and be viewed on the application with time and date and can also be shared in Excel format for maintaining records. You can watch the video below for the complete working demonstration.

Hope you enjoyed the tutorial and found it useful. Feel free to use the designs, upgrade it, and share back. Any questions or comments are welcomed in the comment section below. You can also use our forums if you have any technical queries to be answered.

Code


float error_correction  = 3.5; //add this to actual value
int Range_sensitivity = 200; //Decrease this value to increase range 
#include <Wire.h> 
#include "MLX90615.h"
MLX90615 mlx = MLX90615();
void setup()
{
Serial.begin(9600);
delay(100);
while (! Serial);
pinMode(2,OUTPUT);
mlx.begin();
}
int Noise;
int Signal;
int Noise_P_Signal;
boolean trigger = true;
float temperature;
float pvs_temperature;
void loop()
{
digitalWrite(2,HIGH);    // Turn on IR LED
delayMicroseconds(500);  // Forward rise time of IR LED
Noise_P_Signal=analogRead(A7);        // Read value from A0 => noise+signal
digitalWrite(2,LOW);     // Turn off IR LED
delayMicroseconds(500);  // Fall time of IR LED
Noise=analogRead(A7);        // Read value from A0 => noise only
Signal = Noise - Noise_P_Signal;
//Serial.print("Noise + Signal = "); Serial.println(Noise_P_Signal);
//Serial.print("Noise ="); Serial.println(Noise);
//Serial.print ("--> Signal ="); Serial.println (Signal);
//temperature = (mlx.get_object_temp()) + error_correction;
//Serial.println(temperature,1);
//delay(100);
if (Signal>Range_sensitivity && Noise >500) //dec. signal to increase rage
{ 
  if (trigger == true)
   Serial.println("start");
   digitalWrite(2,LOW); //Turn off IR sensor to avoid interferance. 
   for (int i=1; i<=3; i++)
   {
   temperature = (mlx.get_object_temp()) + error_correction;
   Serial.println(temperature,1);
   delay(150);
   }
  trigger = false; 
}
else
{
  delay(100);
  trigger = true;
  digitalWrite(13,LOW);
  Serial.println("position_error");
}
}

Video

Arduino Announces Full Release of its IoT Cloud Platform for Makers and Professionals

Interfacing SX1278 LoRa Module with ESP32

Google Science Journal Transfers from Google to Arduino as an Open Source Project

Arduino Based Digital Thermometer using MAX30205 Human Body Temperature Sensor

IR Remote Decoder using Arduino

Speech Recognition using Arduino

Fingerprint based Car Ignition System using Arduino and RFID

Cough Detection System using Arduino 33 BLE Sense and Edge Impulse

Code

Code snippet #1Plain text
float calibration = 3.2; //add this to actual value
int Range_sensitivity = 200; //Decrease this value to increase range
#include <Wire.h>
#include "MLX90615.h"
MLX90615 mlx = MLX90615();
Code snippet #2Plain text
digitalWrite(2,HIGH);    // Turn on IR LED
delayMicroseconds(500);  // Forward rise time of IR LED
Noise_P_Signal=analogRead(A7);        // Read value from A0 => noise+signal
digitalWrite(2,LOW);     // Turn off IR LED
delayMicroseconds(500);  // Fall time of IR LED
Noise=analogRead(A7);        // Read value from A0 => noise only
Signal = Noise - Noise_P_Signal;
Code snippet #3Plain text
if (Signal>Range_sensitivity && Noise >500) //dec. signal to increase rage
{
  if (trigger == true)
   Serial.println("start");
   digitalWrite(13,HIGH);
   temperature = (mlx.get_object_temp()) + error_correction;
  Serial.println(temperature,1);
  delay(100);
  trigger = false;
}
else
{
  delay(100);
  trigger = true;
  digitalWrite(13,LOW);
  Serial.println("position_error");
}
Code snippet #4Plain text
float error_correction  = 3.5; //add this to actual value
int Range_sensitivity = 200; //Decrease this value to increase range 
#include <Wire.h> 
#include "MLX90615.h"
MLX90615 mlx = MLX90615();
void setup()
{
Serial.begin(9600);
delay(100);
while (! Serial);
pinMode(2,OUTPUT);
mlx.begin();
}
int Noise;
int Signal;
int Noise_P_Signal;
boolean trigger = true;
float temperature;
float pvs_temperature;
void loop()
{
digitalWrite(2,HIGH);    // Turn on IR LED
delayMicroseconds(500);  // Forward rise time of IR LED
Noise_P_Signal=analogRead(A7);        // Read value from A0 => noise+signal
digitalWrite(2,LOW);     // Turn off IR LED
delayMicroseconds(500);  // Fall time of IR LED
Noise=analogRead(A7);        // Read value from A0 => noise only
Signal = Noise - Noise_P_Signal;
//Serial.print("Noise + Signal = "); Serial.println(Noise_P_Signal);
//Serial.print("Noise ="); Serial.println(Noise);
//Serial.print ("--> Signal ="); Serial.println (Signal);
//temperature = (mlx.get_object_temp()) + error_correction;
//Serial.println(temperature,1);
//delay(100);
if (Signal>Range_sensitivity && Noise >500) //dec. signal to increase rage
{ 
  if (trigger == true)
   Serial.println("start");
   digitalWrite(2,LOW); //Turn off IR sensor to avoid interferance. 
   for (int i=1; i<=3; i++)
   {
   temperature = (mlx.get_object_temp()) + error_correction;
   Serial.println(temperature,1);
   delay(150);
   }
  trigger = false; 
}
else
{
  delay(100);
  trigger = true;
  digitalWrite(13,LOW);
  Serial.println("position_error");
}
}
Github
https://github.com/CircuitDigest/Easy-Scan-Thermometer-Android-Application-/tree/master/EasyScan_APK
Github
https://github.com/CircuitDigest/Easy-Scan-Thermometer-Android-Application-

Custom parts and enclosures

Thingiverse
https://www.thingiverse.com/thing:4555207

Schematics

contactless-body-thermometer-schematic_Dady9O310m.png
Contactless body thermometer schematic dady9o310m

Comments

Similar projects you might like

Smart Battery Charger Multiplexer with Smart Display

Project tutorial by leonzak

  • 10,826 views
  • 10 comments
  • 25 respects

DIY IR Remote and IR Remote controlled LEDs

Project tutorial by Rucksikaa Raajkumar

  • 3,198 views
  • 0 comments
  • 7 respects

DIY: A 5 Minutes Contactless OLED Thermometer With Arduino

Project tutorial by Konstantin Dimitrov

  • 35,660 views
  • 1 comment
  • 30 respects

One Pixel Thermometer

Project tutorial by Ian Cumming

  • 4,460 views
  • 3 comments
  • 10 respects

Wireless IR Temperature Scanner

Project tutorial by engrpandaece

  • 7,395 views
  • 8 comments
  • 8 respects

Smart Home - Smart Rules using ARTIK Cloud & Photon

Project tutorial by Raghavendra Ponuganti

  • 6,287 views
  • 3 comments
  • 18 respects
Add projectSign up / Login