Temperature is a crucial parameter used in various systems and industrial sectors, various sensors. In this work, the rate of change of energy of boiling water is monitored as it cools down to room temperature using Arduino UNO based system. The temperature readings are captured using the DS18B20 temperature sensor which are then processed using MATLAB to compute changes in energy using customized code based on Newton’s law of cooling.
Temperature is one of the most important metrics, used in a wide variety of sectors, including chemical, pharmaceutical and food, machinery and equipment, and almost every other industry. There are a number of devices that can be used to measure temperature such as temperature transmitter, thermocouples, Change-of-State temperature measurement devices, Resistance Temperature Devices (RTD), Fluid-Expansion devices, Bimetallic measurement devices, and Infrared temperature measurement devices. The changes in temperatures have a direct relation with change in the energy of the body, substance or fluid under study hence accurate temperature measurements play an important role.
A. Arduino UNO
Arduino UNO  is a low-cost, flexible and easy-to-use programmable open-source microcontroller based on the ATmega328P microchip, which can interface other peripherals such as sensors, other microcontroller boards, LEDs, servos, and motors. The UNO is a 68.6 mm x 53.4 mm board that comprises 6 analog pin inputs, 14 digital pins, a USB connector, a power jack, and an ICSP (In-Circuit Serial Programming) header.
A labelled diagram of the Arduino UNO board is shown in Figure 1 and the functionality of each of the component is explained in detail as below:
Table 1. Function of Arduino UNO parts
It is a 8-bit single chip microcontroller that combines the memory, Analog to Digital converter, SPI serial ports, I/O lines, registers, timer, external and internal interrupts, and oscillator.
It resets the connection of the circuit
This pin allows the user to program using the firmware of the Arduino board.
It allows the connection of the Arduino board to the computer, which is essential for the programming of the board.
Power LED Indicator
The LED shows the power status of the board, it is lit up when connected to a power source.
It delivers only the required amount of voltage to the input of the Arduino board and controls the DC power supply utilized by the board and other peripheral devices.
Digital I/O pins
The digital pins have the value HIGH or LOW value. They are 14 in total, numbered from D0-D13.
It scales the input voltage to 5V.
The function of Analog pins is to read the analog sensor used in the connection. They are 6 in total numbered from A0-A5.
The ground pin acts as a pin with zero voltage.
Tx and Rx LEDs
These LEDs indicate the transfer of data, where Tx indicates the transferring and Rx indicates the receiving of data.
It is the input voltage.
This pin is used to feed a reference voltage to the Arduino UNO board from the external power supply.
B. DS18B20 temperature sensor
DS18B20  is a popularly used temperature sensor, primarily because it's cheap, easy-to-use and waterproof. This temperature sensor provides 9 to 12-bit configurable temperature reading which indicates the temperature of the device. The data transfer takes place over a 1-wire interface connected from the central microprocessor (Arduino UNO), this allows the power for reading, writing, and temperature conversions from the data line itself without the need for an external power source. Each sensor contains a unique silicon serial number, due to which multiple sensors can exist on the same 1-wire connection. This provides a path for placing multiple sensors in different places and hence this sensor finds its application in sensing temperature inside buildings, equipment or machinery, and process monitoring and control.
C. Newton’s law of cooling
The Newton's law of cooling states that the rate of heat loss of a body is directly proportional to the difference in the temperatures between the body and its surroundings provided the temperature difference is small and the nature of radiating surface remains same.
The experimentation was divided into two segments, first the hardware connections setup and secondly the MATLAB-Arduino software linkage.
A. Hardware connections
The connections of the sensors with the Arduino board are done as per the circuit diagram shown in Figure 3, upon which the board is powered up using the USB connection to a laptop computer. The sensor is configured using the Arduino IDE version 1.8.13, where the DallasTemperature version 3.9.0 library is imported to code workspace using the library manager. Upon defining the programming instructions for the temperature sensing, the code is uploaded to the Arduino and it initializes the temperature sensing process.
???????III. Software setup and calculations
For the calculation of energy loss, firstly the temperature variation of the hot fluid is captured by creating a dynamic linkage between MATLAB R2021b and the Arduino board. MATLAB provides a Support Package for Arduino Hardware that allows to write MATLAB code, which later can be compiled, loaded and executed on an Arduino board. This package enables to read/write to I/O pins, communicate with peripheral device via I2C or SPI, etc. Since MATLAB  is a high-level interpreted language, results can be seen from I/O instructions immediately, without compiling. MATLAB includes thousands of built-in math, engineering, and plotting functions that can be used to quickly analyze and visualize data collected from your Arduino.
The calibration of the temperature sensor was done at room temperature of 30oC as evident from the Figure 4.
Once the sensor was calibrated, a dynamic link between Arduino system and MATLAB was established, that enabled MATLAB to directly read the temperature from the sensor. The temperature readings were then plotted in MATLAB plot GUI as shown in Figure 5. As evident, due a to high sampling frequency of the Arduino certain noises in the data is obtained, which are nullified and processed.
The Figure 6 shows the temperature variation of the hot water with respect to time. The experimentation and sampling were done at a surrounding temperature of 35oC and hot water used at the start of the experimentation was at 95oC. The water reached the temperature of the surrounding after 307 seconds (~ 5 mins).
Using a customized MATLAB script, the calculation of rate of loss of energy of water was implemented and the results is shown in Figure 7, where y-axis represents the loss of energy in kJ/s and x-axis denotes time in seconds. As evident from the plot, at the start of the experiment, the magnitude of energy loss was high and as time increased the magnitude reduced, which is obvious from the fact that, with the passage of time the energy content of water reduces on account of cooling.
Given the importance of temperature measurements in various applications, this study attempted to highlight its significance in estimating the loss of energy of water as it cools down from boiling state. The temperature measurements were carried out using a DS18B20 sensor linked with Arduino UNO and interfaced with MATLAB. The MATLAB software leveraged the data capture and live plotting. After processing the data to remove the noise, the variation of temperature and loss of energy with respect to time was visualized.
 UNO R3. (2022). Arduino Documentation. Retrieved August 4, 2022, from https://docs.arduino.cc/hardware/uno-rev3
 DS18B20 Programmable Resolution 1-Wire Digital Thermometer, datasheets.maximintegrated.com/en/ds/DS18B20.pdf
 MATLAB Support Package for Arduino Hardware Documentation - MathWorks India. (2022). MATLAB Support Package for Arduino Hardware. https://in.mathworks.com/help/supportpkg/arduinoio/