logo-mobile

ROHM

ROHM
Menu
  • Arduino –
  • Raspberry Pi –
  • Trending –
  • Others –
  • About –
  • Contact –

Arduino

Use an Arduino to find out when to turn on your humidifier

DevicePlus Editorial Team
Published by DevicePlus Editorial Team at July 12, 2022
Categories
  • Arduino
Tags
Humidifier

If you have a humidifier that doesn’t turn on or off automatically, you can build this functionality on your own with a simple Arduino humidity sensor. With a DHT11 temperature and humidity sensor, Arduino projects can detect moisture levels in the air, and respond accordingly to automatically turn devices on and off. This guide will show you how.

Table of Contents

  1. How Arduino Humidity Sensors Work
  2. What You’ll Need
  3. The Code
  4. The Wiring

Humidifier

How Arduino Humidity Sensors Work

Arduino humidity controller sensors work by measuring the relative humidity in the air. The relative humidity is calculated as the difference between the amount of water vapor in the air, versus the amount of water vapor needed for saturation. This is expressed as a percentage, ranging from 0-100%.

Internally, the sensor has two electrodes across a moisture-holding substrate. The two electrodes measure the electrical resistance between them to detect moisture levels in the air. As the substrate absorbs moisture in the air, the substrate becomes more conductive. The level of conductivity/resistance can then be converted into a usable humidity level by the sensor’s on-board IC.

Since this calculation is handled on the sensor itself, it only needs three pins: power, ground, and the sensor output pin. This is all you need to be able to detect both the humidity level as well as the temperature in the air, with the humidity sensor. Arduino projects can then perform actions based off that data, like turning on a humidifier, or running a fan.

For this project, we’ll be using the DHT11 temperature and humidity sensor. Arduino projects don’t inherently support the code we’ll be using, so we’ll be using this DHT library. Download the library .zip from this page and head to Sketch > Include library > Add .ZIP library and choose DHTLib.zip to make it available for the sketch we’ll be using.

What You’ll Need

To get started with this project, you’ll need a basic Arduino humidity sensor. There are several types out there, but for our purposes, we’ll be looking at the DHT11 model. Here’s the full list of what you’ll need to start building an Arduino temperature and humidity sensor:

DHT11 temperature and humidity sensor

DHT11 temperature and humidity sensor

Arduino Uno

Arduino Uno

Wires & breadboard

Wires & breadboard

USB cable

USB cable

Arduino IDE

Arduino IDE

One you have all the parts you’ll need, review the code in the next section before uploading it to your Arduino Uno. Then, head to the wiring section to learn how to put it all together.

The Code

Before you upload the sketch below, make sure you’ve added the DHTLib.zip library, as instructed above. Once that’s done, copy the code below into your Arduino IDE and upload it to your Arduino Uno.

C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include
 
dht DHT;
 
#define DHT11_PIN 2
 
void setup(){
  Serial.begin(9600);
}
 
void loop(){
  int chk = DHT.read11(DHT11_PIN);
  Serial.print("Temperature = ");
  Serial.println(DHT.temperature);
  Serial.print("Humidity = ");
  Serial.println(DHT.humidity);
  delay(2000);
}

Now, let’s review the important sections of this code, so you understand how it works.

C#
1
2
3
4
5
#include
 
dht DHT;
 
#define DHT11_PIN 2

The first line here instructs the Arduino IDE to include the DHT.h library you uploaded before. Without this line, the sketch won’t work. Next, we create a dht object named DHT to control the sensor, and define a variable to store the pin that the sensor is connected to.

C#
1
2
3
void setup(){
  Serial.begin(9600);
}

In the setup() section, we’ll start the Serial monitor so you can see the temperature and humidity values that the sensor will return.

C#
1
2
3
4
5
6
7
8
void loop(){
  int chk = DHT.read11(DHT11_PIN);
  Serial.print("Temperature = ");
  Serial.println(DHT.temperature);
  Serial.print("Humidity = ");
  Serial.println(DHT.humidity);
  delay(2000);
}

Finally, in the loop() section, we’ll create a chk variable to store the input from the sensor. In the next four lines, we’ll print the temperature and humidity values, as returned by the DHT object. The temperature will be returned in a Celsius value, while the humidity value will read as a number between 0 to 100, reflecting the relative humidity value currently in the air.

The final line in the loop will pause the sketch for two seconds. Anything shorter than this and the sketch can sometimes return erratic values.

The Wiring

WiringOnce your code is uploaded, you’re ready to connect the sensor to your Arduino project. To do so, follow these steps:

  • Connect the G pin on the sensor to GND on the Arduino Uno.
  • Connect the V pin on the sensor to 5V on the Arduino Uno.
  • Connect the S pin on the sensor to digital pin 2 on the Arduino Uno.

Now that everything is connected, you can turn your Arduino Uno on by connecting it via USB. Open the Serial monitor in your Arduino IDE by heading to Tools > Serial Monitor. Here, you’ll be able to see your updated temperature and humidity values every two seconds.

You can add on to this section by taking action based on these values. For example, you can try turning on a device like a humidifier or a fan using a relay when the humidity dips below a level you decide for too long. Just be sure to keep the relay on for a while, so the Arduino doesn’t end up turning your devices on and off rapidly if the humidity.

DevicePlus Editorial Team
DevicePlus Editorial Team

Check us out on Social Media

  • Facebook
  • Twitter

Recommended Posts

  • How to Find Out When Your Plants Need Watering with a Soil SensorHow to Find Out When Your Plants Need Watering with a Soil Sensor
  • How to control your computer using hand gesturesHow to control your computer using hand gestures
  • Display characters with LEDs! How to use a matrix LEDDisplay characters with LEDs! How to use a matrix LED
  • Using Sensors with the Arduino: Create a Simple Device to Detect Movement and ReactUsing Sensors with the Arduino: Create a Simple Device to Detect Movement and React
  • How to detect motion in your Arduino with an accelerometerHow to detect motion in your Arduino with an accelerometer
  • Top 6 DIY Projects You Can Do to Expand Your IoT ProjectsTop 6 DIY Projects You Can Do to Expand Your IoT Projects
Receive update on new postsPrivacy Policy

Recommended Tutorials

  • How to integrate an RFID module with Raspberry Pi How to integrate an RFID module with Raspberry Pi
  • How to Use the NRF24l01+ Module with Arduino How to Use the NRF24l01+ Module with Arduino
  • How to Run Arduino Sketches on Raspberry Pi How to Run Arduino Sketches on Raspberry Pi
  • Setting Up Raspberry Pi as a Home Media Server Setting Up Raspberry Pi as a Home Media Server

Recommended Trends

  • SewBot Is Revolutionizing the Clothing Manufacturing Industry SewBot Is Revolutionizing the Clothing Manufacturing Industry
  • All About The Sumo Robot Competition And Technology All About The Sumo Robot Competition And Technology
  • 5 Interesting Tips to Calculating the Forward Kinematics of a Robot 5 Interesting Tips to Calculating the Forward Kinematics of a Robot
  • Go Inside the Drones That Are Changing Food Delivery Go Inside the Drones That Are Changing Food Delivery
Menu
  • Arduino –
    Arduino Beginner’s Guide
  • Raspberry Pi –
    Raspberry Pi Beginner's Guide
  • Trending –
    Updates on New Technologies
  • Others –
    Interviews / Events / Others

Check us out on Social Media

  • Facebook
  • Twitter
  • About
  • Company
  • Privacy Policy
  • Terms of Service
  • Contact
  • Japanese
  • 简体中文
  • 繁體中文
Don’t Forget to Follow Us!
© Copyright 2016-2023. Device Plus - Powered by ROHM
© 2023 Device Plus. All Rights Reserved. Muffin group

istanbul escort istanbul escort istanbul escort