Arduino Sensor Data Collection Examples

Explore practical examples of programming an Arduino for sensor data collection in your science fair project.
By Taylor

Introduction to Arduino Sensor Data Collection

Programming an Arduino for sensor data collection is a fantastic way to dive into the world of electronics and programming. Arduino boards are versatile and user-friendly, making them a great choice for beginners and experienced hobbyists alike. In this guide, we’ll explore three diverse examples that will help you understand how to collect and utilize sensor data effectively. Let’s get started!

Example 1: Temperature and Humidity Monitoring System

This project involves using a DHT11 sensor to collect temperature and humidity data. It’s perfect for understanding environmental conditions.

In this example, you will set up a DHT11 sensor with your Arduino to continuously monitor the temperature and humidity levels in your room. This can be useful for various applications, such as climate control or agricultural monitoring.

Here’s how to do it:

  1. Components Required:

    • Arduino Uno
    • DHT11 Temperature and Humidity Sensor
    • Jumper Wires
    • Breadboard (optional)
  2. Wiring:

    • Connect the DHT11 sensor’s VCC pin to the 5V pin on the Arduino.
    • Connect the GND pin to a GND pin on the Arduino.
    • Connect the DATA pin to digital pin 2 on the Arduino.
  3. Code:

    #include <DHT.h>
    #define DHTPIN 2
    #define DHTTYPE DHT11
    
    DHT dht(DHTPIN, DHTTYPE);
    
    void setup() {
      Serial.begin(9600);
      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(" %   ");
      Serial.print("Temperature: ");
      Serial.print(t);
      Serial.println(" *C");
    }
    
  4. Notes:

    • You can modify the code to log data to an SD card or display it on an LCD.
    • Try using other temperature sensors like the DHT22 for more accuracy.

Example 2: Light Intensity Measurement with a Photoresistor

In this project, you will use a photoresistor to measure light intensity. This is ideal for understanding how light affects different environments or activities.

The goal is to measure the ambient light levels in your surroundings and display the values on the serial monitor. This can be useful in projects related to photography, gardening, or indoor lighting design.

Here’s how to set it up:

  1. Components Required:

    • Arduino Uno
    • Photoresistor (LDR)
    • 10k Ohm Resistor
    • Jumper Wires
    • Breadboard (optional)
  2. Wiring:

    • Connect one terminal of the photoresistor to the 5V pin.
    • Connect the other terminal to an analog pin (A0) and one terminal of the 10k resistor.
    • Connect the other terminal of the resistor to GND.
  3. Code:

    void setup() {
      Serial.begin(9600);
    }
    
    void loop() {
      int sensorValue = analogRead(A0);
      Serial.print("Light Intensity: ");
      Serial.println(sensorValue);
      delay(1000);
    }
    
  4. Notes:

    • You can plot the light intensity data over time to analyze patterns.
    • Experiment with different light sources to see how the readings change.

Example 3: Soil Moisture Monitoring System

This project uses a soil moisture sensor to monitor the moisture levels in your garden. It’s perfect for promoting efficient gardening practices.

The goal is to collect data on soil moisture and potentially automate watering systems based on the moisture levels, ensuring your plants stay healthy without overwatering.

Here’s how to implement this:

  1. Components Required:

    • Arduino Uno
    • Soil Moisture Sensor
    • Jumper Wires
    • Breadboard (optional)
  2. Wiring:

    • Connect the VCC pin of the soil moisture sensor to the 5V pin on the Arduino.
    • Connect the GND pin to a GND pin on the Arduino.
    • Connect the output pin to an analog pin (A0) on the Arduino.
  3. Code:

    void setup() {
      Serial.begin(9600);
    }
    
    void loop() {
      int moistureValue = analogRead(A0);
      Serial.print("Soil Moisture Level: ");
      Serial.println(moistureValue);
      delay(2000);
    }
    
  4. Notes:

    • You can set thresholds in your code to trigger a water pump if moisture is low.
    • Consider using a waterproof sensor for outdoor use.

These three examples of programming an Arduino for sensor data collection illustrate the versatility and practicality of using Arduino in real-world applications. Whether it’s monitoring environmental conditions, light intensity, or soil moisture, Arduino provides a hands-on way to learn about data collection and analysis. Happy tinkering!