I want to control two devices:

  1. AC
  2. Humidifier

I have a DHT11 sensor for temperature and humidity. I want the AC to turn on when the temperature is greater than 30°C, and off when it's less than 20°C. Same for the humidifier: on (humidity < 50 ) and off (humidity > 90 ).

It's not necessary for both to operate at the same time, i.e first check for AC then humidifier.

I want to do this task using a single Arduino Uno.


Connect both of your appliances i.e AC and Humidifier to 2 different relays. Connect the relays to the Arduino Uno digital I/O pin using a small current amplifier circuit or a Darlington Transistor pair that will amplify the current going to the relay. enter image description here

Relay circuit

enter image description here

Darlington Pair

Now the connection of your sensor with arduino.enter image description here

In your code you have to use DHT library i.e.

#include <dht11.h>

define your DHT11 object as

dht11 DHT11;    //(class object;)

define your DHT11 sensor pin like this


You can the similar code to control your relay according to the temperature and humidity here. Simply first check the AC temperature and switch on/off the AC relay and then check the Humidifier humidity and switch on/off the humidifier relay.

*** Connect your sensor output to the Digital Pin of the Arduino


You should use two relays to operate the two devices. You would have been able to use one relay, if you would have one device ON or OFF by default.

For the relays use separate I/O pins declared as OUTPUT and have some circuitry for Arduino output current to be amplified, before the relays and after the I/O pins.

  • Now, I understood how to use 2 channel relay using below link, but I am confused where to attach DHT11 signal? : osoyoo.com/2017/07/31/arduino-lesson-2-channel-relay-module – Jatin Patel Jun 21 '18 at 10:22
  • As you know , the DHT11 has generally 3 pins Vcc, Gnd & signal. Attach the DHT11 signal pin to any vacant digital pin e.g. pin 7 on arduino and read the temperature or humidity using DHT library made for arduino which is available online. You can contact me on my mail id- alokapatro999@gmail.com. – Aloka Jun 21 '18 at 13:36
  • Have u done ur work? – Aloka Jul 1 '18 at 18:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.