DHT11 Sensor: Specifications
DHT11 Sensor: Specifications
DHT11 Sensor: Specifications
SPECIFICATIONS
ELECTRICAL CHARACTERISTICS
The saturation point changes with air temperature. Cold air can hold less water
vapor before it becomes saturated, and hot air can hold more water vapor before
it becomes saturated.
The formula to calculate relative humidity is:
WORKING
When MCU sends a start signal, DHT11 changes from the low-power-consumption
mode to the
running-mode, waiting for MCU to complete the start signal. Once it is completed,
DHT11 sends a
response signal of 40-bit data that include the relative humidity and temperature
information to
MCU. Users can opt to collect (read) and store some data. Without the start signal
from MCU, DHT11
will never give back the response signal to MCU. Once data is collected, DHT11
will change to the low power-consumption mode until it receives a start signal
from MCU again
When the cable connecting the MCU and DHT11 is shorter than 20 meters a 5K
pull-up resistor is recommended. One capacitor valued 100nF can be added
between VDD and GND for power filtering.
SKETCH
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT11
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
// Wait a few seconds between measurements.
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Humidity: ");
Serial.print(h);
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(f);
Serial.print("Heat index: ");
Serial.print(hif);
}
HC-SR04 Sensor
Ultrasonic sensor HC - SR04 provides 2cm -
400cm range of measurement. The modules consist of ultrasonic transmitters,
receiver and control circuit. The basic principle of work is as follows;
It emits an ultrasonic wave at 40 000 Hz which travels through the air and if there
is an object or obstacle on its path, it will bounce back to the module. Considering
the travel time and the speed of the sound, we can measure the distance. The HC-
SR04 Ultrasonic Module has 4 pins, Ground, VCC, Trig and Echo. The Ground and
the VCC pins of the module needs to be connected to the Ground and the 5 volts
pins on the Arduino Board respectively and the trig and echo pins are connected
to any Digital I/O pin on the Arduino Board. For example, if the object is 10 cm
away from the sensor, and the speed of the sound is 340 m/s or 0.034 cm/µs the
sound wave will need to travel about 294 u seconds. But we will get the double of
the value of that number because the sound wave needs to travel forward and
return backward. So in order to get the distance in cm, we need to multiply the
received travel time value from the echo pin by 0.034 and divide it by 2.
SKETCH
. #define trigPin 16
#define echoPin 17
int Buzzer = 18;
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(Buzzer, OUTPUT);
pinMode(echoPin, INPUT);
void loop() {
int distance, duration;
digitalWrite(trigPin, HIGH);
delayMicroseconds(2000);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin,HIGH);
distance = (duration/2) / 29.1;
if (distance >= 100 || distance <= 0){
digitalWrite(Buzzer, LOW);
}
else {
Serial.println("Motion detected");
tone(Buzzer, 400);
delay(100);
tone(Buzzer, 800);
delay(100);
tone(Buzzer, 400);
delay(100);
tone(Buzzer, 800);
delay(100);
tone(Buzzer, 400);
delay(100);
tone(Buzzer, 800);
delay(100);
}
delay(400);
}
4*4 Keypad Password Lock
Whenever the keys are pressed, they are matched with the keys already stored. If
the keys that are pressed match the initial password stored in the EEPROM which
is ‘1234’, then the lock will open up. If the password does not match, then it will
print “access denied” on the LCD.If the ‘#’ key will be pressed, it will ask you to
enter the current password and if it matches, then it will ask you to enter the new
password and the password will be changed.
First of all, we will include the libraries for the 4X4 keypad, LCD, and a library for
storing the password. The EEPROM library is used to store the password. The
default password stored in it is ‘1234’.The keys pressed are stored in the
‘password’ variable and these are shown on the LCD when the keys are pressed.
Then these keys will be matched with the initial password stored in the EEPROM.
If the keys that were pressed match the initial password, then the lock will get
open and “Pass accepted” will be printed on the LCD. If the password does not
match, then it will ask to enter the password again .If the ‘#’ key is pressed, then it
will call the ‘change()’ function. In the change function, it will ask you to enter the
current password. If the current password is correct, then it will ask you to enter
the new password. Upon entering the new password, the password will be
changed.
Sketch
#include <Keypad.h>
#include<LiquidCrystal.h>
#include<EEPROM.h>
#include "DHT.h"
#define DHTPIN 8
int trigPin=11;
int echoPin=12;
int dht_pin=8;
LiquidCrystal liquid_crystal_display(14,15,16,17,18,19,);
char password[4];
char saved_password[4];
int i=0;
char key_pressed=0;
char matrix[rows][columns] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
void setup()
dht.begin();
pinMode(dht_pin, INPUT);
pinMode(trigPin, OUTPUT);
pinMode(Buzzer, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(door_pin, OUTPUT);
liquid_crystal_display.begin(16,2);
liquid_crystal_display.setCursor(0,1);
delay(2000);
initialpassword();
}
void loop()
delay(1000)
digitalWrite(trigPin, HIGH);
delayMicroseconds(2000);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin,HIGH);
digitalWrite(Buzzer, LOW);
else {
liquid_crystal_display.clear();
liquid_crystal_display.print("Motion detected");
tone(Buzzer, 400);
delay(100);
tone(Buzzer, 800);
delay(100);
tone(Buzzer, 400);
delay(100);
tone(Buzzer, 800);
delay(100);
tone(Buzzer, 400);
delay(100);
tone(Buzzer, 800);
delay(100);
delay(400);
temphumidity();
delay(100);
digitalWrite(door_pin,LOW);
liquid_crystal_display.clear();
liquid_crystal_display.print("Enter Password");
liquid_crystal_display.setCursor(0,1);
key_pressed = keypad_key.getKey();
if(key_pressed=='#')
change();
if (key_pressed)
password[i++]=key_pressed;
liquid_crystal_display.print(key_pressed);
if(i==4)
delay(200);
for(int j=0;j<4;j++)
saved_password[j]=EEPROM.read(j);
if(!(strncmp(password, saved_password,4)))
liquid_crystal_display.clear();
liquid_crystal_display.print("CORRECT");
digitalWrite(door_pin, HIGH);
delay(1000);
liquid_crystal_display.setCursor(0,1);
liquid_crystal_display.print("Pres # to change");
delay(1000);
liquid_crystal_display.clear();
liquid_crystal_display.print("Enter Password:");
liquid_crystal_display.setCursor(0,1);
i=0;
else
digitalWrite(door_pin, LOW);
liquid_crystal_display.clear();
liquid_crystal_display.print("Wrong Password");
liquid_crystal_display.setCursor(0,1);
liquid_crystal_display.print("Pres # to Change");
delay(2000);
liquid_crystal_display.clear();
liquid_crystal_display.print("Enter Password");
liquid_crystal_display.setCursor(0,1);
i=0;
}
}
void change()
int j=0;
liquid_crystal_display.clear();
liquid_crystal_display.print("Current Password");
liquid_crystal_display.setCursor(0,1);
while(j<4)
char key=keypad_key.getKey();
if(key)
{
password[j++]=key;
liquid_crystal_display.print(key);
key=0;
delay(500);
liquid_crystal_display.clear();
liquid_crystal_display.print("Wrong Password");
delay(1000);
else
j=0;
liquid_crystal_display.clear();
liquid_crystal_display.setCursor(0,1);
while(j<4)
char key=keypad_key.getKey();
if(key)
saved_password[j]=key;
liquid_crystal_display.print(key);
EEPROM.write(j,key);
j++;
}
}
liquid_crystal_display.print("Pass Changed");
delay(1000);
liquid_crystal_display.clear();
liquid_crystal_display.print("Enter Password");
liquid_crystal_display.setCursor(0,1);
key_pressed=0;
void temphumidity(){
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
return;
liquid_crystal_display.clear();
liquid_crystal_display.print("Humidity,Temp= ");
liquid_crystal_display.print(h);
liquid_crystal_display.print(t);
liquid_crystal_display.setCursor(0,1);
delay(3000)
}
void initialpassword(){
for(int j=0;j<4;j++)
EEPROM.write(j, j+49);
for(int j=0;j<4;j++)
initial_password[j]=EEPROM.read(j);
2N2222
They are designed for high spee switching application at collector current up to
500mA, and feature useful current gain over a wide range of collector current,
low leakage currents and low saturation voltage.For the time being, arduino is the
Nano-technology with almost 40mA input or output current. This value of current
is enough to light a single LED but you may need to light several LEDs using a
single pin. For this purpose one may use a transistor as a switch while controlled
with arduino.Here the 2N2222 transistor is used which can endure upto 800mA
current and 40V voltage.
Here,it is being operate as “ON/OFF” type solid state switch by biasing the
transistors Base terminal v
1N4007
1N4007 is used as a “flywheel diode”, also known as a freewheeling diode, is
connected across the relay coil. This flywheel diode clamps the reverse voltage
across the coil to about 0.7V dissipating the stored energy and protecting the
switching transistor
1N5400 DIODE
TECHNICAL SPECIFICATIONS
Vr - Reverse Voltage: 50 V
If - Forward Current: 3A
Configuration: Single
Vf - Forward Voltage: 1V
Reverse Current: 10 uA
Recovery Time: -
We are using 1N5400 diode in power supply’s bridge rectifier because we our
current requitement is max 1.5A and it can support efficiently upto 3A.
CALCULATIONS
R(base)=(Vin-Vbe)/base current
I(base)=Ic/B
Filtering Capacitor