Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

Introduction to Data Logging with Arduino

Importance and Utility of Data Logging

Data logging is a crucial aspect of many engineering and scientific projects. It involves the collection and recording of data over a period of time, allowing for analysis and monitoring of various parameters. By using Arduino, an open-source microcontroller platform, data logging becomes more accessible and affordable for both professionals and hobbyists.

Data logging finds applications in a wide range of fields, including environmental monitoring, industrial automation, home automation, and scientific research. It enables us to track and analyze variables such as temperature, humidity, pressure, light intensity, and much more. With the ability to log data over extended periods, it becomes possible to identify trends, detect anomalies, and make informed decisions based on the collected information.

Project: Temperature and Humidity Data Logger

In this example project, we will create a temperature and humidity data logger using Arduino. The objective is to record temperature and humidity readings at regular intervals and store them for later analysis. This project can be used for monitoring environmental conditions in a room, greenhouse, or any other space where temperature and humidity are critical factors.

List of Components:

Examples:

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

#define DHTPIN 2
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);
File dataFile;

void setup() {
  Serial.begin(9600);
  dht.begin();

  if (!SD.begin(10)) {
    Serial.println("SD Card initialization failed!");
    return;
  }

  dataFile = SD.open("data.txt", FILE_WRITE);
  if (!dataFile) {
    Serial.println("Error opening data file!");
    return;
  }

  dataFile.println("Time,Temperature (C),Humidity (%)");
  dataFile.close();
}

void loop() {
  delay(2000);

  float temperature = dht.readTemperature();
  float humidity = dht.readHumidity();

  dataFile = SD.open("data.txt", FILE_WRITE);
  if (dataFile) {
    dataFile.print(millis());
    dataFile.print(",");
    dataFile.print(temperature);
    dataFile.print(",");
    dataFile.println(humidity);
    dataFile.close();
  }

  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.print(" °C, Humidity: ");
  Serial.print(humidity);
  Serial.println(" %");
}

In this example, we use the DHT11 temperature and humidity sensor to measure the environmental conditions. The data is then logged onto a microSD card using the MicroSD Card module. The code initializes the necessary libraries, opens the data file, and writes the sensor readings along with a timestamp. The data is appended to the file on each iteration of the loop.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.