Kamran
Published © CC BY-NC

Sensitivity test of DHT-11 and NTC thermistor

Testing 2 sensors sensitivity according to sharp temperature reduction. How long do sensors need to stabilize accurate temperature.

IntermediateShowcase (no instructions)2,566
Sensitivity test of DHT-11 and NTC thermistor

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
×1
Resistor 10k ohm
Resistor 10k ohm
According to thermistor I have to choose 10k Ohm
×1
Thermistor
NTC Thermistor from old laptop battery pack.
×1
MH SD Card Module
8 pin SD Card Module
×1

Story

Read more

Schematics

Data logger circuit with Thermistor and DHT11

Every second circuit collects the temperature from 2 sensors and saves it into the SD card. After collecting the data we will do data analyzing.

Code

Data logger code for 2 sensors

C/C++
Every second the code will save the temperature from 2 sensors into the SD card
/*
 *  Author: Kamran Rashidov
 *  Date: 11.26.2021
 *  
 */

// Code to collect the temperature from DHT11 and Thermistor


// include all necessary libraries
#include <SD.h>
#include <SPI.h>
#include<math.h> 
#include <dht.h>



#define dht_apin A2 // Analog Pin sensor is connected to
File myFile; // create a file object
int pinCS = 10; // Pin 10 on Arduino Uno - SD Card
int count = 0; // count the steps
dht DHT; // DHT temperature sensor
int g;



// Method to calculate and return the temperature for thermistor in celcius
double Thermister(int data)
  {
  double temp;
  temp=log(10000.0*((1024.0/data-1)));
  temp=1/(0.001129148+(0.000234125+(0.0000000876741*temp*temp))*temp);
  temp=temp-273.15;
  return temp;
  }




void setup() {
    
  Serial.begin(9600);
  pinMode(pinCS, OUTPUT);
  
  // SD Card Initialization
  if (SD.begin())
    {
      Serial.println("SD card is ready to use.");
    } 
    else
    {
      Serial.println("SD card initialization failed");
      return;
    }
    delay(5000);//Wait before accessing Sensor
  }



void loop() {
  
    DHT.read11(dht_apin);
    g=analogRead(A1);
    
    // Write to serial monitor
    Serial.print("Writing attempt No.: ");
    Serial.println(count);
    
    // Create/Open file 
    myFile = SD.open("collected_data.txt", FILE_WRITE);

  
  // if the file opened then, write to it:
  if (myFile) {

    // Write data to file
    myFile.print(count);
    myFile.print("_Thermistor_");
    myFile.print(Thermister(g));
    myFile.print("_C");
    myFile.print("_DHT11");
    myFile.print("_Temperature_");
    myFile.print(DHT.temperature); 
    myFile.print("_C_");
    myFile.print("Humidity_");
    myFile.print(DHT.humidity);
    myFile.print("_%");
    myFile.println();
    
    myFile.close(); // close the file
    Serial.println("Writing session is closed.");
  }
  
  count = count + 1;
    delay(1000); // every 1 sec
  
}

// Format of written data: 0_Thermistor_Temperature_21.91_Celcius_DHT11_Temperature_21.91_Celcius_Humidity_52.00_%

Python code for data visualization

Python
In order to run this code first you need import Excel file ("collected_data_.xlsx") into the folder.
# Kamran Rashidov
# 12.05.2021
# Matplotlib data visualisation from Thermistor and DHT11

from openpyxl import load_workbook
from matplotlib import pyplot as plt

wb = load_workbook("collected_data_.xlsx")  # excel file
ws = wb.get_sheet_by_name('Sheet1')  # Name of the sheet in the file

column_C = ws['C']  # Column C - data from thermistor
column_C_list = [column_C[x].value for x in range(len(column_C))]

column_G = ws['G']  # Column G - data from DHT11
column_G_list = [column_G[x].value for x in range(len(column_G))]

plt.plot(column_C_list, label="Thermistor", color="RED")
plt.plot(column_G_list, label="DHT-11", color="BLUE")

plt.xlabel("Time in Seconds")
plt.ylabel("Temperature in Celsius")
plt.title("Temperature comparison")
plt.legend()
plt.grid()
plt.tight_layout()
plt.show()

Credits

Kamran
0 projects • 0 followers

Comments