RFID based Contactless Body Temperature Screening using Arduino and MLX90614 IR Temperature Sensor

Arduino

ByAshish Choudhary 1

RFID Based Contactless Temperature Monitoring System using Arduino

Since the outbreak of Covid-19, infrared thermometers are being used as a screening tool to scan the people at Airports, Railway Stations, and other crowded establishments. These scans are being used to identify potential patients of Covid-19. The government made it compulsory to scan everyone before entering the office, school, or any other crowded place.

So in this tutorial, we are going to build an RFID based Contactless Temperature Monitoring System using a contactless temperature sensor with Arduino. When employees scan the RFID card, it will measure the body temperature of employees with a non-contact infrared thermometer and log the Name and Temperature of that employee directly to the excel sheet. We will be using Arduino Nano, MLX90614, EM18 RFID Reader, and Ultrasonic Sensor to build this project. The ultrasonic sensor is used to calculate the distance between the thermometer and the person. The thermometer will only measure the temperature when the distance is less than 25 CM. It is something like an RFID based attendance system, which also records the body temperature of every person.

Components Required

  • Arduino Nano
  • EM-18 RFID Module
  • MLX90614 Contactless Temperature Sensor
  • Ultrasonic Sensor
  • Breadboard
  • Jumper Wires

EM18 RFID Reader Module

One of the widely used RFID readers for reading 125 kHz tags is the EM-18 RFID Reader. This low-cost RFID Reader module features low power consumption, low form factor, and easy to use. EM-18 Reader Module can provide output through two communication interfaces i.e. RS232 and WEIGAND26.

EM18 RFID Reader module

RFID-card

EM18 RFID Reader features a transceiver that transmits a radio signal. When the RFID tag comes in the transmitter signal range, this signal hits the transponder that is inside the card. The tag draws power from the reader module-generated electromagnet field. The transponder then transforms the radio signal into the usable form of power. Upon getting power, the transponder transfers all the information, such as a specific ID, in the form of an RF signal to the RFID Module. Then this data sent to the microcontroller using UART communication.

To learn more about RFID and tags, check our previous RFID based projects.

MLX90614 Infrared Thermometer

Before we proceed with the tutorial, it is important to know how the MLX90614 sensor works. There are many temperature sensors available in the market and we have been using the DHT11 Sensor and LM35 extensively for many applications where atmospheric humidity or temperature has to be measured.

We previously used this sensor in IR thermal gun which can sense the temperature of a particular object (not ambient) without directly getting in contact with the object. Here we are again using the same sensor to calculate the temperature of an object. The MLX90614 is one such sensor that uses IR energy to detect the temperature of an object. To learn more about Infrared and IR sensor circuit, follow the link.

MLX90614 Infrared Thermometer

MLX90614 sensor is manufactured by the Melexis Microelectronics Integrated system, it has two devices embedded in it, one is the infrared thermopile detector (sensing unit) and the other is a signal conditioning DSP device (computational unit). It works based on Stefan-Boltzmann law which states that all objects emit IR energy and the intensity of this energy will be directly proportional to the temperature of that object. The sensing unit in the sensor measures how much IR energy is emitted by a targeted object and the computational unit converts it into temperature value using a 17-bit in-built ADC and outputs the data through the I2C communication protocol. The sensor measures both the object temperature and ambient temperature to calibrate the object temperature value. Features of MLX90614 sensor is given below, for more details refer the MLX90614 Datasheet.

Circuit Diagram

Circuit Diagram for RFID based non-contact temperature sensor using Arduino is given below:

Arduino based RFID Contactless IR Temperature Screening System Circuit Diagram

As shown in the circuit diagram, the connections are very simple since we have used them as modules, we can directly build them on a breadboard. The LED connected to the BUZ pin of the EM18 Reader module turns high when someone scans the tag. The RFID module sends data to the controller in serial; hence the transmitter pin of the RFID module is connected to the Receiver pin of Arduino. The connections are further classified in the table below:

Arduino Nano

EM18 RFID Module

5V

Vcc

GND

GND

5V

SEL

Rx

Tx

Arduino Nano

MLX90614

5V

Vcc

GND

GND

A5

SCL

A4

SDA

Arduino Nano

Ultrasonic Sensor (HCSR-04)

5V

Vcc

GND

GND

D5

Trig

D6

Echo

RFID based Contactless Body Temperature Screening using Arduino and MLX90614 IR Temperature Sensor

Code Explanation

We have to write an Arduino code that can read data from the ultrasonic sensor, MLX90614, EM18 RFID Reader Module, and send the Name and Temperature of a person to an Excel Sheet. For this code, you have to download the Wire and MLX90614 libraries. After downloading the libraries, add them to your Arduino IDE.

The complete code for this contactless body temperature monitoring is given at the end of the page. Here the same program will be explained in small snippets.

As usual, start the code by including all the required libraries. Here the Wire library is used to communicate using I2C protocol and the Adafruit_MLX90614.h library is used to read the MLX90614 sensor data.

#include <Wire.h>
#include <Adafruit_MLX90614.h>

We then define the pins of the ultrasonic sensor to which we have made the connection

const int trigPin = 5;
const int echoPin = 6;

After that, define the variables to store the RFID module, ultrasonic sensor, and MLX90614 sensor data.

long duration;
int distance;
String RfidReading;
float TempReading;

Inside the void setup() function, we initialize serial monitor for debugging and the MLX90614 temperature sensor. Also, set the Trig and Echo pins as output and input pins.

void setup()
{
  Serial.begin(9600);   // Initialise Serial Communication with the Serial Monitor
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  mlx.begin();
  Initialize_streamer();
} 

Inside the void loop() function, calculate the distance between the person and the sensor and if the distance is less than or equal to 25cm, then call the reader() function to scan the tag.

void loop()
{
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = duration * 0.0340 / 2;
  if (distance <= 25){
  reader();  }

void reader() function is used to read the RFID tag card. Once the card is brought near the reader module, the reader module reads the serial data and store it in the input variable.

void reader()
{
if(Serial.available())
  {
    count = 0;
    while(Serial.available() && count < 12)
    {
      input[count] = Serial.read();
      count++;
      delay(5);

In the next lines, compare the scanned card data with the predefined tag ID. If the tag ID matches the scanned card, then read the temperature of the person and send the temperature and name of the person to the excel sheet.

if(input[count]==tag[count])
flag = 1;        else
flag= 0;
count++;        
RfidReading = "Ashish";
      }
    }
    if(flag == 1)
    {
      temp_read();
      Write_streamer();
      }

Inside the temp_read() function, read the MLX90614 sensor data in Celsius and store it in the ‘TempReading’ variable. 

void temp_read()
{
   TempReading = mlx.readObjectTempC();}

Once the hardware and the software are ready, it is time to upload the program into your Arduino Nano Board. As soon your program gets uploaded, the ultrasonic sensor starts calculating the distance. When the calculated distance is less than 40 cm, it reads the temperature and the card.

Storing Sensor Data into Excel Sheet from Arduino Controller

Now to send data to Excel sheet, we are going to use PLX-DAQ. It is an Excel Plug-in software that helps you to write values from Arduino to directly into an Excel sheet on your Laptop or PC. Use the link to download the the file. After downloading extract the file and click on .exe file to install it. It will create a folder named PLS-DAQ on your desktop.

Now open the ‘PLX-DAQ spreadsheet’ file from the desktop folder. If macros are disabled on your Excel than you will see a security block as shown in below image:

 

PLX-DAQ in Excel Sheet

Click on Options->Enable the content -> Finish -> OK to Enable the Macros. After this you will get the following screen:

Excel Sheet PLX-DAQ Setting

Now select the baud rate as “9600” and the port to which your Arduino is connected and then click on Connect to start the data streaming. Your values should start to get logged like shown in the picture below.

Contactless Body Temperature Monitoring Data

This is how you can build a Contactless Temperature screening device and store the data in the Excel Sheet.

A working video and complete code are given at the end of the page.

Code
#include <Wire.h>
#include <Adafruit_MLX90614.h>
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
char tag[] ="180088FECCA2"; // Replace with your own Tag ID
char input[12];        // A variable to store the Tag ID being presented
int count = 0;        // A counter variable to navigate through the input[] character array
boolean flag = 0;     // A variable to store the Tag match status
const int trigPin = 5;
const int echoPin = 6;
long duration;
int distance; 
String RfidReading;
float TempReading;
void setup()
{
  Serial.begin(9600);   // Initialise Serial Communication with the Serial Monitor
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  mlx.begin();
  Initialize_streamer();
}
void loop()
{ 
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = duration * 0.0340 / 2;
 // Serial.println("Distance");
  //Serial.println(distance);
  if (distance <= 40){
  reader();
  }
  delay(1000);
}
void reader()
{
if(Serial.available())// Check if there is incoming data in the RFID Reader Serial Buffer.
  {
    count = 0; // Reset the counter to zero
    while(Serial.available() && count < 12) 
    {
      input[count] = Serial.read(); // Read 1 Byte of data and store it in the input[] variable
      count++; // increment counter
      delay(5);
    }
    if(count == 12) // 
    {
      count =0; // reset counter varibale to 0
      flag = 1;
      while(count<12 && flag !=0)  
      {
        if(input[count]==tag[count])
        flag = 1; // everytime the values match, we set the flag variable to 1
        else
        flag= 0; 
        count++; // increment i
        RfidReading = "Ashish";
      }
    }
    if(flag == 1) // If flag variable is 1, then it means the tags match
    {
      //Serial.println("Access Allowed!");
      temp_read();
      Write_streamer();
      }
    else
    {
     // Serial.println("Access Denied"); // Incorrect Tag Message     
    }
    for(count=0; count<12; count++) 
    {
      input[count]= 'F';
    }
    count = 0; // Reset counter variable
  }
}
void temp_read()
{
   TempReading = mlx.readObjectTempC();
  // Serial.println(sensorReading1);
  // Serial.print(",");
 //Serial.print("Ambient ");
 //Serial.print(mlx.readAmbientTempC());
 //Serial.print(" C");
// Serial.print("Target  ");
// Serial.print(mlx.readObjectTempC());
// Serial.print(" C");
// delay(1000);
}
void Initialize_streamer()
{
Serial.println("CLEARDATA"); //clears up any data left from previous projects
Serial.println("LABEL,Date,Time,Temperature,Name"); //always write LABEL, to indicate it as first line
}
void Write_streamer()
  {
   // Serial.print("DATA"); //always write "DATA" to Indicate the following as Data
   // Serial.print(","); //Move to next column using a ","
  //  Serial.print("DATE"); //Store date on Excel
   // Serial.print(","); //Move to next column using a ","
   // Serial.print("TIME"); //Store date on Excel
   // Serial.print(","); //Move to next column using a ","
    Serial.print(RfidReading); //Store date on Excel
    Serial.print(","); //Move to next column using a ","
    Serial.print(TempReading); //Store date on Excel
    Serial.print(","); //Move to next column using a ","
    Serial.println(); //End of Row move to next row
  }
Video

Get Our Weekly Newsletter!

Subscribe below to receive most popular news, articles and DIY projects from Circuit Digest

Comments

  • John Quigley's picture
    John Quigley
    Jun 29, 2020

    Hello,

    I have done some minimal searching for the individual items required for this project and some seem rather pricey. What is the ebest way to get info. on the availaibilty and general pricing on these components?

     

    Thank you.

Log in or register to post Comment