Arduino-Based Lung Cancer Detector with MQ-2, Sound Sensor, and DHT11
View and Edit Project In Cirkit Designer
Lung Cancer Detector Circuit Documentation
Summary
This document provides a detailed overview of the Lung Cancer Detector circuit. The circuit interfaces with various sensors to detect lung cancer indicators and displays the results on a 16x2 LCD. The components used include an Arduino UNO, MQ-2 Gas Sensor, Sound Sensor, DHT11 Temperature and Humidity Sensor, 16x2 LCD Display, Buzzer, Red LED, and a Rotary Potentiometer.
Component List
Arduino UNO
- Description: Microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
MQ-2 Gas Sensor
- Description: Gas sensor for detecting LPG, i-butane, propane, methane, alcohol, hydrogen, and smoke.
- Pins: GND, VCC, ANALOG, Digital
Sound Sensor
- Description: Sensor to detect sound levels.
- Pins: VCC, GND, DO, AO
DHT11 Temperature and Humidity Sensor
- Description: Sensor for measuring temperature and humidity.
- Pins: DATA, GND, VCC
16x2 LCD Display
- Description: Alphanumeric display module.
- Pins: VSS, VDD, V0, RS, RW, E, D1, D0, D2, D3, D4, D6, D5, D7, A, K
Buzzer
- Description: Audio signaling device.
- Pins: PIN, GND
LED: Two Pin (Red)
- Description: Light-emitting diode.
- Pins: cathode, anode
Rotary Potentiometer
- Description: Variable resistor.
- Pins: GND, OUT, VCC
Resistor
- Description: Fixed resistor.
- Pins: pin1, pin2
- Properties: Resistance: 200 Ohms
Wiring Details
Arduino UNO
GND connected to:
- 16x2 LCD (K, RW, VSS)
- DHT11 (GND)
- LED (cathode)
- Rotary Potentiometer (GND)
- Sound Sensor (GND)
- Buzzer (GND)
- MQ-2 (GND)
5V connected to:
- Rotary Potentiometer (VCC)
- DHT11 (VCC)
- Sound Sensor (VCC)
- MQ-2 (VCC)
- 16x2 LCD (VDD, A)
A0 connected to:
- MQ-2 (ANALOG)
D2 connected to:
- Sound Sensor (DO)
- 16x2 LCD (D7)
D3 connected to:
- DHT11 (DATA)
- 16x2 LCD (D6)
D4 connected to:
- Buzzer (PIN)
- 16x2 LCD (D5)
D5 connected to:
- Resistor (pin1)
- 16x2 LCD (D4)
D11 connected to:
- 16x2 LCD (E)
D12 connected to:
- 16x2 LCD (RS)
MQ-2 Gas Sensor
- GND connected to Arduino UNO (GND)
- VCC connected to Arduino UNO (5V)
- ANALOG connected to Arduino UNO (A0)
Sound Sensor
- GND connected to Arduino UNO (GND)
- VCC connected to Arduino UNO (5V)
- DO connected to Arduino UNO (D2)
DHT11 Temperature and Humidity Sensor
- DATA connected to Arduino UNO (D3)
- GND connected to Arduino UNO (GND)
- VCC connected to Arduino UNO (5V)
16x2 LCD Display
- VSS connected to Arduino UNO (GND)
- VDD connected to Arduino UNO (5V)
- V0 connected to Rotary Potentiometer (OUT)
- RS connected to Arduino UNO (D12)
- RW connected to Arduino UNO (GND)
- E connected to Arduino UNO (D11)
- D4 connected to Arduino UNO (D5)
- D5 connected to Arduino UNO (D4)
- D6 connected to Arduino UNO (D3)
- D7 connected to Arduino UNO (D2)
- A connected to Arduino UNO (5V)
- K connected to Arduino UNO (GND)
Buzzer
- PIN connected to Arduino UNO (D4)
- GND connected to Arduino UNO (GND)
LED: Two Pin (Red)
- cathode connected to Arduino UNO (GND)
- anode connected to Resistor (pin2)
Rotary Potentiometer
- GND connected to Arduino UNO (GND)
- OUT connected to 16x2 LCD (V0)
- VCC connected to Arduino UNO (5V)
Resistor
- pin1 connected to Arduino UNO (D5)
- pin2 connected to LED (anode)
Code Documentation
/*
* Lung Cancer Detector
* This Arduino sketch interfaces with various sensors to detect lung cancer.
* Components:
* - MQ-2 Gas Sensor
* - Sound Sensor
* - DHT11 Temperature and Humidity Sensor
* - 16x2 LCD Display
* - Buzzer
* - LED (Red)
*/
#include <LiquidCrystal.h>
#include <DHT.h>
// Pin definitions
const int mq2Pin = A0; // MQ-2 analog pin
const int soundSensorPin = 2; // Sound sensor digital pin
const int dhtPin = 3; // DHT11 data pin
const int buzzerPin = 4; // Buzzer pin
const int ledPin = 5; // LED pin
// Initialize the LCD library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// Initialize DHT sensor
#define DHTTYPE DHT11
DHT dht(dhtPin, DHTTYPE);
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Initialize the LCD
lcd.begin(16, 2);
lcd.print("Lung Cancer Det.");
// Initialize the DHT sensor
dht.begin();
// Set pin modes
pinMode(mq2Pin, INPUT);
pinMode(soundSensorPin, INPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
// Read MQ-2 sensor value
int mq2Value = analogRead(mq2Pin);
Serial.print("MQ-2 Value: ");
Serial.println(mq2Value);
// Read sound sensor value
int soundValue = digitalRead(soundSensorPin);
Serial.print("Sound Value: ");
Serial.println(soundValue);
// Read DHT11 sensor values
float h = dht.readHumidity();
float t = dht.readTemperature();
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" *C");
// Display values on LCD
lcd.setCursor(0, 1);
lcd.print("T:");
lcd.print(t);
lcd.print("C H:");
lcd.print(h);
lcd.print("%");
// Placeholder for lung cancer detection logic
// Add your detection logic here
// Example: if MQ-2 value exceeds threshold, activate buzzer and LED
if (mq2Value > 300) { // Example threshold
digitalWrite(buzzerPin, HIGH);
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(buzzerPin, LOW);
digitalWrite(ledPin, LOW);
}
delay(2000); // Wait for 2 seconds before next loop
}
This code initializes the sensors and LCD, reads sensor values, and displays them on the LCD. It also includes a placeholder for lung cancer detection logic, with an example of activating the buzzer and LED if the MQ-2 sensor value exceeds a threshold.