Table of Contents
Temperature Logger for MLX 90614 using Arduino SD Card Module- In today’s article, you will learn how to make Temperature Logger using Arduino, MLX 90614 contactless Infrared Temperature Sensor, SD Card Module, and DS3231 RTC “Real-time Clock”. For the data logging, I will be using Microsoft Excel.
For the implementation of this project, it is not necessary for you to use the temperature sensor, you can use any other sensor. And if you guys don’t need the date and time, you can also drop the DS3231 Real Time Clock from your components list.
If you don’t have this SD card module, you can just use a micro-SD card adapter. I have already written a detailed article on this. I have also written an article on the DS3231 Real Time Clock. So, you must read my previous articles for learning the most basic things.
Now let me tell you what is my purpose of using real-time clock with a temperature sensor. You, people, know very well that due to global warming, the temperature of the earth has increased considerably, and this is not a good thing at all. I want to display the temperature as well as the date and time in the excel sheet, so that I can easily know what the temperature was on which date and time. This way I can compare my recorded data with next year’s temperature values.
I have also selected MLX 90614 on some basis because this temperature sensor is very fast as compared to other sensors. And another good thing about this temperature sensor is that, it’s a non-contact infrared temperature sensor.
So MLX 90614 is the best choice for this temperature logger project.
After sharing with you some useful information, now I am going to explain its working, and then I will start a practical demonstration. And afterwards, I will explain circuit diagram, Arduino programming, and how to open the recorded data in an excel sheet, and then how to display the temperature data using graphs.
Altium Designer + Altium 365 + Octopart:
Altium 365 lets you hold the fastest design reviews ever. Share your designs from anywhere and with anyone with a single click. it’s easy, leave a comment tagging your teammate and they’ll instantly receive an email with a link to the design. Anyone you invite can open the design using a web browser. Using the browser interface, you’re able to comment, markup, cross probe, inspect, and more. Comments are attached directly to the project, making them viewable within Altium designer as well as through the browser interface. Design, share, and manufacture, all in the same space with nothing extra to install or configure. Connect to the platform directly from Altium Designer without changing how you already design electronics. Altium 365 requires no additional licenses and comes included with your subscription plan.
Get real-time component insights as you design with Octopart built into Altium 365. Octopart is the fastest search engine for electronic parts and gives you the most up-to-date part data like specs, datasheets, cad models, and how much the part costs at different amounts etc. Right in the design environment so you can focus on your designs. Start with Altium Designer and Activate Altium 365. Search for electronic parts on Octopart.
I have connected everything as per the circuit diagram which I will explain in a minute. Its working is very simple. Arduino measures the Temperature using the MLX 90614 Temperature sensor and takes the Date and Time information from the DS3231 Real Time Clock. Finally, Arduino stores this data in the micro SD card using CSV “Comma separated values” format. I will be storing the Date, Time, Day, and Temperature information in the file. For demonstration purposes, I will be logging data at 2 seconds intervals. But if you want you can increase or decrease this time interval in the programming. Now, let’s go ahead and start our practical demonstration.
First I inserted the micro SD card into the SD Card Adapter. Then I powered up the Arduino using my 12V adaptor. Finally, I started measuring the temperature. It was just a random testing.
I measured the ambient temperature, table temperature, my hand’s temperature, and also measure the flame temperature. Just to make sure I get different temperature values. So, after logging enough data. I switched off the Arduino and removed the SD Card. I plugged it into my Laptop’s SD card Slot and opened the file.
The temperature spikes which you can see are due to; when I used the Flame. If you don’t know how to display this data on the Graphs then you can watch my video given at the end of this article. I am sure you may have fully understood the advantage of data logging and how beneficial it can be during the post analysis. Right now, I am displaying the temperature values versus the time. You can check the temperature at any particular time.
I am sure by now, you might have got an idea of how does this system work. So, without any further delay let’s get started!!!
Other Tools and Components:
*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!
SD Card Module:
This is the SD Card Reading and Writing Module which can be easily interfaced with Arduino and other embedded boards and microcontrollers. With a very basic program, you can read and write to the SD card over the SPI interface. This card module is provided with the onboard 3.3V voltage regulator due to which it can be interfaced with 3.3V compatible controller boards like ESP32 and ESP8266, etc. In order to use the micro SD card with this module, you will need a micro SD card adaptor.
SD Card Pinout:
This SD card module is provided with male headers which are clearly labeled as
If you are planning to use this Card Module with the Arduino then connect the 5v pin with the Arduino’s 5V, and if you are planning to use this Card module with the ESP32 then connect the 3.3v pin with the ESP32 3.3V pin. Never use 5 volts when using this SD card module with 3.3V compatible controller boards.
While performing the initial tests, I powered up the SD card module using 3.3V and it didn’t work. Then I powered up this module using the Arduino’s 5V and it worked. So, in a nutshell, if you are using the Card Module with the Arduino then use 5volts, and if you are using the Card Module with the ESP32 or ESP8266 then use 3.3V. For more details read my article available on electroniclinic.com. I will provide a link in the description. So, first, let’s start with the Arduino and Card Module.
SD Card Module, Description:
This SD Card Reader/Writer is ideal for many Micro-controller projects (Arduino, Pic, Versalino, etc…) including (but not limited to) projects involving sensor and other data logging activities. Audio playing and/or recording. Video, Image, and other multimedia storage and retrieval for advanced embedded applications. Processing large quantities of data with a robot, or storing/retrieving items larger than the limited memory available on your microprocessor. This can be used for a broad range of applications from scientific data collection for biological/geological and other statistical studies in the field, to storing map data for your robots surroundings in and outside the home.
Working Voltage: 3.3 & 5V(DC Both required) Requires SPI Capable Microprocessor Size limitations are library dependent, but most microprocessors have libraries pre-coded that will support sizes upward of 1GB 7 wires required (including power and ground) Fits standard size SD Cards Package Contents: 1*SD Card Reader/Writer
DS3231 RTC Real Time Clock:
This is the RTC DS3231 module. The RTC stands for Real-Time Clock. You might be thinking why we need the RTC DS3231 module when the Arduino itself has the built-in timekeeper. Arduino is really powerful and we can make a real-time clock, but the problem comes in when the Arduino is turned off, or the power is disconnected, the time and date information is completely lost.
But if you look at the RTC DS3231 module it has a battery and can keep track of the Time and Date information even if the main power supply is disconnected or we reprogram the microcontroller.
RTC DS3231 Features:
The RTC DS3231is a low-cost, highly accurate Real Time Clock, which can maintain hours, minutes, and seconds. This module can also maintain the day, month, and year information. The RTC DS3231 module also has automatic compensation for leap years and for months with fewer than 31 days.
This Module can be powered up using 3.3 volts or 5 volts. As you can see clearly in the picture above, the DS3231 module has a total of 6 male headers and are clearly labeled. Out of these 6 Pins, we will be using only 4 Pins which are the SCL, SDA, VCC, and GND.
MLX90614 Temperature Sensor:
The DFRobot MLX90614 Infrared Temperature sensor which uses infrared rays to detect the temperature without direct contact with the object. This method gives us temperature very quickly and accurately. In recent years non-contact measurement methods have been used for medical, environmental monitoring, home automation, automotive electronic, aerospace and military applications. This sensor reads the surface temperature. We can use it to detect fever by reading the temperature of the body. The IR temperature probe consists of an optical system, photoelectric detector, and amplifier, signal processing and output module.
The optical system collects the infrared radiation in its field of view, whose area is decided by optical components and position of the thermometer and the infrared radiation energy is converted in to corresponding electrical signals when converging on the photoelectric detector. After being processed by the amplifier and signal processing circuit, calibrated according to the algorithm and target emissivity, the signal is converted in to temperature value of the target. We have used the Blynk application in which we will display the temperature. Using the Blynk application we can see the temperature everywhere in the world in the mobile. We will display the temperature in Fahrenheit and centigrade.
This sensor consists of four pins as shown in the figure.
- SEN0206 (MLX90614-BBC)
- Operating Voltage: 3.3V – 5V
- Operating Current: 1.2mA
- Temperature: -70.01℃ to +382.19℃, (0.01 ℃ resolution)
- Interface Type: IIC
- Interface Line Sequence: VCC, GND, SCL, SDA
- FOV: 35°
- Dimensions: 31.5*18 mm/1.24 x 0.7 inches
- Operating Voltage: 3.3V-5V
- Operating Current: 1.2mA
- Temperature: -70.01℃ to +270℃，(0.01 ℃ resolution)
- Interface Type: IIC
- Interface Line Sequence: VCC，GND，SCL，SDA
- FOV: 5°
- Dimensions: 31.5*18mm/1.24 x 0.7 inches
Temperature Logger Circuit Diagram:
The 5V and GND pins of the SD Card Module are connected with the Arduino’s 5v and ground. CS is connected with pin 10, MOSI is connected with pin 11, SCK is connected with pin 13, and MISO is connected with pin 12 of the Arduino.
As the MLX90614 Temperature Sensor and DS3231 RTC Real Time Clock both are I2C supported modules so that’s why the SDA and SCL pins of both the modules are connected with the A4 and A5 pins on the Arduino. A4 is the SDA and A5 is the SCL. The Vin and GND pins of the MLX90614 are connected with the 3.3V and GND pins. While the Vin and GND pins of the DS3231 module are connected with the 5V and GND pins.
On the Left side is the regulated 5 volts power supply based on the linear voltage regulator 7805. Now, let’s take a look at the programming.
Required Arduino Libraries:
Before you start the programming, first of all, make sure you download the SD.h, RTClib.h, and DFRobot_MLX90614.h Libraries.
To install the SD.h library simply click on the Sketch Menu, then go to include library, and click on the Manage Libraries. Type sd in the search box and wait for a while.
As you can see I have already installed the latest version of the SD library.
Repeat the same steps for the RTClib library.
Now, repeat the same steps for the DFRobot_MLX9061 library.
After you have installed all the required libraries, then all you need is download the program given below. Anyway, all the instructions are well commented so you won’t have any problem in understanding the code.
Temperature Logger Arduino Programming:
/* SD card Temperature data logger SD card connections ** MOSI - pin 11 ** MISO - pin 12 ** CLK - pin 13 ** CS - pin 10
You can see I am using a delay of 2 seconds. You can increase or decrease this time interval. I know using delays really disturbs the normal execution of the code. So, if you want you can use a timer to run the TakeReading() function. So, that’s all for now.