Temp and Humidity

The Temperature and Humidity Module is a valuable sensor that allows you to monitor environmental conditions in real-time. It combines a temperature sensor and a humidity sensor in a single module, making it ideal for climate control, weather stations, and indoor environment monitoring projects. In this step-by-step guide, we’ll show you how to set up the Temperature and Humidity Module with an Arduino and create projects that provide valuable insights into the surrounding atmosphere.

Materials Needed:

  1. Arduino board (e.g., Arduino Uno, Arduino Nano)
  2. Temperature and Humidity Module (e.g., DHT11 or DHT22)
  3. Resistor (10k ohms, for DHT22 module only)
  4. Breadboard and jumper wires
  5. USB cable for Arduino
  6. Computer with the Arduino IDE installed (https://www.arduino.cc/en/software)

Step 1: Wiring

Connect the Temperature and Humidity Module to the Arduino board as follows:

For DHT11 module:

  • Connect the module’s VCC (Voltage) pin to the 5V pin on the Arduino.
  • Connect the module’s GND (Ground) pin to the GND pin on the Arduino.
  • Connect the module’s OUT (Output) pin to a digital pin on the Arduino (e.g., D2).

For DHT22 module:

  • Connect the module’s VCC (Voltage) pin to the 5V pin on the Arduino.
  • Connect the module’s GND (Ground) pin to the GND pin on the Arduino.
  • Connect the module’s OUT (Output) pin to a digital pin on the Arduino (e.g., D2).
  • Place a 10k ohm resistor between the VCC pin on the module and the OUT pin on the module.

Step 2: Installing the Library

Before you proceed with the code, make sure you have installed the “DHT sensor library” for your Temperature and Humidity Module. To install the library, go to “Sketch” > “Include Library” > “Manage Libraries…” and search for “DHT sensor library” by Adafruit. Click “Install” to add the library to your Arduino IDE.

Step 3: Arduino Code

Open the Arduino IDE and create a new sketch. Then, enter the following code:

#include <DHT.h>

#define DHTPIN 2     // Digital pin connected to the DHT sensor (DHT11 or DHT22)
#define DHTTYPE DHT11   // Replace DHT11 with DHT22 if you are using the DHT22 module

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600); // Initialize serial communication for debugging (optional)
  dht.begin();
}

void loop() {
  delay(2000); // Wait for 2 seconds between readings
  
  float temperature = dht.readTemperature(); // Read the temperature in Celsius
  float humidity = dht.readHumidity(); // Read the humidity in percentage
  
  // Display the temperature and humidity on the Serial Monitor
  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.print(" °C, Humidity: ");
  Serial.print(humidity);
  Serial.println(" %");
}

Step 4: Uploading the code

Connect your Arduino board to the computer using the USB cable and select the appropriate board and port from the Arduino IDE. Then, click the “Upload” button to upload the code to the Arduino.

Step 5: Monitoring Temperature and Humidity

Once the code is uploaded successfully, open the Serial Monitor from the Arduino IDE (Ctrl + Shift + M). The Serial Monitor will display the temperature and humidity readings in Celsius and percentage, respectively, updating every 2 seconds.

Step 6: Experiment and Utilize

Now that the Temperature and Humidity Module is set up and providing readings, you can experiment with different environments and conditions to observe changes in temperature and humidity. Adjust the code to trigger actions or events based on specific temperature or humidity thresholds. For example, you can use the readings to control a fan or a humidifier in an indoor garden, or create a weather station that logs climate data over time.

Congratulations! You’ve successfully set up and used the Temperature and Humidity Module with Arduino. This versatile sensor allows you to monitor environmental conditions effectively, making it perfect for climate control and weather-related projects. Have fun experimenting and incorporating the Temperature and Humidity Module into your Arduino projects to gain insights into the surrounding atmosphere!

0 Comments

Leave a reply

Your email address will not be published. Required fields are marked *

*

or

Log in with your credentials

or    

Forgot your details?

or

Create Account