0

members

Medium Basics: Project 011e 5V relay, DHT 11 21 22 sensor, LCD1602 I2C module - Humidity or

of Acoptex.com in UNO

Basics: Project 011e

Project name: 5V relay, DHT 11 21 22 sensor, LCD1602 I2C module - Humidity or Temperature controlled relay

Tags: Arduino, Arduino Uno, DHT11 21 22, Humidity and temperature module, 5V relay, LCD 1602 I2C module, Humidity controlled relay, Temperature controlled relay,LCD 1602, LCD1602

Attachments: libraries1,  library2 and sketch

WARNING – THIS PROJECT INVOLVES HIGH VOLTAGES THAT CAN CAUSE SERIOUS INJURY OR DEATH. PLEASE TAKE ALL NECESSARY PRECAUTIONS, AND TURN OFF ALL POWER TO A CIRCUIT BEFORE WORKING ON IT. WE ARE NOT RESPONSIBLE FOR ANY DAMAGE, INJURY, DEATH AND OTHER THINGS CAUSED BY THIS PROJECT IMPLEMENTATION. 

In this project, you needed these parts :

1.Aruduino Uno R3 (you can also use the other version of Arduino)

2.5V Relay module 1 pc 

 

3.Arduino IDE ( you can download it from here  )

4.Jumper cables

5.Light bulb 60 W 220 V with connector 1pc

6.DHT11 or DHT21 or DHT22 - 1 pc

 

7.Resistor 1 KOm 1 pc

8. LCD 1602 I2C module

Understanding the Relay

You can read more about relay here.

You can find 5V relay module datasheet here.

Understanding DHT humidity and temperature sensor

You can read more about it here.

Datasheet can be found here.

Understanding LCD 1602 I2C module

You can read more about it here.

Signals and connections of DHT11 module

There are 3 : VCC (+5V), Data, GND (-)

Signals and connections of 5V Relay module nad LM35 sensor.

The SRD-05VDC-SL-C relay has three high voltage terminals (NC, C, and NO) which connect to the device you want to control. The other side has three low voltage pins (Ground, Vcc, and Signal) which connect to the Arduino.

5V Relay Pinout

NC: Normally closed 120-240V terminal
NO: Normally open 120-240V terminal
C: Common terminal
Ground: Connects to the ground pin on the Arduino
5V Vcc: Connects the Arduino’s 5V pin
Signal: Carries the trigger signal from the Arduino that activates the relay
Inside the relay is a 120-240V switch that’s connected to an electromagnet. When the relay receives a HIGH signal at the signal pin, the electromagnet becomes charged and moves the contacts of the switch open or closed.
NORMALLY OPEN VS. NORMALLY CLOSED
The relay has two different types of electrical contacts inside – normally open (NO) and normally closed (NC). The one you use will depend on whether you want the 5V signal to turn the switch on or turn the switch off. The 120-240V supply current enters the relay at the common (C) terminal in both configurations. To use the normally open contacts, use the NO terminal. To use the normally closed contacts, use the NC terminal.

The 5V Relay module has three high voltage terminals (NC, C, and NO) which connect to the device you want to control. The other side has three low voltage pins (GND (0V), VCC (+5V), and S(Signal)) which connect to the Arduino board.

  • NC: Normally closed 120-240V terminal
  • NO: Normally open 120-240V terminal
  • C: Common terminal

Signals and contacts of LCD 1602 I2C module

As you can see on the back of LCD 1602 module there 4 connections: GND (-), VCC (+5V), Serial Data Line (SDA) and Serial Clock Line (SCL).

Wiring

Let us build a HUMIDITY or TEMPERATURE controlled relay circuit that will turn on a light bulb when the humidity value of a DHT 11 sensor reaches 66% or temperature value reaches 25 degrees Celsius. DHT 11 OR 21 OR 22 sensors are really useful with 5V relays. You can use them to turn off a or turn on devices or power sockets depending on temperature or humidity values.

Make sure that the high voltage connections to the 5V relay module are very well secured.

Identify the hot power wire (red wire in the diagram above) in the cord leading to the light bulb and make a cut. Connect the side leading to the light bulb to the NO terminal of the 5V relay, and the side leading to the plug to the C terminal. This way the relay is on the hot side, and current is switched before it reaches the light bulb. It’s dangerous to put the relay on the neutral wire, since if the device fails current can still fault to ground when the relay is off.

The following picture shows the needed connections with the Arduino Uno 

or

Step by Step instruction

  1. Plug your Adruino Uno board into your PC and select the correct board and com port
  2. Open up serial monitor and set your baud to 9600 baud
  3. Verify and upload the the sketch to your Adruino Uno
  4. Comment or Delete the lines of code if you decide to use temperature or humidity values to activate the 5 V relay module: 

 if (h >= 66) { // you can change humidity value here - h>=66 to your preffered number

    digitalWrite(relayPin, HIGH);

  }

  else {

    digitalWrite(relayPin, LOW);

  }

OR

if (t >= 25) {// you can change temperature value here - t>= 25 to your preffered readings or Celsius or Fahrenheit readings

 digitalWrite(relayPin, HIGH);

 }

 else {

 digitalWrite(relayPin, LOW);

  }

Libraries:

  • See attachments on the begining of this project description
  • Adafruit_Sensor library included.Download, unzip  and add to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC. 
  • DHT-sensor library included. You will need to unzip and add the DHT-sensor-library-master library to libraries in your PC, for example C:\Users\toshiba\Documents\Arduino\libraries OR
  • You can install it in Arduino IDE too: select Sketch-> Include library->Manage your libraries->type DHT in Filter your search line and you will see DHT sensor library by Adafruit->More info->select version->install
  • If it will be problem with compilation - remove 2 files from the library - DHT_U.cpp and DHT_U.h.
  • We have used the library - NewliquidCrystal_1.3.4.zip which I downloaded, unzipped, changed the name of folder to LiquidCristal and added to libraries in my PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC.
  • If you have LiquidCristal folder in this location already - delete this folder and copy folder, which was made by you, to this location.
  • Wire library included in Arduino IDE which is installed in your PC.

Sketch:

  • See attachment on the begining of this project description.


Other projects of Acoptex.com
Easy Merry Xmas to everyone of Acoptex.com, Not selected 24-12-2019

« Go back to category
Is this project fake? Report it!   
Recommend to a friend
Published at 13-07-2017
Viewed: 2922 times