Project tutorial
Temperature and Humidity Data Logger

Temperature and Humidity Data Logger © GPL3+

This project shows you how to measure Temperature and Humidity and record data on an SD-Card with an Arduino Uno and an Ethernet Shield.

  • 26,893 views
  • 2 comments
  • 25 respects

Components and supplies

Apps and online services

About this project

What this project is about

I have been experimenting with Arduino Microcontroller for a few weeks now and only built simple circuits with LED's and stuff. I wanted to build my first projects that can be useful to do something and I decided to build a data logger for temperature and humidity. Although this is a fairly straight forward circuit the code can be quite tricky (for someone on my level. Lol).

How we did it

The first step is to assemble your Arduino Uno and the Ethernet Shield and build the following circuit with your components as shown below.

Once the circuit is finished, make sure the SD-card is formatted and inserted on the Ethernet shield.

You can now upload the code shown below to you. Arduino and the sensor will start measuring the temperature and humidity. The Arduino will create a DATALOGGER.TXT file on the SD-card. Once the power is disconnected the datalogger will stop and continue again once the power is restored.

Should the measuring be longer that 1 or 2 hours, I would suggest using a permanent power source like a "wall wart" to make sure the battery does not drain and you lose critical data.

Code

Temp_and_Humid.inoArduino
Use the SD card data logger in the Arduino IDE examples and add the code for the DHT11 sensor as shown in the code below. The SD-card example allows you to log data from up to 3 sensors. Make sure you change line 57 middle segment from analogPin < 3 to analogPin < 1.
/*
  SD card datalogger

 This example shows how to log data from three analog sensors
 to an SD card using the SD library.

 The circuit:
 * analog sensors on analog ins 0, 1, and 2
 * SD card attached to SPI bus as follows:
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS - pin 4

 created  24 Nov 2010
 modified 9 Apr 2012
 by Tom Igoe

 This example code is in the public domain.

 */

#include <SPI.h>
#include <SD.h>
#include <dht.h>

dht DHT;

#define DHT11_PIN A0

const int chipSelect = 4;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.print("Initializing SD card...");

  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    return;
  }
  Serial.println("card initialized.");
}

void loop() {
  // make a string for assembling the data to log:
  String dataString = "";

  // read three sensors and append to the string:
  for (int analogPin = 0; analogPin < 1; analogPin++) {
    int chk = DHT.read11(DHT11_PIN);
    dataString += String(chk);
    if (analogPin < 2) {
      dataString += ",";
    }
  }

  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  File dataFile = SD.open("datalog.txt", FILE_WRITE);

  // if the file is available, write to it:
  if (dataFile) {
    dataFile.println(DHT.temperature);
    dataFile.println(DHT.humidity);
    dataFile.close();
    // print to the serial port too:
    Serial.print("Temperature = ");
  Serial.println(DHT.temperature);
  Serial.print("Humidity = ");
  Serial.println(DHT.humidity);
  delay(600000);
  }
  // if the file isn't open, pop up an error:
  else {
    Serial.println("error opening datalog.txt");
  }
}

Schematics

The SD-Card must be inserted in the slot.
Eop5d3wvnjt1p8iozjs8
The final product
V6lcqeyvxjidumgrc2sr

Comments

Similar projects you might like

Temperature and Humidity Data logger - Breadboard

Project tutorial by Jed Hodson

  • 7,589 views
  • 2 comments
  • 9 respects

Temperature and Humidity Logger (Using Arduino)

Project showcase by lmsousa

  • 7,770 views
  • 3 comments
  • 34 respects

SD Card Temperature Data Logger

Project tutorial by 3 developers

  • 8,978 views
  • 0 comments
  • 9 respects

Date, Time, Temperature and Humidity Display

Project tutorial by Chamath Vithanawasam

  • 14,821 views
  • 8 comments
  • 29 respects

Arduino Temperature - Humidity - Rain Sensor

Project showcase by Rick_Findus

  • 7,412 views
  • 6 comments
  • 13 respects

Flashing LED Light and Temperature Data Logger

Project tutorial by

  • 5,108 views
  • 2 comments
  • 9 respects
Add projectSign up / Login