Skip to main content

Contactless Smart IR Thermometer using Arduino and Android – Save and Share Results with Pictures



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.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-

  1. MLX90615 IR Temperature Sensor
  2. TCRT5000 IR Sensor
  3. Arduino Nano

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.

Contactless Smart IR Thermometer Circuit Diagram

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.

MLX90615 Sensor
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 Thermometer Setup

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.

Easy Scan Android Application

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.

Contactless IR Thermometer 3D Printed enclosure

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 our servers

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.

3D Printed enclosure for Contactless IR Thermometer

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.

Contactless IR Thermometer Serial Monitor

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.

Contactless Thermometer Setup

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.

Contactless Smart IR Thermometer

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.

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. if you have any technical queries to be answered.

Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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");
}
}

Comments