Design of an IoT System for Gas Alarm and Explosion Prevention
Design of an IoT System for Gas Alarm and Explosion Prevention
HIGH at boot
no PWM or I2C
D0 GPIO16 no interrupt used to wake up from deep
support
sleep
HIGH at boot
D4 GPIO2 pulled up OK connected to on-board LED,
boot fails if pulled LOW
HIGH at boot
TX GPIO1 TX pin OK debug output at boot, boot fails
if pulled LOW
-Power block: Is the most basic block, it provides current to all components in the circuit. It
creates a stable voltage that satisfies voltage and current specifications.
-Central processing block: This is the central processing unit, whose task is to
• Read data from sensor block
• Data exchange communication with wifi block
• Output control signal to display block to display information
• Output signal to control alarm block for timely warning
-Wifi block: Connect to wifi and perform the following tasks
• Receive control signals on your phone and directly control peripheral devices
• Receive data from the central processing unit to send data to phone
-Sensor block: Includes
• Gas sensor to detect gas leaks and fire alarm
• Fire sensor to detect fire spots
Operating principle of the entire system
• Fire monitoring system: The system is based on a fire sensor and a gas sensor. These two
sensors collect data and send it to the central processing unit. If a fire is detected, the central
processing unit will control the siren to sound an alarm. At the same time, the central processing
unit sends a warning signal to the wifi unit and issues a warning on the App to the homeowner.
• Device control system: Controlling devices via the internet, sends control data to the wifi
block, upon receiving the data, the wifi block will control the corresponding devices to turn on
and off.
Solfware used:
Arduino IDE: The Arduino IDE supports programming the ESP8266 using the Arduino programming
language. You can use the ESP8266 Arduino core, which provides libraries and examples specifically
for the ESP8266.
Proteus: Used for circuit design.
void setup() {
Serial.begin(115200); // Khởi tạo giao tiếp Serial với tốc độ 115200 bps
pinMode(GasSensor, INPUT); // Đặt chế độ chân GasSensor là INPUT
pinMode(GreenLED, OUTPUT); // Đặt chế độ chân GreenLED là OUTPUT
pinMode(RedLED, OUTPUT); // Đặt chế độ chân RedLED là OUTPUT
pinMode(GreenLED1, OUTPUT); // Đặt chế độ chân GreenLED1 là OUTPUT
pinMode(RedLED1, OUTPUT); // Đặt chế độ chân RedLED1 là OUTPUT
pinMode(Buzzer, OUTPUT); // Đặt chế độ chân Buzzer là OUTPUT
}
void loop() {
int gasValue = analogRead(GasSensor); // Đọc giá trị cảm biến gas
int flameValue = digitalRead(flameSensor); // Đọc giá trị cảm biến lửa
Serial.print("Gas Value: "); // In giá trị gas lên Serial Monitor
Serial.println(gasValue);
Serial.print("Flame Value: "); // In giá trị lửa lên Serial Monitor
Serial.println(flameValue);
if (gasValue < 200) {
digitalWrite(GreenLED1, HIGH); // Bật đèn LED xanh thứ 2
digitalWrite(RedLED1, LOW); // Tắt đèn LED đỏ thứ 2
digitalWrite(Buzzer, LOW); // Tắt còi báo động
} else {
digitalWrite(GreenLED1, LOW); // Tắt đèn LED xanh thứ 2
digitalWrite(RedLED1, HIGH); // Bật đèn LED đỏ thứ 2
digitalWrite(Buzzer, HIGH); // Bật còi báo động
}
if (flameValue == 1) {
digitalWrite(GreenLED, HIGH); // Bật đèn LED xanh
digitalWrite(RedLED, LOW); // Tắt đèn LED đỏ
digitalWrite(Buzzer, LOW); // Tắt còi báo động
} else {
digitalWrite(GreenLED, LOW); // Tắt đèn LED xanh
digitalWrite(RedLED, HIGH); // Bật đèn LED đỏ
digitalWrite(Buzzer, HIGH); // Bật còi báo động
}
}