Introduction
In today’s world, where health and safety are of paramount importance, contactless temperature measurement has become a necessity, especially in the wake of the COVID-19 pandemic. Traditional mercury thermometers are not only inconvenient but also pose environmental and health risks. Contactless thermometers, on the other hand, offer a safe and efficient way to measure body temperature without physical contact.
One of the most popular and versatile platforms for building such devices is the Arduino microcontroller. Arduino, with its open-source nature and vast community support, provides a flexible and cost-effective solution for creating customized temperature monitoring systems.
In this article, we will delve into the process of building a contactless thermometer using an Arduino board, along with an SD card temperature logger. This project will not only allow you to measure body temperature remotely but also provide you with the ability to store and analyze temperature data over time.
Table of Contents
- Hardware Requirements
- Software Requirements
- Setting up the Hardware
- Programming the Arduino
- Calibrating the Thermometer
- SD Card Temperature Logger
- Testing and Troubleshooting
- Frequently Asked Questions (FAQ)
Hardware Requirements
To build this project, you will need the following hardware components:
- Arduino Board: We recommend using an Arduino Uno or Arduino Nano board for this project. These boards are widely available, affordable, and have sufficient memory and processing power for our needs.
- MLX90614 Non-contact Infrared Temperature Sensor: This sensor is capable of measuring temperatures from a distance without physical contact. It uses infrared radiation to detect the surface temperature of objects or individuals.
- SD Card Module: An SD card module, such as the Arduino Ethernet Shield or a dedicated SD card breakout board, is required to store temperature data on an SD card.
- Breadboard and Jumper Wires: A breadboard and jumper wires will be used to connect the components and prototype the circuit.
- LCD Display (optional): An LCD display can be added to the project to display the temperature readings in real-time.
- Buzzer or LED (optional): A buzzer or LED can be incorporated to provide audible or visual alerts when the temperature exceeds a certain threshold.
Software Requirements
To program the Arduino and interact with the SD card module, you will need the following software:
- Arduino IDE: The Arduino Integrated Development Environment (IDE) is a cross-platform application that allows you to write code, compile it, and upload it to your Arduino board. You can download the latest version of the Arduino IDE from the official website: https://www.arduino.cc/en/software
- SD Card Library: The SD card library is required to communicate with the SD card module and perform read/write operations. This library is included in the Arduino IDE by default.
- MLX90614 Library: To interact with the MLX90614 non-contact infrared temperature sensor, you will need a dedicated library. You can find and install this library through the Arduino IDE’s Library Manager.
Setting up the Hardware
Before we dive into the programming aspect, let’s set up the hardware components:
- Connect the MLX90614 Temperature Sensor:
- Connect the
VCC
pin of the MLX90614 sensor to the5V
pin on the Arduino board. - Connect the
GND
pin of the sensor to theGND
pin on the Arduino board. - Connect the
SCL
(Serial Clock) pin of the sensor to theSCL
pin (Analog 5 on Uno, Digital 19 on Mega) on the Arduino board. - Connect the
SDA
(Serial Data) pin of the sensor to theSDA
pin (Analog 4 on Uno, Digital 18 on Mega) on the Arduino board.
- Connect the
- Connect the SD Card Module:
- If you’re using the Arduino Ethernet Shield, simply plug it into the Arduino board.
- If you’re using a dedicated SD card breakout board, connect the
VCC
pin to the5V
pin on the Arduino board, and theGND
pin to theGND
pin on the Arduino board. - Connect the
MOSI
(Master Out Slave In) pin of the SD card module to theMOSI
pin (Digital 11 on Uno, Digital 51 on Mega) on the Arduino board. - Connect the
MISO
(Master In Slave Out) pin of the SD card module to theMISO
pin (Digital 12 on Uno, Digital 50 on Mega) on the Arduino board. - Connect the
SCK
(Serial Clock) pin of the SD card module to theSCK
pin (Digital 13 on Uno, Digital 52 on Mega) on the Arduino board. - Connect the
CS
(Chip Select) pin of the SD card module to a digital pin on the Arduino board (e.g., Digital 10 on Uno, Digital 53 on Mega).
- Connect the LCD Display (optional):
- Connect the
VCC
pin of the LCD display to the5V
pin on the Arduino board. - Connect the
GND
pin of the LCD display to theGND
pin on the Arduino board. - Connect the
SDA
pin of the LCD display to theSDA
pin (Analog 4 on Uno, Digital 20 on Mega) on the Arduino board. - Connect the
SCL
pin of the LCD display to theSCL
pin (Analog 5 on Uno, Digital 21 on Mega) on the Arduino board.
- Connect the
- Connect the Buzzer or LED (optional):
- Connect the positive terminal of the buzzer or the anode of the LED to a digital pin on the Arduino board (e.g., Digital 9 on Uno, Digital 9 on Mega).
- Connect the negative terminal of the buzzer or the cathode of the LED to the
GND
pin on the Arduino board. - Include a current-limiting resistor (e.g., 220 ohm for an LED) in series with the buzzer or LED.
Programming the Arduino
Now that we have set up the hardware, it’s time to write the code to control the components and measure the temperature. Follow these steps:
- Open the Arduino IDE and create a new sketch (File > New).
- Include the required libraries at the beginning of your code:arduinoCopy code
#include <Wire.h> #include <Adafruit_MLX90614.h> #include <SD.h> // Additional libraries for LCD display and other components, if needed
- Declare global variables and initialize the required objects:arduinoCopy code
Adafruit_MLX90614 mlx = Adafruit_MLX90614(); File dataFile; const int chipSelect = 10; // Change this if you're using a different CS pin // Additional variables for LCD display, buzzer/LED, and other components, if needed
- In the
setup()
function, initialize the serial communication, start the MLX90614 sensor, and initialize the SD card module:arduinoCopy codevoid setup() { Serial.begin(9600); mlx.begin(); Serial.print("Initializing SD card..."); if (!SD.begin(chipSelect)) { Serial.println("Card failed, or not present"); return; } Serial.println("Card initialized."); // Additional setup code for LCD display, buzzer/LED, and other components, if needed }
- In the
loop()
function, read the temperature from the MLX90614 sensor, log the data to the SD card, and perform any additional actions (e.g., display temperature on LCD, trigger buzzer/LED if temperature exceeds a threshold):arduinoCopy codevoid loop() { double ambientTemp = mlx.readAmbientTempC(); double objectTemp = mlx.readObjectTempC(); // Open the data file for writing dataFile = SD.open("templog.txt", FILE_WRITE); // Write the temperature data to the SD card if (dataFile) { dataFile.print(ambientTemp); dataFile.print(","); dataFile.println(objectTemp); dataFile.close(); Serial.print("Ambient Temp: "); Serial.print(ambientTemp); Serial.print("°C, Object Temp: "); Serial.print(objectTemp); Serial.println("°C"); } else { Serial.println("Error opening data file"); } // Additional code for displaying temperature on LCD, triggering buzzer/LED, etc. delay(5000); // Wait for 5 seconds before taking the next reading }
- Upload the code to your Arduino board, and it should start measuring and logging the temperature data to the SD card.
Calibrating the Thermometer
The MLX90614 non-contact infrared temperature sensor is highly accurate and reliable. However, to ensure the best possible temperature readings, it is recommended to calibrate the sensor based on your specific environment and application.
Here are some steps you can follow to calibrate the contactless thermometer:
- Obtain a reference thermometer: You will need a reliable and accurate reference thermometer, such as a calibrated mercury thermometer or a high-quality digital thermometer, to compare the readings with the MLX90614 sensor.
- Set up the testing environment: Create a controlled environment where you can measure the temperature of a stable object or surface. Ensure that the temperature remains relatively constant during the calibration process.
- Take multiple readings: Take several temperature readings from the reference thermometer and the MLX90614 sensor simultaneously. Record the readings in a table or spreadsheet for comparison.
- Calculate the offset: Calculate the difference between the readings from the MLX90614 sensor and the reference thermometer for each measurement. This difference represents the offset value.
- Determine the average offset: Calculate the average offset by summing up all the individual offsets and dividing by the number of measurements taken.
- Apply the offset correction: Modify your Arduino code to subtract or add the average offset value from the temperature readings obtained from the MLX90614 sensor. This will effectively calibrate the sensor to match the reference thermometer.arduinoCopy code
double objectTemp = mlx.readObjectTempC() - averageOffset;
- Repeat and refine: Repeat the calibration process multiple times, adjusting the offset value as needed, until the readings from the MLX90614 sensor closely match the reference thermometer.
It’s important to note that environmental factors such as ambient temperature, humidity, and surface emissivity can affect the accuracy of the non-contact infrared temperature sensor. Periodic recalibration may be necessary to maintain optimal performance.
SD Card Temperature Logger
One of the key features of this project is the ability to log temperature data to an SD card. This allows for long-term data collection and analysis, which can be invaluable in various applications, such as monitoring environmental conditions, tracking patient temperatures in healthcare settings, or monitoring industrial processes.
The SD card temperature logger works by writing the temperature readings, along with the timestamp, to a text file on the SD card. This file can be easily transferred to a computer for further analysis or archiving.
To implement the SD card temperature logger, follow these steps:
- Initialize the SD card module: In the
setup()
function, use theSD.begin(chipSelect)
function to initialize the SD card module, wherechipSelect
is the digital pin connected to theCS
(Chip Select) pin of the SD card module. - Open the data file: In the
loop()
function, use theSD.open("filename.txt", FILE_WRITE)
function to open a file on the SD card for writing. Replace"filename.txt"
with the desired name for your temperature log file. - Write temperature data to the file: Use the
file.print()
andfile.println()
functions to write the temperature data and any additional information (e.g., timestamp) to the file. Make sure to separate the data fields with commas or other delimiters for easy parsing later. - Close the file: After writing the data, call the
file.close()
function to close the file and ensure that all data is properly written to the SD card. - Repeat the process: In the
loop()
function, repeat the steps of opening the file, writing the data, and closing the file to continuously log temperature readings over time.
By implementing the SD card temperature logger, you can easily collect and analyze temperature data for various applications, such as monitoring environmental conditions, tracking patient temperatures in healthcare settings, or monitoring industrial processes.
Testing and Troubleshooting
After completing the hardware setup and programming the Arduino, it’s essential to test the contactless thermometer and troubleshoot any issues that may arise. Here are some steps you can follow:
- Check the wiring: Ensure that all connections between the Arduino board, MLX90614 sensor, SD card module, and any other components are properly made according to the circuit diagram.
- Open the Serial Monitor: In the Arduino IDE, open the Serial Monitor (Tools > Serial Monitor) to view the output from the Arduino board. This will help you identify any error messages or debugging information.
- Test the MLX90614 sensor: Upload a simple sketch to the Arduino board that reads and displays the ambient and object temperatures from the MLX90614 sensor. Verify that the temperature readings are reasonable and consistent.
- Test the SD card module: Upload a separate sketch to the Arduino board that writes and reads data to and from the SD card. This will help you identify any issues with the SD card module or the code related to file operations.
- Integrate the components: Once the individual components are working correctly, upload the complete sketch that integrates the MLX90614 sensor, SD card module, and any additional components (e.g., LCD display, buzzer/LED).
- Troubleshoot errors: If you encounter any errors or unexpected behavior, carefully review the code and ensure that all connections are secure. Common issues may include incorrect pin assignments, library conflicts, or SD card formatting issues.
- Verify temperature readings: Compare the temperature readings from the contactless thermometer with a known reference, such as a calibrated mercury thermometer or a high-quality digital thermometer. If the readings differ significantly, calibrate the MLX90614 sensor as described in the “Calibrating the Thermometer” section.
- Check for interference: Ensure that the contactless thermometer is not exposed to any external sources of infrared radiation, as this can affect the temperature readings. Additionally, avoid using the device in areas with high levels of electromagnetic interference (EMI).
- Seek community support: If you’re still experiencing issues, consider reaching out to the Arduino community forums or online resources for additional assistance and troubleshooting tips.
By following these steps and carefully testing each component, you can ensure that your contactless thermometer using Arduino with an SD card temperature logger is functioning correctly and providing accurate temperature measurements.
Frequently Asked Questions (FAQ)
- How accurate is the MLX90614 non-contact infrared temperature sensor?
The MLX90614 sensor has a factory-calibrated accuracy of ±0.5°C over the temperature range of 0°C to 50°C. However, environmental factors such as ambient temperature, humidity, and surface emissivity can affect the accuracy. It’s recommended to calibrate the sensor for your specific application and environment to ensure optimal accuracy.
- Can this contactless thermometer be used for medical purposes?
While the MLX90614 sensor is suitable for measuring body temperature, it’s essential to consult with medical professionals or regulatory authorities before using this device for medical purposes. Proper calibration, testing, and compliance with relevant standards and regulations are necessary for medical applications.
- How far can the MLX90614 sensor measure temperatures?
The MLX90614 sensor has a measurement range of up to 7 meters (approximately 23 feet). However, the accuracy of the temperature readings may decrease with increasing distance due to factors like atmospheric absorption and ambient temperature variations.
- Can I use a different SD card module or Arduino board for this project?
Yes, you can use different SD card modules or Arduino boards as long as they are compatible with the required libraries and have sufficient memory and processing power. You may need to modify the code and pin assignments accordingly.
- How long can the temperature data be stored on the SD card?
The amount of temperature data that can be stored on the SD card depends on the size of the SD card and the frequency of temperature readings. A typical 8GB SD card can store millions of temperature readings, providing ample storage capacity for most applications.