Arduino datalogger with SD card, DS3231 and DHT22 sensor

Last time I made a simple Arduino datalogger using SD card and DHT11 relative humidity and temperature sensor. Now I’m going to show how to build an Arduino datalogger that logs: date, time, temperature and humidity on an SD card.

In this project the DS3231 real time clock chip will be used to maintain the time as well as the date and the DHT22 sensor to detect the relative humidity and the temperature. Also, in the circuit there will be two pushbuttons to set up the time and date and a 20×4 LCD screen to display all parameters (time, date, temperature and humidity) as shown below:

arduino sd card datalogger ds3232 dht22

Related Projects:
Arduino data logger using SD card and DHT11 sensor
Arduino and DS3231 real time clock
Arduino with DHT22 sensor and LCD

Components Required:

  • Arduino board   —> ATmega328P datasheet
  • DS3231 board   —> DS3231 datasheet
  • DHT22 relative humidity and temperature sensor   —> datasheet
  • 20×4 (2004) LCD screen
  • SD card
  • SD card socket (connector)
  • 2 x push button
  • 2 x 10K ohm resistor
  • 4.7K ohm resistor
  • 3 x 3.3K ohm resistor
  • 3 x 2.2K ohm resistor
  • 330 ohm resistor
  • Breadboard
  • Jumper wires

Arduino data logger with SD card, DS3231 and DHT22 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 datalogger ds3232 dht22 sd card

(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 level shifter (74LVC125A) which converts the 5V signals into 3.3V for lines: SS, MOSI and SCK:

arduino datalogger ds3231 dht22 micro sd card adapter

(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).

In the circuit there are two push buttons: B1 and B2 connected to Arduino pins A1 and A2 respectively, these buttons are used to set the time and the date of the real time clock.

The DHT22 sensor has 4 pins: VCC, Data, NC (not connected) and GND. It powered with 5V (from the Arduino board).

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

Full arduino code is below.

As a result of my project, I got the log file (Logger.txt) shown below:

arduino datalogger dht22 sd card

Arduino IDE serial monitor result is shown below:

arduino datalogger dht22 serial monitor

The video below shows a simulation of the Arduino time, date, temperature and humidity 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.

11 thoughts on “Arduino datalogger with SD card, DS3231 and DHT22 sensor”

  1. Sir, Great Project and Easy to Implement, Want to how to Increase the logging interval (if want log temperature humidity every 10 min) what should be changed in C code. Please let us know. It Great help for us.
    thank you.

  2. Hi, I have got 2×16 LCD can I use this or I need to buy 20×4? What do I need to change in the code to use 2×16? Great project 🙂

    1. Simple Projects

      If you use 16×2 LCD then the 3rd and the 4th rows will not be printed, this means you’ll not be able to see temperature and humidity values.
      Otherwise, you’ve to do some modifications to the C code in order to print time, date, temperature & humidity values.

  3. mahamadou Mountaka oumarou Ibrahim

    please i have somme errors in my project : [MMC cmd] command unsupported and the compulation failed because the mmc has not been initialised. please help me

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