Lec 2 - Arduino Sensors Module

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 31

Real Time System Laboratory

Department of Computer Engineering

College of Engineering

Mosul University
Arduino
Arduino Sensors Module 1
Objectives
Study the characteristics and applications of
different photoelectric sensors:
• Humidity Sensor
• Flame Sensor
• Tracking Sensor
• Metal Touch Sensor
Humidity Sensor
• The DHT-11, DHT-22 Digital Temperature And
Humidity Sensor is a digital-output, relative
humidity, and temperature sensor. It uses a
capacitive humidity sensor and a thermistor to
measure the surrounding air, and sends a
digital signal on the data pin.
Humidity Sensor
Features
• Low power consumption.
• DHT11 sensor adopts
• The module can detect the surrounding
environment of the humidity and temperature
• High reliability and excellent long-term stability
• The output from the digital output
• Has fixed bolt hole and easy installation
Humidity Sensor
• Comparison between the two types of sensors
DHT-11 DHT-22
Temperature range Good from 0 to 50 ° Temperature range Good from -40 to
C with an accuracy 80 ° C with an
of ±2 ° C accuracy of ±0.5° C

Humidity Good for 20% to Humidity Good for 0% to


measurement range 80% humidity with measurement range 100% humidity with
5% accuracy 2% to 5% accuracy

Sampling rate 1 Hz (Once every Sampling rate 0.5 Hz (Once every


second) two seconds)
Energy 2.5 mA Maximum, Energy 2.5 mA Maximum,
consumption during data request consumption during data request
Experiments and Records
Humidity Sensor
Assumptions:
• Signal pin connected to Arduino pin number 2
• Vcc pin connected to 5 volt of Arduino board
• GND pin connected to the ground of Arduino board
• We need to connect 10k ohm resistor (pull up
resistor) between the DATA and the Vcc pin.
• See the temperature and humidity display on serial
port monitor which is updated every 2 seconds.
Experiments and Records
Circuit diagram
Experiments and Records
Circuit diagram
Experiments and Records
• #include "DHT.h"
• #define DHTPIN 2 // what digital pin we're connected to
• #define DHTTYPE DHT11
• DHT dht(DHTPIN, DHTTYPE);
• void setup() {
• Serial.begin(9600);
• Serial.println("DHTxx test!");
• dht.begin();
• }
• void loop() {
• delay(2000);
• float h = dht.readHumidity();
• float t = dht.readTemperature();
• Serial.print("Humidity: ");
• Serial.print(h);
• Serial.print(" %\t");
• Serial.print("Temperature: ");
• Serial.print(t);
• Serial.print(" *C ");
• }
Flame Sensor
This Flame Sensor Module is used to detect fire/flame source or other light sources of
the wavelength in the range of 760nm – 1100 nm. It is based on the YG1006
sensor which is a high speed and high sensitive NPN silicon phototransistor.
Due to its black epoxy, the sensor is sensitive to infrared radiation.
The sensor can be a great addition in a fire fighting robot, it can be used as a robot
eyes to find the fire source. When the sensor detects flame the Signal LED will light
up and the D0 pin goes LOW.
The module has 2 outputs: Analogue, which gives a real-time voltage output signal on
thermal resistance, and digital which allows temperature thresholds to be set via a
potentiometer
Flame Sensor

The output signal level changes with the The short lead of the infrared sensor is cathode,
brightness of the fire flame, which is then and the long lead is positive. The negative lead is
feed into the ADC of the MCU to be connected to 5V and the positive lead connect to
converted to a digital reading. the GND through a 10K ohm resistor. When the
intensity of infrared light changes, the resistance of
the sensor changes too, which then lead to the
change of voltage.
Flame Sensor
Features:
• High Photo Sensitivity
• Sensitivity adjustable
• Detects a flame or a light source of a wavelength in the range of 760nm-
1100 nm.
• Detection range: up to 100 cm.
• Adjustable detection range.
• Detection angle about 60 degrees, it is sensitive to the flame spectrum.
• Operating voltage 3.3V-5V.
• Digital and Analog Output.
Flame Sensor
There are two types of Flame Sensor:
1. DO digital switch outputs (0 and 1)

2. AO analog voltage output


Flame Sensor
Circuit diagram for analog sensor
Flame Sensor
Circuit diagram for analog and digital sensor
Experiments and Records
• int flame = 0;
• int buzzer=7;
• void setup() {
• // put your setup code here, to run once:
• pinMode(2 , INPUT);
• pinMode(buzzer , OUTPUT);
• }
• void loop() {
• // put your main code here, to run repeatedly:
• digitalWrite(buzzer,LOW);
• flame=digitalRead(2);
• delay(1000);
• while(flame==1)
• {
Experiments and Records
• digitalWrite(buzzer,HIGH);
• flame=digitalRead(2);
• }
• }
Tracking Sensor
Introduction:
A tracking sensor (as shown below) has the
same principle with an obstacle avoidance
sensor but has small transmitting power.
Tracking Sensor
Experimental Principle:
When the infrared transmitter emits rays to a
piece of paper, if the rays shine on a white
surface, they will be reflected and received by
the receiver, and pin S will output low level; If
the rays encounter black lines, they will be
absorbed, thus the receiver gets nothing, and
pin S will output high level.

20
Tracking Sensor
In this experiment, we will use an obstacle
avoidance sensor module and an LED attached
to pin 13 of the Arduino board to build a simple
circuit to make a tracking light.
Since an LED has been attached to pin 13,
connect the pin out to D8 of the Arduino board.
When the tracking sensor detects reflection
signals (white), the LED will be on. Otherwise, it
will be off (black line).

21
Experimental Procedures
Step 1: Build the circuit
S D8
- GND
+ 5V

Step 2: write a program to draw two black thick lines on


the paper. If the rays emitted by the sensor encounter the
black lines, the LED attached to pin 13 on Arduino board
will light up. Otherwise, it will go out.

22
Experimental Procedures

23
Experimental Procedures
const int tracingPin = 8;
const int ledPin = 13;void setup()
{
pinMode(tracingPin, INPUT);
pinMode(ledPin, OUTPUT);
}void loop()
{
int val = digitalRead(tracingPin);
if(val == HIGH)
{
digitalWrite(ledPin, HIGH);
}
else
{
digitalWrite(ledPin, LOW);
}
}

24
Metal Touch Sensor
Introduction:
A metal touch sensor is a type of switch that
only operates when it's touched by a charged
body. It has a high-frequency transistor which
can conduct electricity when receiving
electromagnetic signals.

25
Metal Touch Sensor

26
Metal Touch Sensor
Experimental Principle:

In this experiment, touch the base electrode of a


transistor with fingers to make it conduct electricity, for
human body itself is a kind of conductor and an antenna
that can receive electromagnetic waves in the air. These
electromagnetic wave signals collected by human body
are amplified by the transistor and processed by the
comparator on the module to output steady signals.

27
Experimental Procedures
the LED attached to pin 13 of Arduino, connect pin D0 of the sensor to D7 of the
Arduino board. When the metal touch sensor detects touch signals, the LED will be on.
Otherwise, it will be off.
Step 1: Build the circuit
AO A0
G GND
+ 5V
D0 D7

Step 2: write a program to touch the base electrode of the transistor and the LED
attached to pin 13 on the Arduino board will light up.

28
Experimental Procedues

29
Experimental Procedues
• int touch = 0;
• int motor=7;

• void setup() {
• // put your setup code here, to run once:
• pinMode(2 , INPUT);
• pinMode(motor , OUTPUT);
• Serial.begin(9600);

• }

• void loop() {
• // put your main code here, to run repeatedly:
• digitalWrite(motor,HIGH);
• touch =digitalRead(2);
• Serial.println(touch);

• while(touch==1)
• {
• digitalWrite(motor,LOW);

• }
• }

30
THANK YOU ANY QUESTION

You might also like