

A data logger is an electronic device designed to record data over time. It is commonly used for monitoring environmental conditions such as temperature, humidity, pressure, and other parameters. Data loggers are equipped with sensors to collect data and can either store the data internally or transmit it to a computer or cloud-based system for further analysis. These devices are widely used in industries such as agriculture, environmental science, logistics, and manufacturing.








Below are the general technical specifications for a typical data logger. Note that specific models may vary in their capabilities.
The pin configuration for a typical data logger module is as follows:
| Pin Name | Description |
|---|---|
| VCC | Power input (3.3V or 5V, depending on the module). |
| GND | Ground connection. |
| SDA | Serial Data Line for I2C communication. |
| SCL | Serial Clock Line for I2C communication. |
| TX | Transmit pin for UART communication. |
| RX | Receive pin for UART communication. |
| CS | Chip Select pin for SPI communication (used with SD card modules). |
| MOSI | Master Out Slave In pin for SPI communication. |
| MISO | Master In Slave Out pin for SPI communication. |
| SCK | Serial Clock pin for SPI communication. |
Below is an example of how to use a data logger with an SD card module to record temperature data from a DHT11 sensor.
#include <SD.h>
#include <DHT.h>
#define DHTPIN 2 // Pin connected to the DHT11 sensor
#define DHTTYPE DHT11 // Define the type of DHT sensor
#define CSPIN 10 // Chip Select pin for the SD card module
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
dht.begin();
// Initialize SD card
if (!SD.begin(CSPIN)) {
Serial.println("SD card initialization failed!");
return;
}
Serial.println("SD card initialized.");
}
void loop() {
// Read temperature and humidity
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
// Check if readings are valid
if (isnan(temperature) || isnan(humidity)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// Open file on SD card
File dataFile = SD.open("datalog.txt", FILE_WRITE);
// If the file is available, write data to it
if (dataFile) {
dataFile.print("Temperature: ");
dataFile.print(temperature);
dataFile.print(" °C, Humidity: ");
dataFile.print(humidity);
dataFile.println(" %");
dataFile.close(); // Close the file
Serial.println("Data logged.");
} else {
Serial.println("Error opening datalog.txt");
}
delay(2000); // Wait 2 seconds before next reading
}
SD Card Initialization Fails:
Sensor Readings Are NaN:
Data Not Saved to SD Card:
Inaccurate Sensor Readings: