[AIoT] Early Fire Detection using AI
Pico project that provides a quick alarm response to the people in the particular zone when a fire source or flame is detected.
PIEZO BUZZER - MCKPT-G1210-3916.
Python - Python
One of the most common man made disaster is by fire. The project focuses on implementation in petrol pumps, and other fire zone and fire restricted areas. Today, we'll look at an unusual Pico project that provides a quick alarm response to the people in the particular zone when a fire source or flame is detected. The Advantage on real time applications is, it provides quick response before a smoke spread due to fire Whenever a fire/flame is detected it sends quick response to the peoples in the zone.
- Jumper wires
- Wiznet Pico board
- LED Bulb
- 330k Resistor
- 16*2 LCD Display
- I2C Module
- Yolov5 Object detection
- Arduino IDE
- Google Colaboratory
- PyCharm - Python IDE
LED: Consist of 2 pins, positive pin which is connected to 330K resistor and GP13. and negative pin is connected to GND (ground).BUZZER: Consist of 2 pins in which positive pin is connected to GP14. Negative pin is connected to GND. 16*2 LCD Display with I2C Module: Consist of 4 pins. VCC, GND, SDA, SCL. VCC connected to 5V. SDA pin connected to GP4. SCL pin connected to GP5. GND can be connected to any GND of pico board.
In this project, we have used the YOLOV5 object detection model on a custom trained datasets which could detect when a flame or fire source is found. Training is done by various fire sources such as lamps, lighters and matchsticks. The annotation is done with the collected real time flames and fire sources. Then feed it to the training algorithm. Ensure that the present working directory is the YOLOV5 directory and all dependencies are installed. The coco128.yaml file has to be updated with the datasets directory and also the classes used. Train using the command:
!python train.py --img 416 --batch 16 --epochs 100 --data coco128.yaml --weights yolov5s.pt --cache
A pertained weight has been assigned to the training [yolov5s.pt] and is running at 100 epochs. Once the training is done check in the “runs” folder to check the accuracy of predictions in the.jpg files. The real time detection can be used with the command:
python test.py --weights best.pt --img 416 --conf 0.28 --source 1
While running this command the present working directory should be the root of the yolov5 folder. The weight file ending in “.pt” file has to be given in the - -weight argument. The source can be set to 1 or 0 depending on the webcam used as internal or external. On running this command a frame opens up with bounding box detection. Through serial communication it sends the data and displays the status in LCD display, These status messages include “Fire detected”, when a flame or fire source is found using camera, in case no fire/flame are detected “No fire detected” command. On receiving the status via serial communication to raspberry pico, we check for keywords matching. A global variable is assigned for each status and this status will be displayed in the LCD display as well as the Serial Monitor.
Liquidcrystal_I2C library has to be added to the arduino sketch. Line [2 - 3] contains the libraries required for LCD display which is wire.h and Liquidcrystal_I2C.h. Line [7 - 10] Initializing variables for led, buzzer and a global variable data. Line [12 - 20] void setup contains pinMode of led and buzzer. Setting led and buzzer voltage level to low. Line  void loop starts. Line [25 - 28] while loop to read the data through serial connection. Line [31 - 44 ] if condition with data = h, where h is a keyword passed through serial communication. If the data read is “h” then the buzzer and led gets activated to indicate the fire detected. In LCD display “Fire detected ” message been printed. Line [46 - 59] else condition when there is “No fire” detected. when no fire is detected led and buzzer voltage level will be low.
Early Fire Detection