0% found this document useful (0 votes)
19 views7 pages

Lab 12 - Gas Sensor and BMP 180 Series Sensor Interface

The document outlines a lab exercise at Hamdard University focused on interfacing gas sensors, specifically the MQ series and BMP 180 sensor, with Arduino to detect gas concentrations and measure temperature and depth. It includes background information on the sensors, their working mechanisms, hardware setups, and sample code for implementation. The lab aims to enhance students' understanding of sensor operation and control through practical application.

Uploaded by

swathimoazzam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views7 pages

Lab 12 - Gas Sensor and BMP 180 Series Sensor Interface

The document outlines a lab exercise at Hamdard University focused on interfacing gas sensors, specifically the MQ series and BMP 180 sensor, with Arduino to detect gas concentrations and measure temperature and depth. It includes background information on the sensors, their working mechanisms, hardware setups, and sample code for implementation. The lab aims to enhance students' understanding of sensor operation and control through practical application.

Uploaded by

swathimoazzam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

Hamdard University, Karachi.

Lab No: 12
Introduction to Gas Sensor and BMP 180 series sensor Interface
OBJECTIVE:
To imitate the design to detect different gases whether hazardous or poisonous using MQ
Series sensor family and calculating pressure and depth of an object lying using Arduino.

BACKGROUND:
About MQ Series Sensors

There are quite a few different gas sensors you can use together with My Sensors. Detect
alcohol, methane (fart-sensor?), fire etc. We list a few in the buying guide below. The
example provided here uses the MQ2 sensor to detect air quality.

Figure 14.1: MQ-2 Sensor

Figure Connections with Arduino UNO

In below mentioned table the names of several sensors are mentioned with their specific
gas detections as given below:

Faculty of Engineering Sciences and Technology(FEST), Hamdard University


Shara-e-Madinat Al-Hikmah, Muhammad Bin Qasim Avenue, Karachi 74600, Pakistan.
FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY
Hamdard University, Karachi.

Table

How does it work?

The voltage that the sensor outputs changes accordingly to the smoke/gas level that
exists in the atmosphere. The sensor outputs a voltage that is proportional to the
concentration of smoke/gas.
In other words, the relationship between voltage and gas concentration is the
following:

 The greater the gas concentration, the greater the output voltage
 The lower the gas concentration, the lower the output voltage

Figure Working Mechanism


Faculty of Engineering Sciences and Technology(FEST), Hamdard University
Shara-e-Madinat Al-Hikmah, Muhammad Bin Qasim Avenue, Karachi 74600, Pakistan.
FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY
Hamdard University, Karachi.

Hardware Setup

Figure Hardware Setup

CODE
int redLed = 12;
int greenLed = 11;
int buzzer = 10;
int smokeA0 = A5;
// Your threshold value
int sensorThres = 400;

void setup() {
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(smokeA0, INPUT);
Serial.begin(9600);
}
void loop() {
int analogSensor = analogRead(smokeA0);

Faculty of Engineering Sciences and Technology(FEST), Hamdard University


Shara-e-Madinat Al-Hikmah, Muhammad Bin Qasim Avenue, Karachi 74600, Pakistan.
FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY
Hamdard University, Karachi.

Serial.print("Pin A0: ");


Serial.println(analogSensor);
// Checks if it has reached the threshold value
if (analogSensor > sensorThres)
{
digitalWrite(redLed, HIGH);
digitalWrite(greenLed, LOW);
tone(buzzer, 1000, 200);
}
else
{
digitalWrite(redLed, LOW);
digitalWrite(greenLed, HIGH);
noTone(buzzer);
}
delay(100);
}

BMP 180 Sensor:


The BMP180 is the next-generation of sensors from Bosch, and replaces the BMP085.
The good news is that it is completely identical to the BMP085 in terms of
firmware/software - you can use our BMP085 tutorial and any example code/libraries
as a drop-in replacement. The XCLR pin is not physically present on the BMP180 so if
you need to know that data is ready you will need to query the I2C bus. This board is 5V
compliant - a 3.3V regulator and a i2c level shifter circuit is included so you can use this
sensor safely with 5V logic and power. Using the sensor is easy. For example, if you're
using an Arduino, simply connect the VIN pin to the 5V voltage pin, GND to ground, SCL
to I2C Clock (Analog 5) and SDA to I2C Data (Analog 4). Then download our
BMP085/BMP180 Arduino library and example code for temperature, pressure and
altitude calculation. Install the library, and load the example sketch. Immediately you'll
have precision temperature, pressure and altitude data.

Figure BMP 180 Sensor

Faculty of Engineering Sciences and Technology(FEST), Hamdard University


Shara-e-Madinat Al-Hikmah, Muhammad Bin Qasim Avenue, Karachi 74600, Pakistan.
FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY
Hamdard University, Karachi.

Hardware Connections

Figure Hardware connections of BMP 180 with Arduino

Code:

#include <Wire.h>
#include <Adafruit_BMP085.h>

// Connect VCC of the BMP180 sensor to 3.3V


// Connect GND to Ground
// Connect SCL to i2c clock thats A5
// Connect SDA to i2c data thats A4

Adafruit_BMP085 bmp;

void setup()
{
Serial.begin(9600);
if (!bmp.begin())
{
Serial.println("BMP180 sensor not found");
while (1) {}

Faculty of Engineering Sciences and Technology(FEST), Hamdard University


Shara-e-Madinat Al-Hikmah, Muhammad Bin Qasim Avenue, Karachi 74600, Pakistan.
FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY
Hamdard University, Karachi.

}
}

void loop() {
Serial.print("Temperature = ");
Serial.print(bmp.readTemperature());
Serial.println(" *C");

Serial.print("Altitude = ");
Serial.print(bmp.readAltitude(101500));
Serial.println(" meters");

Serial.println();
delay(1000);
}

LAB TASK 1:
Make a small prototype by whom one may know the exact depth at which any object lie and
what is the temperature and actual depth over there. Along with this one may also interface
MQ2 sensor in order to detect the gas

Faculty of Engineering Sciences and Technology(FEST), Hamdard University


Shara-e-Madinat Al-Hikmah, Muhammad Bin Qasim Avenue, Karachi 74600, Pakistan.
FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY
Hamdard University, Karachi.

LEARNING OUTCOMES:
Upon successful completion of the lab, students will be able to:
LO1: Understand the basic working of different types sensors
LO2: Control the working pf sensors and runtime evaluation

Faculty of Engineering Sciences and Technology(FEST), Hamdard University


Shara-e-Madinat Al-Hikmah, Muhammad Bin Qasim Avenue, Karachi 74600, Pakistan.

You might also like