Arduino data logger using SD card and DHT11 sensor

Building a data logger using Arduino and SD card is so easy, this topic shows how to build a simple temperature and humidity data logger with DHT11 sensor.

The DHT11 sensor is used to sense the relative humidity and temperature and the SD card is used to save the values of the humidity and the temperature every 1 second. The values of the temperature and humidity are saved in .TXT file which is stored in the SD card.

Related projects:
Arduino and SD card interfacing example
Arduino and SD card example – Read and write files
Arduino interfacing with DHT11 sensor and LCD

Hardware Required:

  • Arduino board
  • DHT11 sensor
  • SD card
  • SD card socket (connector)
  • 10K ohm resistor
  • 4.7K ohm resistor
  • 3 x 3.3K ohm resistor
  • 3 x 2.2K ohm resistor
  • Breadboard
  • Jumper wires

Arduino data logger using SD card and DHT11 sensor circuit:
Arduino datalogger circuit diagrams are shown below, both circuits are well working.
The first circuit consists of three voltage dividers to step down the 5V into 3V, the voltage dividers are for: SS (chip select), MOSI (master in slave out) and SCK (serial clock) signals.

Arduino sd card dht11 data logger temperature and humidity

(All grounded terminals are connected together)

and the second circuit uses micro SD card module, this module is powered with 5V (comes from the Arduino board), it has AMS1117 voltage regulator and a voltage level converter (74LVC125A) which converts the 5V signals into 3.3V for lines: SS, MOSI and SCK:

Arduino sd card dht11 datalogger microsd card module

(All grounded terminals are connected together)

With the micro SD card module the connections are more simpler, the sd card module is supplied with 5V which comes from the Arduino board.
The SD card module has 6 pins which are (from left to right): GND, VCC, MISO, MOSI, SCK and CS (chip select).

Arduino data logger code:
The code below reads temperature and humidity from the DHT11 sensor, then it saves the data into the SD card within a file named DHT11Log.txt and finally it sends the same data serially to PC. The reading and storing of data is done every 1 second.

As a result, I powered my circuit and after few seconds I turned it OFF, I removed my 2 GB FAT16 SD card from the circuit and placed it in the PC, I opened my SD card with windows and I got the file shown below:

arduino sd card dht11 datalogger result

Arduino IDE serial monitor gave me the window shown below:

arduino sd card dht11 datalogger serial monitor

The video below shows a simulation of the Arduino datalogger using Proteus, I got the same result as the real hardware circuit:

Downloads:
Adafruit library for DHT series (after extracting put the folder named DHT in the library folder of Arduino):
Download

Proteus simulation file download:
Download
SD card image file download:
Download


Discover more from Simple Circuit

Subscribe to get the latest posts sent to your email.

3 thoughts on “Arduino data logger using SD card and DHT11 sensor”

  1. Hello sir:
    I’ve got the same problem.
    Which after the code type in,but the output of sensor are all 0%(both the temperature and humidity).
    As the above you said need add code into the program, which should it add in?
    And my sensor is use DHT22,have any different of Jumper wires connections?

    1. Check your Data pin on your DHT11, add this code in your loop function after reading the values:

      if (isnan(h) || isnan(t)) {
      Serial.println(F(“Failed to read from DHT sensor!”));
      return;
      }

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top