how to make a temperature logger

How to Create a Temperature Logger: A Step-by-Step Guide

By William Jones
AD

Ever wondered how to record and monitor temperature data remotely or automatically? A temperature logger, also known as a data logger, is a device that captures and stores temperature readings at set intervals. It's an essential tool in various industries, from agriculture to manufacturing, and even in your home's temperature control systems. This guide will walk you through the process of making a temperature logger using a simple microcontroller and a temperature sensor.

Before we dive in, let's briefly touch upon the key components you'll need for this project: an Arduino board (like the Arduino Uno), a DHT11 or DHT22 temperature and humidity sensor, a breadboard and jumper wires, a power source (like a USB charger), an SD card (for data logging), and a few other accessories like an LED and a resistor. With these components, you'll be ready to create your very own temperature logger.

Setting Up Your Arduino Board

The Arduino Uno is our microcontroller of choice for this project due to its simplicity, extensive library support, and wide community base. First, you'll need to install the Arduino IDE on your computer. This will allow you to write and upload your code to the Arduino board. Once the IDE is installed, connect your Arduino board to your computer using a USB cable. The IDE should recognize the board automatically.

AD
Arduino Temperature Logger Project - Tutorial45
Arduino Temperature Logger Project - Tutorial45
Quick & Easy Temperature Loggers
Quick & Easy Temperature Loggers
Log Temperature, Humidity, and Heat Data with Arduino to an SD Card
Log Temperature, Humidity, and Heat Data with Arduino to an SD Card

To verify that your board is working properly, let's upload a simple blink sketch. This will ensure that your board is communicating with the IDE and that the onboard LED is functioning correctly. After uploading the blink sketch, you should see the LED on the board blinking every second.

Wiring Your Temperature Sensor

The DHT11 and DHT22 sensors are simple and widely used temperature sensors that also measure humidity. They have four pins: VCC, GND, Data, and NO CONNECTION. For our project, we'll only use VCC, GND, and Data. Connect your sensor as follows:

ESP8266 Wifi Temperature Logger
ESP8266 Wifi Temperature Logger
Arduino Temperature Logger Project - Tutorial45
Arduino Temperature Logger Project - Tutorial45
DIY ESP32 Temperature, Humidity, and Dew Point Data Logger – Step-by-Step Guide
DIY ESP32 Temperature, Humidity, and Dew Point Data Logger – Step-by-Step Guide
  1. VCC to 5V on the Arduino board
  2. GND to GND on the Arduino board
  3. Data to Digital Pin 2 on the Arduino board

Remember that these sensors are moisture-sensitive, so keep them away from liquids and excessive heat. Also, ensure you install the DHT library in the Arduino IDE to interact with the sensor effectively.

Sensing Temperature

To read temperature data from your sensor, include the DHT library in your sketch and initialize the sensor. Here's a simple code snippet to read temperature data:

AD
#include <DHT.h> #define DHTPIN 2 #define DHTTYPE DHT11 DHT dht(DHTPIN, DHTTYPE); void setup() { dht.begin(); } void loop() { delay(2000); float h = dht.readHumidity(); float t = dht.readTemperature(); if (isnan(h) || isnan(t)) { Serial.println("Failed to read from DHT sensor!"); return; } Serial.print("Humidity: "); Serial.print(h); Serial.print(" %\t"); Serial.print("Temperature: "); Serial.print(t); Serial.println(" °C "); }

Upload this code to your Arduino board. Upon running, it should display temperature readings in Celsius.

Arduino Temperature Logger Project - Tutorial45
Arduino Temperature Logger Project - Tutorial45
an electronic device sitting on top of a wooden table next to a capacitor
an electronic device sitting on top of a wooden table next to a capacitor
ESP8266-01 Temperature Logger With Multiple Inputs
ESP8266-01 Temperature Logger With Multiple Inputs
Tiny ESP8266 Temperature Logger (Google Sheets)
Tiny ESP8266 Temperature Logger (Google Sheets)
Raspberry Pi: DHT11/DHT22 Temperature and Humidity Data Logger (Python) | Random Nerd Tutorials
Raspberry Pi: DHT11/DHT22 Temperature and Humidity Data Logger (Python) | Random Nerd Tutorials
Single Chip Temperature Data Logger - Electronics-Lab
Single Chip Temperature Data Logger - Electronics-Lab

Logging Data to SD Card

To store data locally, we'll use an SD card breakout board that connects directly to the Arduino board. First, wire the SD card to your Arduino board:

  1. CS to Digital Pin 4
  2. MOSI to Digital Pin 11
  3. MISO to Digital Pin 12
  4. CLK to Digital Pin 13
  5. VCC to 3.3V
  6. GND to GND

Next, install the SD library in the Arduino IDE and include it in your sketch. Initialize the SD card and open a file for writing:

AD
#include <SD.h> File dataFile; void setup() { if (!SD.begin(4)) { Serial.println("Card failed, or not present"); while (1); } dataFile = SD.open("datalog.txt", FILE_WRITE); if (!dataFile) { Serial.println("error opening datalog.txt"); while (1); } }

Now, you can write data to the SD card using the print() function with the file object as the argument.

Raspberry Pi with BME280: Temperature, Humidity, and Pressure Data Logger | Random Nerd Tutorials
Raspberry Pi with BME280: Temperature, Humidity, and Pressure Data Logger | Random Nerd Tutorials
chipKIT Project 2: Temperature and relative humidity logger
chipKIT Project 2: Temperature and relative humidity logger
Real Time Temperature Logging With Arduino, NodeJS and Plotly!
Real Time Temperature Logging With Arduino, NodeJS and Plotly!

Building the Enclosure

To protect your temperature logger from dust, moisture, and other environmental hazards, build an enclosure using a plastic or acrylic box and a plastic lid. Use screws to assemble the box, and add a small fan to ensure proper ventilation inside the enclosure. Drill holes in the lid to accommodate the temperature sensor and any display or LED indication.

Mounting Components

Mount your Arduino board, sensor, and SD card to the inside of the enclosure using double-sided tape, screws, or a custom 3D-printed bracket. Ensure the sensor is pointed outward through the drilled hole in the lid.

AD

Once everything is securely mounted, connect your temperature logger to a USB charger or a battery pack, and you're ready to start logging temperatures!

With your newly built temperature logger, you can now monitor and record temperature data effortlessly. Whether it's for your home, office, or industrial use, this versatile device will serve you well. Happy tinkering, and don't forget to share your unique projects with the community!

AD