Temperature Sensor for Arduino Applied for COVID 19

by fcodiegomoreira in Circuits > Arduino

3047 Views, 15 Favorites, 0 Comments

Temperature Sensor for Arduino Applied for COVID 19

0.jpg

The temperature sensor for Arduino is a fundamental element when we want to measure the temperature of a processor of the human body.

The temperature sensor with Arduino must be in contact or close to receive and measure the heat level. That's how thermometers work.

These devices are extremely used to measure the body temperature of sick people, as the temperature is one of the first factors that change in the human body when there is an abnormality or disease.

One of the diseases that alter the temperature of the human body is COVID 19. Therefore, we present the main symptoms:

Cough Tiredness Difficulty breathing (Severe cases) Fever Fever is a symptom whose main characteristic is an increase in body temperature. In this disease, we need to constantly monitor these symptoms.

Thus, we will develop a project to monitor the temperature and store this data on a memory card through a JLCPCB Datalogger using a temperature sensor with Arduino.

Therefore, in this article you will learn:

  • How does a JLCPCB Datalogger with a temperature sensor with Arduino?
  • How works the temperature sensor with Arduino.
  • How works the DS18B20 temperature sensor with Arduino
  • Use buttons with multiple functions.

Next, we will show you how you will develop your JLCPCB Datalogger using the Arduino temperature sensor.

Supplies

Arduino UNO

JLCPCB Printed Circuit Board

DS18B20 Temperature Sensor

Arduino Nano R3

Jumpers

LCD Display 16 x 2

Pushbutton switch

Resistor 1kR

SD Card Module for Arduino

Construction of the JLCPCB Datalogger With Temperature Sensor With Arduino

1.jpg

As previously mentioned, the project consists of creating a JLCPCB Datalogger with Temperature Sensor with Arduino, and through this data, we can monitor the temperature of the patient being treated.

Thus, the circuit is shown in the Figure above.

Therefore, as you can see, this circuit has a DS18B20 temperature sensor with Arduino, which is responsible for measuring the patient's temperature reading.

In addition, the Arduino Nano will be responsible for collecting this data and storing it on the SD Card Module's memory card.

Each information will be saved with its respective time, which will be read from the RTC Module DS1307.

Thus, for the data of the temperature sensor with Arduino to be saved, the user must perform the process through the Control Menu with the 16x2 LCD.

2.jpg

Each button is responsible for controlling an option, as shown on the LCD screen 16x2 in Figure 2.

Each option is responsible for performing a function in the system, as shown below.

  • Option M is responsible for starting the measurement and recording of data on the Memory Card.
  • Option H is responsible for adjusting the system hours.
  • Option O/P is used to confirm data entry in the system or to pause writing data to the memory card.

To understand the system control process, we will provide the code below and discuss the step-by-step control system of the JLCPCB Datalogger with Temperature Sensor with Arduino.

#include <DallasTemperature.h> //Library with all function of DS18B20 Sensor
#include <DS1307.h>
#include <LiquidCrystal_I2C.h> //Biblioteca I2C do LCD 16x2
#include <Wire.h> //Biblioteca de Comunicacao I2C 
#include <OneWire.h> //OneWire Library for DS18B20 Sensor
#include <SD.h>
#include <SPI.h>

LiquidCrystal_I2C lcd(0x27,16,2);  // Configurando o endereco do LCD 16x2 para 0x27

#define ONE_WIRE_BUS 8 //Digital Pin to connect the DS18B20 Sensor

//Define uma instancia do oneWire para comunicacao com o sensor
OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);
DeviceAddress sensor1;

File myFile;

#define Buttonmeasure 2
#define Buttonadjusthour 3
#define Buttonok 4

bool measure = 0, adjusthour = 0, ok = 0;
bool measure_state = 0, adjusthour_state = 0, ok_state = 0;
bool measure_process = 0, adjust_process = 0;

byte actualMin = 0, previousMin = 0;
byte actualHour = 0, previousHour = 0;
byte minUpdate = 0;

int pinoSS = 10; // Pin 53 para Mega / Pin 10 para UNO

int DataTime[7];

void updateHour()
{
      DS1307.getDate(DataTime);
      
      if(DataTime[5] != minUpdate)
      {
          sprintf(times, "%02d:%02d", DataTime[4], DataTime[5]);
          
          lcd.setCursor(0,0);
          lcd.print("                ");
          lcd.setCursor(5,0);
          lcd.print(times);
          
          minUpdate = DataTime[5];
      }
      
}

void updateTemp()
{
      DS1307.getDate(DataTime);
      
      if(DataTime[5] != minUpdate)
      {
          sprintf(times, "%02d:%02d", DataTime[4], DataTime[5]);

          lcd.clear();
          lcd.setCursor(5,0);
          lcd.print(times);

          lcd.setCursor(0,1);
          lcd.print("Temperature: ");
          lcd.setCursor(14,1);
          
          sensors.requestTemperatures();
          float TempSensor = sensors.getTempCByIndex(0);
      
          lcd.print(TempSensor);
          
          
          minUpdate = DataTime[5];
      }
      
}

void setup() 
{ 

Serial.begin(9600);
DS1307.begin();
sensors.begin();
pinMode(pinoSS, OUTPUT); // Declara pinoSS como saída

Wire.begin(); //Inicializacao da Comunicacao I2C
lcd.init();                      //Inicializacao do LCD
lcd.backlight();

lcd.setCursor(3,0);
lcd.print("Temp System");
lcd.setCursor(3,1);
lcd.print("Datalogger");
delay(2000);

// Localiza e mostra enderecos dos sensores
Serial.println("Localizando sensores DS18B20...");
Serial.print("Sensor Localization successfully!");
Serial.print(sensors.getDeviceCount(), DEC);
Serial.println(" Sensor");

if(SD.begin()) 
{
// Inicializa o SD Card
Serial.println("SD Card pronto para uso."); // Imprime na tela
}

else 

{
Serial.println("Falha na inicialização do SD Card.");
return;
}
  
  DS1307.getDate(DataTime);
    
  lcd.clear();
  
  sprintf(times, "%02d:%02d", DataTime[4], DataTime[5]);

  lcd.setCursor(5,0);
  lcd.print(times);
  lcd.setCursor(0,1);
  lcd.print("1-M   2-H  3-O/P");
}

void loop()
{  
  updateHour();
  
  //Reading button states
  measure = digitalRead(Buttonmeasure);
  adjusthour = digitalRead(Buttonadjusthour);
  ok = digitalRead(Buttonok);
  
  if(measure == 0 && measure_state == 1)
  {
    measure_state = 0;
  }
  
  if(measure == 1 && measure_state == 0 && measure_process == 0)
  {
    measure_process = 1;
    measure_state = 1;

    if (SD.exists("temp.txt"))
    {
      Serial.println("Apagou o arquivo anterior!");
      SD.remove("temp.txt");
      myFile = SD.open("temp.txt", FILE_WRITE); // Cria / Abre arquivo .txt
      Serial.println("Criou o arquivo!");
    }
    
    else
    
    {
      Serial.println("Criou o arquivo!");
      myFile = SD.open("temp.txt", FILE_WRITE); // Cria / Abre arquivo .txt
      myFile.close();
    }
    
    delay(500);
    
    myFile.print("Hour: ");
    myFile.println("Temperature");

    DS1307.getDate(DataTime);
    actualMin = previousMin = DataTime[5];

    sprintf(times, "%02d:%02d", DataTime[4], DataTime[5]);

    lcd.clear();
    lcd.setCursor(5,0);
    lcd.print(times);

    lcd.setCursor(0,1);
    lcd.print("Temperature: ");
    lcd.setCursor(14,1);
          
    sensors.requestTemperatures();
    float TempSensor = sensors.getTempCByIndex(0);

    lcd.print(TempSensor);
  }
  
  if(adjusthour == 0 && adjusthour_state == 1)
  {
    adjusthour_state = 0;
  }
  
  if(adjusthour == 1 && adjusthour_state == 0 && measure_process == 0)
  {
    adjust_process = 1;
  }
  
  //--------------------------------------------------Measuring Process-----------------------------------------------------------
  if(measure_process == 1)
  {
    updateTemp();
    
    byte contMin = 0, contHour = 0;
    DS1307.getDate(DataTime);
    actualMin = DataTime[5];

//---------------------------------------------------------Count Minutes----------------------------------------------------------
      if(actualMin != previousMin)
      {
        contMin++;
        previousMin = actualMin;
      }
      
      if(contMin == 5)
      {
        sprintf(times, "%02d:%02d ", DataTime[4], DataTime[5]);
        
        sensors.requestTemperatures();
        float TempSensor = sensors.getTempCByIndex(0);
      
        myFile.print(times);
        myFile.println(TempSensor);
        contMin = 0;
      }
//-----------------------------------------------------------Count Hours----------------------------------------------------------
      if(actualHour != previousHour)
      {
        contHour++;
        previousHour = actualHour;
      }
      
      if(contHour == 5)
      {
        myFile.close();
        lcd.clear();
        lcd.setCursor(5,0);
        lcd.print("Finished");
        lcd.setCursor(5,1);
        lcd.print("Process");
        measure_process = 0;
        contHour = 0;
      }
//----------------------------------------------Condition to stop the datalogger--------------------------------------------------
      if(ok == 1)
      {
        myFile.close();
        
        lcd.clear();
        lcd.setCursor(6,0);
        lcd.print("Stoped");
        lcd.setCursor(5,1);
        lcd.print("Process");
        
        measure_process = 0;
        delay(2000);

        lcd.clear();

        DS1307.getDate(DataTime);
        
        sprintf(times, "%02d:%02d", DataTime[4], DataTime[5]);
        
        lcd.setCursor(5,0);
        lcd.print(times);
        lcd.setCursor(0,1);
        lcd.print("1-M   2-H  3-O/P");
      }
  
  }

//-----------------------------------------------------Adjust Hours---------------------------------------------------------------

  //Adjust Hour
  if(adjust_process == 1)
  {
      lcd.clear();
      DS1307.getDate(DataTime);
      lcd.setCursor(0,0);
      lcd.print("Adjust Hour:");

      sprintf(times, "%02d:%02d", DataTime[4], DataTime[5]);
  
      lcd.setCursor(5,1);
      lcd.print(times);

    //Hour Adjust
    do
    {
      measure = digitalRead(Buttonmeasure);
      adjusthour = digitalRead(Buttonadjusthour);
      ok = digitalRead(Buttonok);
      
      if(measure == 0 && measure_state == 1)
      {
        measure_state = 0;    
      }
      
      if(measure == 1 && measure_state == 0)
      {  
        DataTime[4]++;
        
        if(DataTime[4] > 23)
        {
          DataTime[4] = 0;  
        }
        
        measure_state = 1;
        
        sprintf(times, "%02d:%02d", DataTime[4], DataTime[5]);
        
        lcd.setCursor(5,1);
        lcd.print(times);
        DS1307.setDate(DataTime[0],DataTime[1],DataTime[2],DataTime[3],DataTime[4],DataTime[5],00);
      }
      
      if(adjusthour == 0 && adjusthour_state == 1)
      {
        adjusthour_state = 0;
      }
    
      if(adjusthour == 1 && adjusthour_state == 0)
      {  
        DataTime[5]++;

        if(DataTime[5] > 59)
        {
          DataTime[5] = 0;
        }
        
        sprintf(times, "%02d:%02d", DataTime[4], DataTime[5]);
  
        lcd.setCursor(5,1);
        lcd.print(times);

        DS1307.setDate(DataTime[0],DataTime[1],DataTime[2],DataTime[3],DataTime[4],DataTime[5],00);
        
        adjusthour_state = 1;
      }

      if(ok == 1)
      {
        lcd.clear();

        DS1307.getDate(DataTime);
        sprintf(times, "%02d:%02d", DataTime[4], DataTime[5]);
        
        lcd.setCursor(0,0);
        lcd.print(times);
        lcd.setCursor(0,1);
        lcd.print("1-M    2-H   3-O");
        adjust_process = 0;
      }
    
    }while(ok != 1);
  }
//------------------------------------------------------End Adjust Hour-----------------------------------------------------------

  

}

First, we define all the libraries for controlling the modules and declaring variables used when programming the JLCPCB Datalogger with a temperature sensor for Arduino. The code block is shown below.

#include <DallasTemperature.h> //Library with all function of DS18B20 Sensor
#include <DS1307.h>
#include <LiquidCrystal_I2C.h> //Biblioteca I2C do LCD 16x2
#include <Wire.h> //Biblioteca de Comunicacao I2C 
#include <OneWire.h> //OneWire Library for DS18B20 Sensor
#include <SD.h>
#include <SPI.h>

LiquidCrystal_I2C lcd(0x27,16,2);  // Configurando o endereco do LCD 16x2 para 0x27

#define ONE_WIRE_BUS 8 //Digital Pin to connect the DS18B20 Sensor

//Define uma instancia do oneWire para comunicacao com o sensor
OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);
DeviceAddress sensor1;

File myFile;

#define Buttonmeasure 2
#define Buttonadjusthour 3
#define Buttonok 4

bool measure = 0, adjusthour = 0, ok = 0;
bool measure_state = 0, adjusthour_state = 0, ok_state = 0;
bool measure_process = 0, adjust_process = 0;

byte actualMin = 0, previousMin = 0;
byte actualHour = 0, previousHour = 0;
byte minUpdate = 0;

int pinoSS = 10; // Pin 53 para Mega / Pin 10 para UNO

int DataTime[7];

Hereafter, we have the void setup function. This function is used to configure the pins and device initialization, as shown below.

void setup() 
{ 

Serial.begin(9600);
DS1307.begin();
sensors.begin();

pinMode(pinoSS, OUTPUT); // Declara pinoSS como saída

Wire.begin(); //Inicializacao da Comunicacao I2C
lcd.init();                      //Inicializacao do LCD
lcd.backlight();

lcd.setCursor(3,0);
lcd.print("Temp System");
lcd.setCursor(3,1);
lcd.print("Datalogger");
delay(2000);

// Localiza e mostra enderecos dos sensores
Serial.println("Localizando sensores DS18B20...");
Serial.print("Sensor Localization successfully!");
Serial.print(sensors.getDeviceCount(), DEC);
Serial.println(" Sensor");

if(SD.begin()) 
{
// Inicializa o SD Card
Serial.println("SD Card pronto para uso."); // Imprime na tela
}

else 

{
Serial.println("Falha na inicialização do SD Card.");
return;
}
  
  DS1307.getDate(DataTime);
    
  lcd.clear();
  
  sprintf(times, "%02d:%02d", DataTime[4], DataTime[5]);

  lcd.setCursor(5,0);
  lcd.print(times);
  lcd.setCursor(0,1);
  lcd.print("1-M   2-H  3-O/P");
}

First, the serial communication, the real-time clock and the temperature sensor for Arduino DS18B20 were started.
After initializing and testing the devices, the message with the menu options was printed on the 16x2 LCD screen. This screen is shown in Figure 1.

After that, the system reads the hours and updates the value by calling the updateHour function. Thus, this function has the purpose of presenting the hourly value every minute. The function code block is shown below.

void updateHour()
{
      DS1307.getDate(DataTime);
      
      if(DataTime[5] != minUpdate)
      {
          sprintf(times, "%02d:%02d", DataTime[4], DataTime[5]);
          
          lcd.setCursor(0,0);
          lcd.print("                ");
          lcd.setCursor(5,0);
          lcd.print(times);
          
          minUpdate = DataTime[5];
      }
      
}

3.jpg

In addition to updating the hours, the user can select one of the three buttons to monitor the patient with a temperature sensor with Arduino. The circuit is shown in the Figure above.

JLCPCB Datalogger Control Menu

4.jpg

First, the user must check and adjust the system hours. This process is performed when the second button is pressed.

When the button is pressed, the following screen should appear, which is shown in Figure above.

6.jpg

From this screen, the user will be able to enter the hour and minute values from the buttons connected to digital pins 2 and 3 of the Arduino. The buttons are shown in the Figure above.

The code portion for controlling the hours is shown below.

if(adjusthour == 0 && adjusthour_state == 1)
{
  adjusthour_state = 0;
}
  
if(adjusthour == 1 && adjusthour_state == 0 && measure_process == 0)
{
  adjust_process = 1;
}

When the hours' button is pressed and the measure_process variable is set to 0, the condition will be true and the adjust_process variable will be set to 1.
The measure_process variable is used to signal that the system is monitoring temperature. When its value is 0, the system will allow the user to enter the time setting menu. Therefore, after the adjust_process variable receives a value of 1, the system will enter the time adjustment condition. This code block is shown below.

//-----------------------------------------------------Adjust Hours---------------------------------------------------------------

  //Adjust Hour
  if(adjust_process == 1)
  {
      lcd.clear();
      DS1307.getDate(DataTime);
      lcd.setCursor(0,0);
      lcd.print("Adjust Hour:");

      sprintf(times, "%02d:%02d", DataTime[4], DataTime[5]);
  
      lcd.setCursor(5,1);
      lcd.print(times);

    //Hour Adjust
    do
    {
      measure = digitalRead(Buttonmeasure);
      adjusthour = digitalRead(Buttonadjusthour);
      ok = digitalRead(Buttonok);
      
      if(measure == 0 && measure_state == 1)
      {
        measure_state = 0;    
      }
      
      if(measure == 1 && measure_state == 0)
      {  
        DataTime[4]++;
        
        if(DataTime[4] > 23)
        {
          DataTime[4] = 0;  
        }
        
        measure_state = 1;
        
        sprintf(times, "%02d:%02d", DataTime[4], DataTime[5]);
        
        lcd.setCursor(5,1);
        lcd.print(times);
        DS1307.setDate(DataTime[0],DataTime[1],DataTime[2],DataTime[3],DataTime[4],DataTime[5],00);
      }
      
      if(adjusthour == 0 && adjusthour_state == 1)
      {
        adjusthour_state = 0;
      }
    
      if(adjusthour == 1 && adjusthour_state == 0)
      {  
        DataTime[5]++;

        if(DataTime[5] > 59)
        {
          DataTime[5] = 0;
        }
        
        sprintf(times, "%02d:%02d", DataTime[4], DataTime[5]);
  
        lcd.setCursor(5,1);
        lcd.print(times);

        DS1307.setDate(DataTime[0],DataTime[1],DataTime[2],DataTime[3],DataTime[4],DataTime[5],00);
        
        adjusthour_state = 1;
      }

      if(ok == 1)
      {
        lcd.clear();

        DS1307.getDate(DataTime);
        sprintf(times, "%02d:%02d", DataTime[4], DataTime[5]);
        
        lcd.setCursor(0,0);
        lcd.print(times);
        lcd.setCursor(0,1);
        lcd.print("1-M    2-H   3-O");
        adjust_process = 0;
      }
    
    }while(ok != 1);
  }

In this condition, the system will display the message shown in Figure 4 and then wait for the values to adjust internally in the while loop.
When adjusting the hours, these buttons have their functions changed, that is, they are multifunction.

This allows you to use a button for more than one function and reduce the complexity of the system.

In this way, the user will adjust the value of the hours and minutes and then save the data in the system when the Ok button is pressed.

As you can see, the system will read the 3 buttons, as shown below.

measure = digitalRead(Buttonmeasure);
adjusthour = digitalRead(Buttonadjusthour);
ok = digitalRead(Buttonok);

Note that the measure button (Buttonmeasure) has changed its function. It will now be used to adjust the hour values, as shown below.
The following two conditions are similar and are used to adjust the hours and minutes, as shown above.

if(measure == 0 && measure_state == 1)
      {
        measure_state = 0;    
      }
      
      if(measure == 1 && measure_state == 0)
      {  
        DataTime[4]++;
        
        if(DataTime[4] > 23)
        {
          DataTime[4] = 0;  
        }
        
        measure_state = 1;
        
        sprintf(times, "%02d:%02d", DataTime[4], DataTime[5]);
        
        lcd.setCursor(5,1);
        lcd.print(times);
        DS1307.setDate(DataTime[0],DataTime[1],DataTime[2],DataTime[3],DataTime[4],DataTime[5],00);
      }
      
      if(adjusthour == 0 && adjusthour_state == 1)
      {
        adjusthour_state = 0;
      }
    
      if(adjusthour == 1 && adjusthour_state == 0)
      {  
        DataTime[5]++;

        if(DataTime[5] > 59)
        {
          DataTime[5] = 0;
        }
        
        sprintf(times, "%02d:%02d", DataTime[4], DataTime[5]);
  
        lcd.setCursor(5,1);
        lcd.print(times);

        DS1307.setDate(DataTime[0],DataTime[1],DataTime[2],DataTime[3],DataTime[4],DataTime[5],00);
        
        adjusthour_state = 1;
      }

Therefore, each time one of the two buttons is pressed, the value of positions 4 and 5 of the DataTime vector will be changed and secondly, these values will be saved in the DS1307 memory.

After the adjustments, the user must click on the Ok button, to finish the process. When this event occurs, the system will execute the following lines of code.

if(ok == 1)
      {
        lcd.clear();

        DS1307.getDate(DataTime);
        sprintf(times, "%02d:%02d", DataTime[4], DataTime[5]);
        
        lcd.setCursor(0,0);
        lcd.print(times);
        lcd.setCursor(0,1);
        lcd.print("1-M    2-H   3-O");
        adjust_process = 0;
      }

It will enter the above condition and present the hour message and the Options Menu to the user.

Finally, the user must start the patient monitoring process through the temperature sensor with Arduino JLCPCB Datalogger.

To do this, the user must press the measurement button, which is connected to digital pin 2.

Then, the system will perform the reading with the temperature sensor for Arduino and save it on the memory card. The circuit region is shown in the Figure above.

7.jpg

Therefore, when the button is pressed, the following portion of code will be executed.

if(measure == 0 && measure_state == 1)
  {
    measure_state = 0;
  }
  
  if(measure == 1 && measure_state == 0 && measure_process == 0)
  {
    measure_process = 1;
    measure_state = 1;

    if (SD.exists("temp.txt"))
    {
      Serial.println("Apagou o arquivo anterior!");
      SD.remove("temp.txt");
      myFile = SD.open("temp.txt", FILE_WRITE); // Cria / Abre arquivo .txt
      Serial.println("Criou o arquivo!");
    }
    
    else
    
    {
      Serial.println("Criou o arquivo!");
      myFile = SD.open("temp.txt", FILE_WRITE); // Cria / Abre arquivo .txt
      myFile.close();
    }
    
    delay(500);
    
    myFile.print("Hour: ");
    myFile.println("Temperature");

    DS1307.getDate(DataTime);
    actualMin = previousMin = DataTime[5];

    sprintf(times, "%02d:%02d", DataTime[4], DataTime[5]);

    lcd.clear();
    lcd.setCursor(5,0);
    lcd.print(times);

    lcd.setCursor(0,1);
    lcd.print("Temperature: ");
    lcd.setCursor(14,1);
          
    sensors.requestTemperatures();
    float TempSensor = sensors.getTempCByIndex(0);

    lcd.print(TempSensor);
  }

In the code portion above, the system will assign a value of 1 to the measure_process variable. It is responsible for allowing the data to be saved on the SD Card.

In addition, the system will check whether a text file with a data log exists or not. If there is a file, the system will delete and create a new one to store the data.

After that, it will create two columns: one for the hours and one for the temperature inside the text file.

After that, it will display the hours and temperature on the LCD screen, as shown in Figure above.

After that, the code flow will execute the following program block.

if(measure_process == 1)
  {
    updateTemp();
    
    byte contMin = 0, contHour = 0;
    DS1307.getDate(DataTime);
    actualMin = DataTime[5];

//---------------------------------------------------------Count Minutes----------------------------------------------------------
      if(actualMin != previousMin)
      {
        contMin++;
        previousMin = actualMin;
      }
      
      if(contMin == 5)
      {
        sprintf(times, "%02d:%02d ", DataTime[4], DataTime[5]);
        
        sensors.requestTemperatures();
        float TempSensor = sensors.getTempCByIndex(0);
      
        myFile.print(times);
        myFile.println(TempSensor);
        contMin = 0;
      }
//-----------------------------------------------------------Count Hours----------------------------------------------------------
      if(actualHour != previousHour)
      {
        contHour++;
        previousHour = actualHour;
      }
      
      if(contHour == 5)
      {
        myFile.close();
        lcd.clear();
        lcd.setCursor(5,0);
        lcd.print("Finished");
        lcd.setCursor(5,1);
        lcd.print("Process");
        measure_process = 0;
        contHour = 0;
      }
//----------------------------------------------Condition to stop the datalogger-----

First, the updateTemp() function will be executed. It is similar to the updateHour() function; however, it displays the temperature every 1 minute.

After that, the system will collect the time data from the Real-Time Clock and store the current minute value in the currentMin variable.

Then, it will check if the min variable has been changed, according to the condition presented below

if(actualMin != previousMin)
{
   contMin++;
   previousMin = actualMin;
}

Therefore, if the current minute variable is different from the previous value, it means that a change in the value has occurred.
This way, the condition will be true and the value of the minute count will be increased (contMin) and the current value will be assigned to the variable previousMin, to store its previous value.

Therefore, when the value of this count is equal to 5, it means that 5 minutes have passed and the system must perform a new temperature reading and save the hour and temperature value in the SD Card log file.

if(contMin == 5)
{
   sprintf(times, "%02d:%02d ", DataTime[4], DataTime[5]);
        
   sensors.requestTemperatures();
   float TempSensor = sensors.getTempCByIndex(0);
 
   myFile.print(times);
   myFile.println(TempSensor);
   contMin = 0;
}

In this way, this process will be repeated until reaching the value of 5 hours of monitoring the patient's temperature with the temperature sensor with Arduino.

The code portion is shown below and is similar to the minute count, which was presented above.

//-----------------------------------------------------------Count Hours----------------------------------------------------------
      if(actualHour != previousHour)
      {
        contHour++;
        previousHour = actualHour;
      }
      
      if(contHour == 5)
      {
        myFile.close();
        lcd.clear();
        lcd.setCursor(5,0);
        lcd.print("Finished");
        lcd.setCursor(5,1);
        lcd.print("Process");
        measure_process = 0;
        contHour = 0;
      }

After reaching 5 hours of monitoring, the system will close the log file and present the message "Finished Process" to the user.

In addition, the user can press the Ok/Pause button in order to stop recording data. When this occurs, the following code block will be executed.

//----------------------------------------------Condition to stop the datalogger--------------------------------------------------
      if(ok == 1)
      {
        myFile.close();
        
        lcd.clear();
        lcd.setCursor(6,0);
        lcd.print("Stoped");
        lcd.setCursor(5,1);
        lcd.print("Process");
        
        measure_process = 0;
        delay(2000);

        lcd.clear();

        DS1307.getDate(DataTime);
        
        sprintf(times, "%02d:%02d", DataTime[4], DataTime[5]);
        
        lcd.setCursor(5,0);
        lcd.print(times);
        lcd.setCursor(0,1);
        lcd.print("1-M   2-H  3-O/P");
      }

9.jpg

Then, the system will close the file and present the message "Stoped Process", as shown in Figure 8.

10.jpg

After that, the system will print the time screen and menu options, as shown in Figure 9.

Accessing SD Card Module Data With Arduino

11.jpg

After the process of monitoring the JLCPCB Datalogger with the temperature sensor with Arduino, it is necessary to remove the memory card and access the data on the computer.

To view and analyze the data with better quality, export / copy all information of the text file to Excel.
After that, you can plot graphs and analyze the results obtained.

Conclusion

The JLCPCB Datalogger with a temperature sensor with Arduino allows us, in addition to measuring the temperature, to record information on the patient's temperature behavior over a period of time.

With these stored data, it is possible to analyze and understand how the temperature of the patient infected by COVID 19 behaves.

In addition, it is possible to evaluate the temperature level and associate its value with the application of some type of medication.

Therefore, through these data, the JLCPCB Datalogger with temperature sensor for Arduino aims to assist doctors and nurses in the study of patients' behavior.

Finally, we thank the company JLCPCB for supporting the development of the project and hope that you can use it.

All files can be downloaded and used freely by any user.