Getting Ready
The first step is to download the Arduino IDE software. The software is attainable at https://www.arduino.cc/en/software
After accepting the terms and conditions and confirming an email, the software is ready to use. If preferred, the web-editor can be used.
![](https://gbgdatalogger.ieeecbu.org/wp-content/uploads/2020/10/Screen-Shot-2021-02-22-at-9.55.48-PM-1024x460.png)
![](https://gbgdatalogger.ieeecbu.org/wp-content/uploads/2020/10/Screen-Shot-2021-02-22-at-10.01.23-PM-1024x506.png)
Next, it is required to download the DHT11 and DS3231 libraries. Once the libraries are downloaded, I included the libraries by going to the menu bar, sketch, include library, and add .ZIP library.
Sensor Testing
After downloading the DHT11 sensor library, I was able to run the code and gather/display the data (temperature, time, humidity, and heat index). The results should be similar as shown.
![](https://gbgdatalogger.ieeecbu.org/wp-content/uploads/2020/10/Screen-Shot-2021-02-23-at-7.22.26-PM.png)
Code
#include “DHT.h”
#define DHTPIN 7 //Digital pin connected to the DHT sensor
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE); //Initialize DHT sensor
void setup() {
Serial.begin(9600);
Serial.println(F(“Printing Data”));
dht.begin();
}
void loop() {
delay(2000); //waits 2 seconds between measurements
float h = dht.readHumidity(); //Read temperature as Celsius (the default)
float t = dht.readTemperature(); //Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);
// Check if any reads fail
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(F(“Failed to read from DHT sensor!”));
return;
}
float hif = dht.computeHeatIndex(f, h); //Compute heat index in Fahrenheit
float hic = dht.computeHeatIndex(t, h, false); //Compute heat index in Celsius (fahrenheit = false)
Serial.print(F(“Humidity: “));
Serial.print(h);
Serial.print(F(“% Temperature: “));
Serial.print(t);
Serial.print(F(“°C “));
Serial.print(f);
Serial.print(F(“°F Heat index: “));
Serial.print(hic);
Serial.print(F(“°C “));
Serial.print(hif);
Serial.println(F(“°F”));
}
Results: Web-Editor
![](https://gbgdatalogger.ieeecbu.org/wp-content/uploads/2020/10/Screen-Shot-2020-11-03-at-11.57.33-AM-572x1024.png)
Results: IDE
![Screen Shot 2021-02-23 at 7.32.23 PM Screen Shot 2021-02-23 at 7.32.23 PM](https://gbgdatalogger.ieeecbu.org/wp-content/uploads/elementor/thumbs/Screen-Shot-2021-02-23-at-7.32.23-PM-p3banp8g2c9tiw6se33vrenvf8ahknlrvjz137d408.png)
Logging Data to SD Card
This part of the code initializes the SD card and checks if the SD card is present.
![](https://gbgdatalogger.ieeecbu.org/wp-content/uploads/2020/10/Screen-Shot-2021-02-27-at-1.47.18-PM.png)
![](https://gbgdatalogger.ieeecbu.org/wp-content/uploads/2020/10/Picture1-1.png)
This code writes into the text file the date and time from the RTC, and the temperature and humidity from the DHT11 sensor.