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

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/352208163

FINAL YEAR PROJECT REPORT Smart Fire Alarm System and Device Smart Fire
Alarm Device and System Final Year Report of Alekhaya Datta

Technical Report · February 2021


DOI: 10.13140/RG.2.2.24225.94567

CITATIONS READS

0 744

1 author:

Alekhaya Datta
Management Development Institute of Singapore
2 PUBLICATIONS 0 CITATIONS

SEE PROFILE

All content following this page was uploaded by Alekhaya Datta on 08 June 2021.

The user has requested enhancement of the downloaded file.


Module Lecturer: Dr. Tan Kim Piew
Project Supervisor: Dr. Lum Kum
Meng
Name: Alekhaya Datta
Batch: BNED11801A
Student Id: SIDI1707048850
Submission Date: 18th January 2021

FINAL YEAR PROJECT


REPORT
Smart Fire Alarm System and Device
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 1

I. ABSTRACT
In recent times we have seen a lot of accidents related to fire, like burning of houses and
electronic devices. Although this problem cannot be completely stopped, but the severity of
damage can be reduced which will potentially save lives through a smart-fire alarm system and
device.

The system will alert the user of any presence of fire via sound alarm. In addition, if the user
is not present in the vicinity of the fire, then a notification will be sent instantly through push-
notifications in the user’s mobile device. In addition to that a mobile application will be
developed from scratch which will be capable of showing data to the user from the Smart Fire
Alarm Device .The device will also have live-streaming video capabilities. This is an extra
feature which will allow rescuers to view the vicinity in case of Fire.

The aim for this project is to create a Smart Fire Alarm Device and design a system which
capable of having the above feature and moreover the device should be small in terms of size.
and the system should be inexpensive in terms of cost

II. ACKNOWLEDGEMENT

Foremost, I would like to thank Teesside University and Management Development Institute
of Singapore for putting Final Year Project in their course curriculum. Final Year Project
helped me gain knowledge on new things, new technology and new business ideas which I
might not have gained without the exposure of the Final Year Project.
I would like to express my sincere gratitude to my supervisor Prof. Dr Lum Kum Meng for
the continuous support of my Final Year Project study and research, for his patience,
motivation, enthusiasm, and immense knowledge. His guidance helped me in all the time of
research and writing of this thesis. I could not have imagined having a better advisor and mentor
for my Bachelor in Electronics and Electrical Engineering studies.
Besides my advisor, I would like to thank the module lecturer Dr. Tan Kim Piew for his
guidance and briefing of the Final Year Project procedures, protocols, and briefing.
My sincere thanks also goes to the Dean of MDIS Dr. Tham Yiengwei and Lab Technician Mr
Abdul Razak for their continuous support and motivation for completing the project
Last but not the least, I would like to thank my family: my parents Koushik Datta and Paramita
Datta, for supporting me spiritually and mentally throughout my life.
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 2
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 3

IV. TABLE OF CONTENTS

I. ABSTRACT .......................................................................................................................... 1

II. ACKNOWLEDGEMENT.................................................................................................. 1

III. DECLARATION ............................................................................................................... 2

1. INTRODUCTION.............................................................................................................. 13

1.1 Background .................................................................................................................... 13

1.2 Objectives ...................................................................................................................... 14

1.3 Project Scope .................................................................................................................. 14

2. LITERATURE REVIEW ................................................................................................. 15

2.1 Types of Fire .................................................................................................................. 15

2.2 Flowchart of the Fire-Alarm System ............................................................................ 18

3. INSTRUMENTATION ..................................................................................................... 19

3.1 Difference between a Microcontroller and a Microcomputer ...................................... 21

3.2 Types of Development Boards & module ................................................................... 22

3.2.1 NODE MCU V-3 (ES 8266 12E) ...................................................................... 22

3.2.2 ESP32-Cam module ........................................................................................... 23

3.3 Types of Sensor available which can detect fire/flame ................................................ 24

3.3.1 Temperature Sensor ........................................................................................... 24

3.3.1.1 Construction and Technical Specification of a DHT11 Sensor ........... 24

3.3.1.2 Working Principle of a DHT11 ........................................................... 25

3.3.2 Smoke/Gas Sensor ............................................................................................. 27

3.3.2.1 Construction and Technical Specification of a MQ-2 Gas Sensor ...... 30

3.3.2.2 Working Principle of a MQ-2 .............................................................. 31

3.3.2 Flame Sensor...................................................................................................... 32


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 4

3.3.3.1 Construction and Technical Specification of a Flame Sensor ............. 32

3.3.3.2 Working Principle of a Flame Sensor .................................................. 33

3.4 Electronic Equipment required for the Fire Alarm Device ........................................... 34

3.4.1 Display ............................................................................................................... 34

3.4.1.1 Construction and Technical Specification of a TFT Display............... 35

3.4.1.2 Working Principle of a TFT Display ................................................... 35

3.4.2 Piezo Buzzer ...................................................................................................... 36

3.4.2.1 Construction and Technical Specification of a Piezo Buzzer ............. 36

3.4.2.2 Working Principle of a Piezo Buzzer .................................................. 36

4. CONNECTION AND CIRCUIT DIAGRAM ................................................................. 37

4.1 NODE MCU V3 (ES 8266 12E) Connection and Circuit Diagram .............................. 37

4.2 ESP32-Cam module & FTDI-Programmer Connection & Circuit Diagram .................. 38

5. PROCEDURES .................................................................................................................. 39

5.1 Arduino IDE Setup ........................................................................................................ 39

5.2 Flutter Setup ................................................................................................................... 41

5.3 Firebase Setup ................................................................................................................ 43

5.4 Arduino-Firebase Setup ................................................................................................. 47

5.5 Flutter-Firebase Setup .................................................................................................... 47

5.6 Arduino Code ................................................................................................................. 51

5.6.1 ESP8266 coding ................................................................................................. 52

5.6.1 ESP-32 Coding .................................................................................................. 62

5.7 Flutter Code ................................................................................................................... 66

5.7.1 main.dart File .................................................................................................... 67

5.7.2 LoginUI.dart File .............................................................................................. 67

5.7.3 authentication.dart File ..................................................................................... 71


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 5

5.7.4 Main_Section.dart File ........................................................................................ 73

5.7.5 First_Screen.dart File .......................................................................................... 75

5.7.6 dht.dart File ......................................................................................................... 77

5.7.7 MQ2.dart File ...................................................................................................... 78

5.7.8 Temperature.dart File .......................................................................................... 79

5.7.9 Smoke.dart File ................................................................................................... 82

5.7.10 Camera_Webview.dart File ............................................................................... 84

5.8 Alerting System ............................................................................................................. 85

5.9 Design and Casing ......................................................................................................... 90

5.9.1 Static Part ............................................................................................................ 90

5.9.2 Movable Part ....................................................................................................... 92

5.9.3 Assembly Stage ................................................................................................... 93

5.10 3D-Printing ................................................................................................................... 94

6. RESULTS AND DISCUSSION ........................................................................................ 97

6.1 First Test ......................................................................................................................... 97

6.2 Second Test ..................................................................................................................... 98

6.3 Mobile Application Testing ............................................................................................ 98

6.4 Casing Implementation ................................................................................................. 100

6.5 Alerting System Test..................................................................................................... 102

6.56Alerting System Test.................................................................................................... 103

7. CONCLUSION ................................................................................................................ 104

7.1 Troubleshooting ............................................................................................................ 104

7.2 Future Improvements .................................................................................................... 105

7.3 Design and Cost ............................................................................................................ 106

7.4 Closing Stage ................................................................................................................ 106


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 6

8. BIBLIOGRAPHY ............................................................................................................ 107

9. APPENDIX ....................................................................................................................... 108

9.1 Timeline of Project ....................................................................................................... 108

9.2 Gantt Chart .................................................................................................................... 109

9.3 Structure of a Flutter App ............................................................................................. 110

9.4 Dart Cheat Sheet ........................................................................................................... 111

9.5 Arduino Cheat Sheet ..................................................................................................... 112

V. LIST OF FIGURES

1. A Smoke Sensor................................................................................................................... 13

2. Various Parts of Flame......................................................................................................... 16

3. Node MCU V3 ESP8266 12-E Pin Diagram ....................................................................... 22

4. ESP32 Cam Module with FTDI Programmer ...................................................................... 23

5. ESP32 Cam Module Pin Diagram Part 1 ............................................................................. 23

6. ESP32 Cam Module Pin Diagram Part 2 ............................................................................. 24

7. DHT-11 Pin Diagram........................................................................................................... 25

8. DHT 11 Humidity Measurement Part .................................................................................. 26

9. DHT 11 Temperature Measurement Part ............................................................................ 26

10. MQ-2 Pin Diagram ............................................................................................................ 30

11. MQ-2 Gas Sensor Working Part ........................................................................................ 31

12. Flame Sensor Pin Diagram ................................................................................................ 32

13. Light Spectrum Diagram.................................................................................................... 33

14. 16*2 LCD Display ............................................................................................................. 34

15. TFT Display Top & Bottom View ..................................................................................... 34

16. Working of the Piezo Buzzer ............................................................................................. 36


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 7

17. Circuit Diagram of Node MCU V3 (ESP8266 12-E) ....................................................... 37

18. Circuit Diagram of ESP-32 Cam Module & FTDI-Programmer Before Upload (Left Fig)
& After Upload (Right Fig) ..................................................................................................... 38

19. File Window of the Arduino IDE ...................................................................................... 39

20. Preference Window of the Arduino IDE ........................................................................... 39

21. Tools Window in Arduino IDE.......................................................................................... 40

22. Boards Manager in Arduino IDE ....................................................................................... 40

23. Settings Window for the two boards in Arduino IDE........................................................ 41

24. Library Manager Window of Arduino IDE ....................................................................... 41

25. File Manager Window of Android Studio ......................................................................... 42

26. Plugin Manager Window of Android Studio ..................................................................... 42

27. Firebase Project Selection Page ......................................................................................... 43

28. Firebase Project Creation-Naming Page ........................................................................... 43

29. Firebase Project Creation-Google Analytics Page ............................................................ 44

30. Firebase Project Creation- Configure Google Analytics Page ......................................... 44

31. Firebase Project Creation-Confirmation Page ................................................................... 45

32. Firebase Project Console.................................................................................................... 45

33. Firebase Realtime Database Console ................................................................................. 46

34. Firebase Realtime Database Rules ..................................................................................... 46

35. Firebase Console of this Project ........................................................................................ 48

36. Firebase Android App Configuration Page........................................................................ 48

37. AndroidManifest.xml file inside Android Studio .............................................................. 49

38. Firebase Google Service.json download option................................................................. 49

39. Firebase SDK Configuration Option with Android ........................................................... 50

40. Firebase-Android Successful Configuration Message ....................................................... 50


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 8

41. pubspec.yaml file of the Flutter Project ............................................................................. 51

42. Imported Libraries ............................................................................................................. 52

43. Variable Declaration and Definition .................................................................................. 52

44. Code inside void setup () function ..................................................................................... 54

45. Code of wifiConnect () Function ....................................................................................... 55

46. DHT-11 temperature sensor reading declaration and code for updating data on Firebase
Database .................................................................................................................................. 55

47. MQ-2 Gas sensor reading declaration and code for updating data on Firebase Database 55

48. Code for TFT Display in void loop () function ................................................................. 56

49. IF-ELSE statement in the void loop () function................................................................. 57

50. Camera Web Server Example Sketch ................................................................................ 62

51. Camera Web Server Project Tabs ...................................................................................... 62

52. Line number 14 of Camera Web Server Example ............................................................. 62

53. Line number 18 and 19 of Camera Web Server Example ................................................ 63

54. Generated IP Address in the Arduino Serial Monitor........................................................ 63

55. Web Page for live streaming from the ESP 32 Camera Module ....................................... 63

56. Project Files for developing the Flutter Mobile Application ............................................. 66

57. A typical project structure of a Flutter Application ........................................................... 66

58. Firebase Authentication Web Page .................................................................................... 68

59. Widget Structure for Login UI.dart code ........................................................................... 68

60. Widget Structure for authentication.dart codee ................................................................. 71

61. Widget Structure for Main_Section.dart code ................................................................... 73

62. Widget Structure for First_Screen.dart code ..................................................................... 75

63. Widget Structure for dht.dart code..................................................................................... 77

64. Widget Structure for MQ2.dart code ................................................................................ 78


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 9

65. Widget Structure for Temperature.dart code .................................................................... 79

66. Widget Structure for Smoke.dart code .............................................................................. 82

67. Widget Structure for Camera_Webview.dart code ........................................................... 84

68. Download Page of NodeJS ............................................................................................... 85

69. File Structure of Firebase Cloud Function ......................................................................... 87

70. Terminal Message after the deploy of Firebase Cloud Function ....................................... 88

71. (Top) Firebase Function named as “FIRE” deployed in Firebase, (Bottom) Firebase Cloud
Message Statistics ................................................................................................................... 89

72. Logo of Solidworks............................................................................................................ 90

73. Tools used for designing the Static part ............................................................................. 90

74. Four Sectional Views of the Static Part ............................................................................. 91

75. Isometric View of the Static Part ....................................................................................... 92

76. Tools used for designing the Movable Part ....................................................................... 92

77. Two Sectional Views of the Movable Part ........................................................................ 93

78. Tools used for doing the assembly in Solidworks ............................................................. 93

79. Isometric View of the Assembly........................................................................................ 94

80. No interferences detected during the Assembly ................................................................ 94

81. Static Part Imported in Cura .............................................................................................. 95

82. Movable Part imported in Cura.......................................................................................... 96

83. 3D Printer printing the movable part ................................................................................. 96

84. Circuit of the First Test ...................................................................................................... 97

85. Camera Page of the App .................................................................................................... 97

86. Circuit of the Second Test.................................................................................................. 98

87. Front View of Casing ....................................................................................................... 100

88. Side View of Casing (Right) ............................................................................................ 100


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 10

89. Back View of Casing ....................................................................................................... 101

90. Side View of Casing (Left) .............................................................................................. 101

91. Top View of Casing Left ................................................................................................. 101

92. Sensor Tested with incense stick ..................................................................................... 102

93. Sensor Tested with the use of lighter ............................................................................... 102

94. Push Notification send to user device once a Fire is detected ......................................... 103

95. Gantt Chart ....................................................................................................................... 109

96. Dart Cheat Sheet .............................................................................................................. 111

95. Arduino Cheat Sheet ........................................................................................................ 112

VI. LIST OF CODES


1. Arduino Code for ESP-8266 ................................................................................................ 58

2. Arduino Code for ESP-32 Cam Module ............................................................................. 64

3. Dart Code for main.dart file ................................................................................................. 67

4. Dart Code for LoginUI.dart file ........................................................................................... 69

5. Dart Code for authentication.dart file .................................................................................. 72

6. Dart Code for Main_Section.dart file .................................................................................. 73

7. Dart Code for First_Screen.dart file..................................................................................... 75

8. Dart Code for dht.dart file.................................................................................................... 77

9. Dart Code for MQ2.dart file ................................................................................................ 78

10. Dart Code for Temperature.dart file .................................................................................. 79

11. Dart Code for Smoke.dart file............................................................................................ 83

12. Dart Code for Camera_Webview.dart file ......................................................................... 85

13. Index.js code for Firebase Cloud Function ........................................................................ 87


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 11

VII. LIST OF FLOWCHARTS


1. Fire Alarm System ............................................................................................................... 18

2. Mobile App UI Flow Chart ................................................................................................. 99

3. A Basic Widget Structure in a Flutter Project ................................................................... 111

4. Difference between a stateless and a stateful widget ........................................................ 111

VIII. LIST OF TABLES

1. Classes of Fire ...................................................................................................................... 15

2. Flame Temperature at various types of combustion ........................................................... 17

3. List of Equipments used for this Projects ............................................................................ 19

4. Difference between Microcontroller and Microcomputer ................................................... 21

5. DHT-11 Pin Specification.................................................................................................... 25

6. DHT-11 Technical Specification ......................................................................................... 25

7. Different Types of MQ sensors and their usage .................................................................. 27

8. Different Types of MQ sensors and their range................................................................... 27

9. MQ-2 Sensor Pin Specification .......................................................................................... 30

10. MQ-2 Sensor Technical Specification .............................................................................. 30

11. Flame Sensor Pin Specification ........................................................................................ 32

12. Flame Sensor Technical Specification .............................................................................. 32

13. TFT Display Pin Specification........................................................................................... 35

14. TFT Display Technical Specification ............................................................................... 35

15. Piezo Buzzer Pin Specification .......................................................................................... 36

16. Piezo Buzzer Technical Specification .............................................................................. 36

17. Node MCU V3 (ESP8266 12-E) Pin Connection .............................................................. 37

18. ESP-32 Cam Module & FTDI-Programmer Pin Connection Before Upload ................... 38
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 12

19. ESP-32 Cam Module & FTDI-Programmer Pin Connection After Upload ..................... 38

20. Firebase Operations with any Arduino Compatible Board ................................................ 47

21. Explanation of the command used in void setup () function ............................................. 53

22. List of troubleshooting methods ..................................................................................... 104

23. List of Future Improvements .......................................................................................... 105

24. Final Costing of the device .............................................................................................. 106

25. Project Timeline .............................................................................................................. 108

IX. LIST OF ABBREVIATION

Sl Abbreviated Words Full Form


No

1 GPIO General Purpose Input/Output

2 DIY Do it Yourself

3 NTC Negative Temperature Coefficient

4 ppm Parts per million

5 GUI Graphical User Interface

6 PWM Pulse Width Modulation

7 SPI Serial Programming Interface

8 TFT Thin Film Transistor

9 OS Operating System

10 IP Internet Protocol

11 LPG Liquefied Petroleum Gas

12 CO Carbon Monoxide

13 BJT Bipolar Junction Transistor

14 Fig Figure
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 13

1. INTRODUCTION

1.1 Background
The rapid oxidation of a material in an exothermic chemical reaction, releasing heat, light and
various reaction product is defined as fire (Anonymous, 2009). Ever since the discovery of fire
in the early stone age era by the people of the stone age era, humans have used this form of
energy as the primary source in various domestic and industrial application. For over the years
human have learned various technique to control this natural form of energy.
However, although fire is used in various applications, but if it is not controlled properly Fire
can cause destruction and damage to household or an area. It can even cause health hazard
which can eventually lead to death. Accident can happen at any time & anywhere. If proper
precautions are taken at an early stage, then the accidents along with the destruction and
damages caused by fire could be prevented. Proper precautions can also prevent injuries and
mishaps, but most importantly it can also potentially can save many lives.

Figure 1: A Smoke Sensor

There are many devices available in the market that can prevent the deadly and destructive fire.
Fire Alarm is one of such examples of a Fire Prevention and Alert Device available in the
market. Now the way the fire alarm works is quite simple. There are mainly two steps involved
in this type of traditional Fire Alarm Systems which are given as follows:
 There are sensors which can detect the fire in its proximity
 There are buzzers or an audio device which will alert the people nearby.
Normally this system will work and will prevent destruction and damage to only a certain
extent. There are many limitations to the traditional fire alarm system. Some of the limitation
are listed as follows:
 Alerting the people nearby only works within a certain range: Suppose the person
stays in Location-A and currently that person is in Location-B. Let us consider that
Location-B is 10kms away from Location-A and Location-A is situated in one of the
remote areas of a town. Now if there is Fire in Location-A and let’s say the person is
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 14

the only one staying in that house, there is no way for the person currently in Location-
B to know that there is a fire in his/her house. The time the person knows about the fire,
everything is over.
 It is not possible to understand the source, extent of damage and the number of
people stuck inside a room or building if there is a fire : There are different types of
fire and different ways to extinguish the fire. Some types of fire can be extinguished
using water. However, if there is any electrical source beside the fire, sand is mostly
preferred because water can cause electrocution. Fire Fighters or rescuers must
understand what type of extinguishing source they will use. But during this time of
emergency, they must act first. So, these devices are really disadvantageous in this type
of situation.
In this project the above issues are addressed, and an inexpensive easy solution is provided just
by using basic Electronics equipment and Programming techniques which could potentially
save lives and can prevent the damage and destruction caused by fire.

1.2 Objectives
The main aim of this project is to design a smart Fire Alarm System and Device. Apart from
this aim the below list shows the following objective that the design should meet:

1) The Fire Alarm device should be connected to the internet to send the sensor data to any
database service provider.
2) Develop a web/mobile application, so user can visualize the sensor data.
3) Send notifications to the user’s device if there is a fire which is detected by the sensors
4) (Optional) Add an inexpensive camera module which will support live streaming, so
developer can see the live stream if there is a Fire in a room or area.
5) Design a casing for the Fire Alarm Device and implement the microcontroller, sensors and
camera within the casing

1.3 Project Scope


In the market there are plenty of Fire Alarm Devices which are available. Although a basic Fire
Alarm Device is itself very inexpensive but as the word “Smart” is added before the device,
the overall cost becomes expensive. The Fire Alarm Device which will be designed for this
project is inexpensive and will be a great addition to the fire safety and prevention. Moreover,
the device can be easily assembled and upgraded easily which makes it an user-friendly device
for the developer, designer or DIY enthusiast. The device is an example of how IoT can be
used to achieve the unthinkable, for this case some basic IoT concepts are used to connect the
Fire Alarm Device to the Internet and through the power of internet notification will be send
to the user no matter where they are whenever there is a fire. The device also has an inbuilt
camera whose main function is to capture the video which will be helpful for rescuers to
understand if there are any survivors who are stuck inside and rescue them accordingly. The
device is the first of its kind and will be a game changer after the device launch in the market.
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 15

2. LITERATURE REVIEW

2.1 Types of Fire


Now before starting with the main part for this report which is the Design & Construction and
also the Testing section for the device, it is always a good practice to know some basic
characteristic of a fire and flame. Now Fires are divided into various classes. The classes of
fire are described as follows
 Class A - This type of fire involves solid material such as wood, textile or papers etc
(Anonymous, 2017).
 Class B - This type of fire involves flammable liquids such as oils, petrol or diesels etc.
 Class C - This type of fire involves mainly gases like methane etc.
 Class D - This type of fire involves metals like aluminium, magnesium etc.
 Class E - This type of fire involves electrical apparatus or appliances like computer,
mobile phones etc.
 Class F - This type of fire involves cooking oils or fat etc.
Each of this fire have different procedures for extinguishing the fire. If the firefighters or the
rescuers does not follow the proper procedure for extinguishing, it can cause even more
deadlier problems for example let’s say there is a Class E Fire and the rescuers use water as the
extinguishing medium – this type of scenario can eventually lead to electrocution. The below
table shows the various types of extinguishing medium which firefighters use to extinguish the
various classes of fire.
Table 1: Classes of Fire

Now in this project the main focus is not on the available extinguishing medium. Instead the
main focus is on the characteristics of flames. The basic knowledge on the characteristics and
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 16

terms for fire and flames will come in handy during the selection of sensor and the design of
the circuit.
Earlier Fire was discussed, now Flame will be discussed. Most people think that fire and flames
are the same thing. In reality they are different. The visible and the gaseous part of the fire is
defined as a Flame which is caused by an extremely heat-releasing reaction happening in a thin
zone. Very hot flames are hot enough to have ionized gaseous components of sufficient density
to be considered plasma (Schmidt & Symes, 2008).
Depending on the combustion medium, the temperature and colour of the flame differ from
each other. Let us take the example of a candle in order to understand how the flame occurs.
The heat applied allows the molecules of fuel in the candle wax to vaporize (If this process
occurs without oxidizer in the inert atmosphere, it is called pyrolysis). They can then readily
react with oxygen in the air in this state, which gives off enough heat to vaporize even more
fuel in the ensuring exothermic reaction, thereby retaining a constant flame. The high flame
temperature allows the molecules of vaporized fuel to decompose, creating various incomplete
products of combustion and free radicals, and these products then react with each other and
with the reaction-involved oxidizer. All the various parts of the flame from a candle with a cold
metal spoon may be inspected. Water vapour is the higher part, the end product of combustion;
soot is the yellow part in the middle; unburned wax is down just next to the candlewick. In
some of the transient reaction intermediates, such as the methylidyne radical (CH) and diatomic
carbon (C2), ample energy in the flame can excite the electrons, resulting in the emission of
visible light as these substances release their excess energy (see spectrum below for a
description of which particular radical species emit specific colours). As a flame's combustion
temperature increases (if the flame contains small particles of unburnt carbon or other
material), the total electromagnetic radiation energy released by the flame increases. Apart
from oxygen, other oxidizers may be used to create a blaze. Hydrogen burning in chlorine
produces a flame and, as the combustion product, releases gaseous hydrogen chloride (HCl) in
the process. Hydrazine and nitrogen tetroxide, which
is hypergolic and widely used in rocket engines, is
another of the potential chemical combinations.
Fluoropolymers may be used as an oxidizer of
metallic fuels, for example, in the composition of
magnesium / Teflon / Viton, to provide fluorine
(Anonymous, 2008). The chemical kinetics that occur
in the flame are very complex and usually include a
large number of chemical reactions, most of them
radicals, and intermediate species. For example, to
define biogas combustion, a well-known chemical
kinetics scheme, GRI-Mech, utilizes 53 species and
325 elementary reactions.
The methods of distributing the necessary
combustion components to a flame are different.
Oxygen and fuel diffuse through one another in a
diffusion flame; the flame happens where they meet.
The oxygen and fuel are premixed beforehand in a
Figure 2: Various Parts of a Flame
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 17

premixed flame, resulting in a different form of flame. By evaporating the fuel that rises in a
laminar flow of hot gas that then mixes with surrounding oxygen and combusts, candle flames
(a diffusion flame) work.
Almost all the fire accident which happened in various parts of the world produced the flame
whose primary source of gas is oxygen. Although oxygen is one of the main sources of live for
almost all the species living in the earth, but oxygen can act as deadly source when it comes to
fire mishaps. Hence it can be said that the temperature of the flame is dependent upon the
percentage of oxygen in air.
The table given below shows the flame temperature during the combustion of various materials
(Various, 2019)

Table 2: Flame Temperature at various types of combustion


Sl Material for combustion Flame Temperature
no

1 Charcoal fire 750–1,200 °C (1,382–2,192 °F)

2 Methane (natural gas) 900–1,500 °C (1,652–2,732 °F)

3 Bunsen burner flame 900–1,600 °C (1,652–2,912 °F) [depending on the air


valve, open or close.]

4 Candle flame ≈1,100 °C (≈2,012 °F) [majority]; hot spots may be 1,300–
1,400 °C (2,372–2,552 °F)

5 Propane blowtorch 1,200–1,700 °C (2,192–3,092 °F)

6 Backdraft flame peak 1,700–1,950 °C (3,092–3,542 °F)

7 Magnesium 1,900–2,300 °C (3,452–4,172 °F)

8 Hydrogen torch Up to ≈2,000 °C (≈3,632 °F)

9 MAPP gas 2,020 °C (3,668 °F)

10 Acetylene blowlamp/blowtorch Up to ≈2,300 °C (≈4,172 °F)

11 Oxyacetylene Up to 3,300 °C (5,972 °F)

12 Hydrogen torch Up to ≈2,000 °C (≈3,632 °F)

13 MAPP gas 2,020 °C (3,668 °F)

14 Acetylene blowlamp/blowtorch Up to ≈2,300 °C (≈4,172 °F)

15 Oxyacetylene Up to 3,300 °C (5,972 °F)

16 Animal fat 800–900 °C (1,472–1,652 °F)

17 Kerosene 990 °C (1,814 °F)

18 Gasoline 1,026 °C (1,878.8 °F)

19 Wood 1,027 °C (1,880.6 °F)

20 Methanol 1,200 °C (2,192 °F)

21 Charcoal (forced draft) 1,390 °C (2,534 °F)


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 18

2.2 Flowchart of the Fire-Alarm System


Flow Chart 1: Fire Alarm System
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 19

3. INSTRUMENTATION
The below table shows the list of required instrument and equipment which will be required
for the Fire Alarm Device.
Table 3: List of Equipment Used For this Project
Sl no Type Equipment Picture
1 Microcontroller NodeMCU V3 (ESP8266
12-E)

2 ESP32 Cam Module with


FTDI Programmer

3 Sensor Flame Sensor

4 Temperature Sensor

5 Smoke Sensor
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 20

6 Buzzer

7 Display

8 Casing PLA roll (1.75 mm)

9 Board Breadboard

10 Wires Jumper Wires


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 21

3.1 Difference between a Microcontroller and a Microcomputer


Now before moving onto, the main discussion part of the report, it is always a good practice to
know the difference between a microcontroller and a microprocessor. Whenever it comes to
modern day electronics and Internet of Things (IoT) project, the first thing which a designer
think is to whether to hook up the sensors or devices to a microcontroller or a microprocessor.
There is no specific rule that on what type of controller or the brain of the circuit a designer
should use. Both microprocessors and microcontrollers have their own set of advantages and
limitations. It depends mainly on the case in which a designer finds the best thing to use. The
difference between a microcontroller and a microcomputer is given below (Anonymous, 2016):
Table 4: Difference between Microcontroller and Microcomputer

In this design for the “Fire Alarm System”, a microcontroller is used and preferred instead of
a microprocessor. The main reason for using a microcontroller instead of a microprocessor is
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 22

because the final hardware must be smaller and inexpensive. When it comes to microcontroller,
the microcontroller is attached to a development board. There are many developments board
option which are available in the market. Arduino UNO is one of the examples of such board
which is widely used in the market. To programme an Arduino, the programming language
which is used is known as the Arduino language. Most people tend to confuse Arduino
Language with C++ or C due to its similarity in syntax and the data structures. The Integrated
Development Environment which people use mostly to programme is called as Arduino IDE.
People can use other IDE as well like Visual Code Studio or Arduino Online Editor etc.

3.2 Types of Development Boards & module

3.2.1 NODE MCU V-3 (ES 8266 12E)


Although Arduino UNO is a good development board to get started into modern electronics
and IoT, but the size is large and is not feasible because the size of the fire alarm should be as
small as possible. Instead a NodeMCU V3 development board with an ESP8266-12E WiFi
chip will be used. The ESP8266 is a low-cost Wi-Fi chip with full TCP/IP stack and MCU
(Micro Controller Unit) (PDAControl, 2017). It
comes in many variants starting from ESP-01 to
ESP-12E.
For this application, the ESP8266-12E has the
following advantages:
• It is cheaper
• The length and width of this board is small
49mm* 26mm
• It has an inbuilt Wi-Fi module. This feature
makes it easier to do perform Internet
operation with just a few lines of code.
The only limitations for this board is that since
this board is small, there are lesser number of
Digital and Analog pins available. However, only
a few Digital and Analog Pins will be needed, so
for this application this board is a good choice.
The below table shows some of the important
specification for the NodeMCU module. The pin
diagram for the Node MCU module V3 is given
in Figure 3

The board is required to connect the sensors and


devices like LCD display and buzzer to it.

Figure 3: Node MCU V3 ESP8266 12-E Pin Diagram


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 23

3.2.2 ESP32-Cam module


ESP32 is another type of microcontroller that offers Wi-Fi capabilities which allows potential
consumers to implement IoT solution in an easy manner. An ESP32 cam module will be used
in the Smart- Fire Alarm device. The reason behind adding the ESP-32 cam module is to allow
rescuers and firefighters to monitor the situation of a particular area in case of a fire. Rescuers
can also see if there are any people who are stuck inside of a room when there is a fire. This
will allow easier rescue operations and avoid confusion and delay during the time of
emergency.

The ESP32-CAM with the ESP32-S chip is a


very small camera module In addition to the
OV2640 camera and many peripheral GPIOs,
it also features a microSD card slot that can
be useful for storing images taken with the
camera or storing files to serve customers
(Santos, 2019). However, the only
disadvantages of this module is that it does
not have a USB Connector soldered with the
Camera module. Figure 4: ESP32 Cam Module with FTDI Programmer

Due to this small issue electronic designers or the developer must purchase a FTDI programmer
which will allow the developer upload the code from the U0R and U0T pins of the ESP-32 cam
module. The camera which will be attached to the ESP-32 cam module is a OV2640 camera.
It is one of the cheapest and smallest webcams currently available in the market. For this
application, the ESP32 cam module has the following advantages:
• It is cheaper compared to other camera modules in the market
• It has an inbuilt Wi-Fi module. This feature makes it easier to perform Internet based
operation with just a few lines of code.
The pin diagram for the ESP-32 cam module is shown in Figure 5

Figure 5: ESP32 Cam Module Pin Diagram Part 1


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 24

Figure 6: ESP32 Cam Module Pin Diagram Part 2

3.3 Types of Sensor available which can detect fire/flame


Currently there are mainly three-types of sensors which are available in the market, which can
detect if there is a fire or flame within the sensor’s range. Now all of this sensor might not be
strong as the sensor used in the industry but for a DIY (Do it Yourself)- Fire Alarm System,
the sensors discussed below are one of the best sensor which is capable of detecting fire or
flame.

3.3.1 Temperature Sensor


There are many types of temperature sensors which are available in the market. Now for this
Fire Alarm System, a DHT 11 sensor will be used. The sensor doesn’t only measure
temperature of its surroundings but is also capable of measuring the humidity of its
surroundings. The amount of water vapour present in the air is known as humidity. In many
countries like Australia or the United States of America, low humidity can cause bush fire.
Humidity is one of the factors that determines the mixture of water vapour, nitrogen, oxygen
etc.

3.3.1.1 Construction and Technical Specification of DHT11 Sensor


DHT11 normally consists of four pins. However, there are some DHT11 which only has three
pins. The purpose of each pin is given in the following Table 5 (Ali, 2019).
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 25

Table 5: DHT-11 Pin Specification


Pin # Type Parameters
1 Vcc The pin is used for power input purpose. The pin is usually connected
to a 5V or 3.3V power supply.
2 Data Through this pin the output of the temperature and humidity values are
received by Serial Transmission Protocol.
3 N/C Not Connected.
4 Ground The pin used for connecting the module to ground.
The following table shown in Table 6 shows some technical specification of the DHT 11 sensor
Table 6: DHT-11 Technical Specification
Parameters Value
Operating Voltage 3.3 to 5 V
Operating Current 0.3 to 5.5 mA
Operating temperature -40°C to 80°C
Humidity Range 0 to 100 %
Accuracy ±0.5°C and ±1%.
Sampling Rate 0.5Hz
Dimension 27mm x 59mm x 13.5mm
Weight 2.4g
Cost 1 SGD to 5 SGD
The diagram given below shows the pin diagram of a DHT11 sensor.

Figure 7: DHT-11 Pin Diagram

3.3.1.2 Working Principle of a DHT11


DHT11 sensor comprises of a capacitive sensing element which is able to sense the humidity
& a thermistor which is capable of sensing temperature. The capacitor which senses the
humidity has two electrodes attached with a substrate which can hold moisture as a dielectric
between them. Whenever there is change in the humidity of the surroundings the value of
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 26

capacitance changes as well. The picture given below shows the constructions of DHT11 for
sensing the humidity.

Figure 8: DHT 11 Humidity Measurement Part


DHT11 sensor also has a Negative Temperature Coefficient sensor or a Thermistor embedded
on the DHT11 PCB. Thermistors are a variable resistor which alters its resistance with the
alteration of surrounding temperature. Negative Temperature Coefficient Sensors are sensor
whose resistance value increases with the decrease in temperature. The graph given below
shows that the as the temperature increases the resistance of the NTC or the Thermistor
decreases or decay exponentially.

Figure 9: DHT 11 Temperature Measurement Part


In the end the IC’s job is to evaluate and process the value of the new resistance of the
thermistor and convert that analogue value into digital form
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 27

3.3.2 Smoke/Gas Sensor


The second type of sensor which will be added to the design is a Smoke/Gas Sensor. As the
name suggests this type of sensor is capable of detecting any gas or smoke in its surroundings.
There are many models of Smoke/Gas Sensor module available in the market. However, the
most popular model for Smoke detecting sensor available are from the MQ series of
Gas/Smoke detecting sensors.

This type of sensors are small and inexpensive. However, most importantly the series of MQ
sensors are compatible with any family of microcontroller. Now there are various types of MQ
sensors which are available in the market and each of those different sensors detect different
type of gas in its surroundings. The most common type of MQ sensors which designer and
consumers use are listed as follows along with their usages (Davidegironi, 2018) .
Table 7: Different Types of MQ sensor and their usage
Sl No Name Usage
1 MQ-2 This model of sensor detects mostly flammable gas such as
LPG, Carbon Monoxide etc in its surroundings
2 MQ-3 Detects the presence of ethanol in its surroundings
3 MQ-4 Detects the presence of methane and natural gases
4 MQ-5 Detects the presence of LPG and methane in its surroundings
5 MQ-6 Like the MQ-5, this sensor also detects the presence of LPG
and methane in its surroundings
6 MQ-7 Like the MQ-2 this type of sensor is capable of detecting
Carbon Monoxide and also Hydrogen (H2) in its
surroundings
7 MQ-8 Detects the presence of Hydrogen (H2) and other types of
gases in its surroundings
8 MQ-135 Detects the presence of gaseous ammonia (NH3), benzene,
ethyl alcohol, carbonic dioxide (CO2) and other types of
gases in it’s surroundings.

Now from the above table, it is very hard to conclude the type of sensor which will be used in
the design because there are sensors which can detect the same types of gases. To avoid this
problem electronic designers will need to refer to a table that shows the range of the types of
gases which will be detected. The table shown in Table 8 shows the range of the gases a particle
module can detect
Table 8: Different Types of MQ sensor and their range

Gas Measurable Gases Range

Grove - CO 0 ~ 1000 ppm


Multichannel Gas
Sensor Alcohol 10 ~ 500 ppm
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 28

CH4 > 1000 ppm

Propane > 1000 ppm

NO2 0.05 ~ 10 ppm

NH3 1 ~ 500 ppm

Iso-butane > 1000 ppm

H2 1 ~ 1000 ppm

CO 200 ~ 10000 ppm

Alcohol 100 ~ 2000 ppm

CH4 5000 ~ 20000 ppm

Propane 200 ~ 5000 ppm


Grove - Gas
Sensor (MQ2)
LPG 200 ~ 5000 ppm

Butane 3000 ~ 5000 ppm

Smoke 200 ~ 10000 ppm

H2 300 ~ 5000 ppm

CO 0.05 ~ 10 ppm

Alcohol 0.05 ~ 10 ppm

CH4 0.05 ~ 10 ppm


Grove - Gas
Sensor (MQ3)
Hexane 0.05 ~ 10 ppm

LPG 0.05 ~ 10 ppm

Benzine 0.05 ~ 10 ppm


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 29

CO 200 ~ 10000 ppm

Alcohol 200 ~ 10000 ppm

Grove - Gas
CH4 200 ~ 10000 ppm
Sensor (MQ5)

LPG 200 ~ 10000 ppm

H2 200 ~ 10000 ppm

CO 20 ~ 2000 ppm

Grove - Gas
CH4 500 ~ 10000 ppm
Sensor (MQ9)

LPG 500 ~ 10000 ppm

Grove - Dust
Dust 0 ~ 8000 pcs/0.01cf
Sensor

Grove - Alcohol
Alcohol 20 ~ 1000 ppm
Sensor

Grove - Gas
O2 0 ~ 25% VOL
Sensor (O2)

Grove - HCHO
HCHO 5 ~ 40 ppm
Sensor

Grove - CO2 CO2 0 ~ 2000 ppm

From the above table it is seen that the range is given in ppm or parts per million. Parts-per-
million (abbreviated ppm) is the ratio of one gas to another. For example, 1,000ppm of CO2
means that if you could count a million gas molecules, 1,000 of them would be of carbon
dioxide and 999,000 molecules would be some other gases (Various, 2014).
In the project, MQ-2 sensor will be used. MQ-2 Gas Sensor can detect Carbon Monoxide,
Smoke and other types of gases.
It is difficult to detect carbon monoxide because it does not have any scent, taste, or colour.
This also means that, without realizing, it is easy to inhale.
When fuels such as gas, oil, coal, and wood do not burn entirely, carbon monoxide is emitted.
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 30

In an enclosed space, as a fire burns, the oxygen in the room is eventually used up and replaced
by carbon dioxide. The fuel is stopped from burning entirely after a build-up of carbon dioxide
in the air and begins to emit carbon monoxide.

3.3.2.1 Construction and Technical Specification of a MQ-2 Gas Sensor


Like the DHT11, MQ-2 normally consists of four pins. The purpose of each pin is given in the
following Table 9 (Anonymous, 2019).
Table 9: MQ-2 Sensor Pin Specification
Pin# Type Parameters
1 VCC The pin is used for power input purpose. The pin is usually connected to a 5V
or 3.3V power supply.
2 GND This is the Ground Pin and needs to be connected to GND pin on the
Microcontroller Development Board.
3 D0 This pin provides a digital representation of the presence of combustible
gases.
4 A0 This pin provides analog output voltage in proportional to the concentration
of smoke/gas.
The following table shown in Table 10 shows some technical specification of the MQ-2 sensor
Table 10: MQ-2 Technical Specification
Parameters Value
Operating voltage 5V
Load resistance 20 KΩ
Heater resistance 33Ω ± 5%
Heating consumption <800mw
Sensing Resistance 10 KΩ – 60 KΩ
Concentration Scope 200 – 10000ppm
Preheat Time Over 24 hour
Operating voltage 5V
Load resistance 20 KΩ
The diagram given below shows the pin diagram of a DHT11 sensor.

Figure 10: MQ-2 Pin Diagram


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 31

3.3.2.2 Working Principle of a MQ-2 sensor


MQ2 is one of the gas sensors widely used in the MQ series of sensors. It is also referred to
as Chemiresistors as a Metal Oxide Semiconductor (MOS) style Gas Sensor as the detection
is based on the resistance shift of the sensing material when the gas encounters the material.
Concentrations of gas can be identified using a simple voltage divider network.
This sensor contains a sensing element enclosed in a stainless-steel mesh, mostly aluminium
oxide-based ceramic, coated with Tin Dioxide. There are six connecting legs attached to the
sensing portion. For the heating of the sensing element, two leads are responsible, the other
four are used for output signals (Anonymous, 2019).

Figure 11: MQ-2 Gas Sensor Working Part


When heated at high temperatures in the air, oxygen is adsorbed on the surface of the sensing
material. This oxygen is then attracted by donor electrons present in tin oxide, thus
preventing the current flow.
These oxygen atoms react with the reducing gases when reducing gases are present, thereby
decreasing the surface density of the adsorbed oxygen. The current will now flow through the
sensor, generating analog voltage values.
In order to know the gas concentration, the voltage values are calculated. Voltage levels when
the gas concentration is high are higher.
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 32

3.3.3 Flame Sensor


A flame sensor is a sensor which can sense the presence of any flame or fire in within the sensor
range. The Flame sensor module has a photodiode for light detection and an op-amp for
sensitivity control. It is used to detect fire upon detection and provide a Strong signal.

3.3.3.1 Construction and Technical Specification of a Flame Sensor


Like the DHT11, Flame Sensor normally consists of four pins. However, some of the module
has 3 pins in it. The purpose of each pin is given in the following Table 11.
Table 11: MQ-2 Sensor Pin Specification
Pin# Type Parameters
1 VCC The pin is used for power input purpose. The pin is usually connected to a 5V
or 3.3V power supply.
2 GND This is the Ground Pin and needs to be connected to GND pin on the
Microcontroller Development Board.
3 D0 This pin provides a digital representation of the presence of combustible
gases.
4 A0 This pin provides analog output voltage in proportional to the concentration
of smoke/gas.
The following table shown in Table 12 shows some technical specification of the Flame sensor
Table 12: MQ-2 Sensor Technical Specification
Parameters Value
IC Chip used LM393 comparator chip
Detection Range 760 nm to 1100 nm
Operating Voltage 3.3 V to 5 V
Maximum Output Current: 15 mA
Digital Outputs 0 and 1
Detection Angle Approx 60 degrees
Sensitivity Adjustment Adjustable sensitivity via potentiometer
LED lights indicators Power (red) and digital switching output (green)
Cost 1 to 5 SGD

The diagram given below shows the pin diagram of a Flame sensor.

Fig 12: Flame Sensor Pin Diagram


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 33

3.3.3.2 Working Principle of a Flame sensor


During a fire, or when there is an occurrence of a flame, Infrared wavelengths are emitted from
the flame. The flame sensor which we will be used in this design is an Infrared Flame Sensor.
As the name suggest whenever there is a fire, the sensor detects the infrared wavelength of the
fire and sends or triggers notification to the user.

In Figure 12, if seen carefully, it is noticed that the Flame sensor has a black cylindrical object
mounted on the top of the Flame Sensor PCB that looks like a LED. This part is the
phototransistor, and it is the main component which detects the infrared wavelength of the
flame.

The phototransistor is an NPN Transistor with three terminals, where the emitter is the long
lead and the collector is the shorter one (there is no base terminal because the light it detects
will allow current flow).

In the wavelength ranging from 760 nm to 1100 nm, this photo transistor is coated with black
epoxy, making it sensitive to infrared radiation and this photo transistor (YG1006) is sensitive
to infrared radiation.
The sensor can detect infrared light up to 100 cm within its 60-degree detection angle using
this specific type of flame sensor.
There are two types of YG1006 Photo Transistor Flame Sensor implementations: one is with
both Analog Output and Digital Output, while the other is with Digital Output only (Ayesha
Rafat Arkeri, 2019).

In this design the module which has the Digital Output Pin will be used.

Figure 13: Light Spectrum Diagram


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 34

3.4 Electronics Equipment required for the Fire Alarm Device

3.4.1 Display
Although a mobile application will be created, but there are certain users who might want to
view the sensor data from the actual device. For this type of scenarios an electronic display
needs to be added to design which is an extra feature for the Fire Alarm Device. There are
many types of display which are currently available in the market and are compatible with the
ESP8266 microcontroller. These displays come in various sizes, types, and functionalities. It
solely depends on the electronic designer on which display they want to select.
One of the most popular display which people use widely is the LCD (16*2) display. This type
of display are developer friendly when it comes to coding and implementation. However, there
are various disadvantages to these types of display:
• The display does not have a nice Graphical Developer Interface (GUI) and the display
is not colourful. In 2021, this display fells really outdated considering modern standards
• The display is huge and bulky. Currently for almost all electronic devices are small and
having a huge display will make the hardware design look
ugly.
• Although the size is huge, but the display can only show
32 characters. Although the numbers might vary for other
types of LCD display but if a developer wants to display
a greater number of characters, the display size will also
be increased.
• For this display the developer cannot increase or decrease
Figure 14: 16*2 LCD Display
the font-size. Neither the screen could be rotated.
In order to avoid the above-mentioned issues, the display which will be used for the Fire Alarm
device is a Thin Film Transistor (TFT) display. Like the LCD display, TFT display comes in
various sizes and configuration. For the Fire Alarm Device, 1.8 inches TFT display with
128*160 resolution will be used.
The advantages of this display are listed as
follows.
• It offers a colourful display.
• The module is itself quite light.
• Although the display is small
compared to the LCD (16*2)
display, but the developer can
programme it to display a greater
number of characters.
• The developer can rotate the screen
and can increase or decrease the
font-size. Figure 15: TFT Display Top & Bottom View
• The developer can also programme this to display custom images by loading the images
with a SD card by inserting the card within the slot attached to the TFT display
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 35

3.4.1.1 Construction and Technical Specification of a TFT Display


The pin specification of the 1.8’’ TFT display is given below .
Table 13: TFT Display Pin Specification
Pin# Type Parameters
1 VCC This pin supplies power for the module. The pin can be connected to 5V or
3V output from the Microcontroller Development Board.
2 GND This is the Ground Pin and needs to be connected to GND pin on the
Microcontroller Development Board.
3 CS This is the TFT Serial Peripheral Interface chip select pin
4 RESET This is the TFT reset pin. Its best to have this pin controlled by the library
so the display is reset cleanly, but developer can also connect it to the
Arduino Reset pin, which works for most cases.
5 A0 This is the TFT SPI data or command selector pin
6 SDA This is the Serial Peripheral Interface Microcontroller Out Serial In pin, it
is used to send data from the microcontroller to the SD card and/or TFT
7 SCK This is the Serial Peripheral Interface clock input pin
8 LED This is the PWM input for the backlight control. Developer should connect
3-5 VDC to turn on the backlight and Connect it to ground to turn it off.
The following table shown in Table 14 shows some technical specification of the TFT display
Table 14: TFT Display Technical Specification
Parameters Value
Resolution 128×160, 18-bit (262,144) color
Operating Voltage 3 V to 5 V
Overall dimensions 34mm x 56mm x 6.5mm
Maximum Current drawn at maximum 50mA
backlight
Cost 5-7 SGD

3.4.1.2 Working Principle of a TFT Display


Simple chemical and electrical properties are used by TFT screens or thin film transistor
displays to produce a visible image on a panel. Using an electrical charge that causes the liquid
crystals to change their molecular structure, allowing "pass-through" to different backlight
wavelengths. The TFT display's active matrix is in continuous flux and rapidly adjusts or
refreshes depending on the incoming signal from the control unit.
The TFT panel utilizes multiple filter layers sandwiched between two panels of glass. Two
polarizer filters, colour filters and two layers of alignment decide exactly how much light can
pass and what colours will be emitted. A colour filter shows the colour, and the top layer houses
the visible panel. The TFT layer controls the light flow.
The TFT display pixels are calculated by the colour matrix's underlying density and the TFT
layout. The more pixels available, the greater the detail. The TFT displays recommended for
any project are specified by available screen size, power consumption needs, and product
needs.
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 36

Standard TFT displays use a white, bright light backlight to produce the image. To produce
their light, newer panels use LED or light emitting diodes and thus use less power and need
less depth by design.

3.4.2 Piezo Buzzer


A device which is mainly used as an alerting device that produce a sound based on reverse of
the piezoelectric effect. This device is used in Alarming Circuits, Communication
Equipment’s etc. (Mybotic, 2018)

3.4.2.1 Construction and Technical Specification of a Piezo Buzzer


The pin specification of the Piezo Buzzer is given below
Table 15: Piezo Buzzer Pin Specification

The following table shown in Table 16 shows some technical specification of the Piezo Buzzer
Table 16: Piezo Buzzer Technical Specification
Parameters Value
Rated current 30mA
Operating Voltage 3 V to 5 V
Approx. resonant frequency 2300Hz

3.4.2.2 Working Principle of Piezo buzzers

Figure 16: Working of the Piezo Buzzer


When a value of small DC voltage is employed to the input pins and the applied voltage is
converted to an oscillating signal by using the resistor and transistor together. After that the
inductor coil to intensify these oscillating signals. A pressure variation is produced when an
electrical potential is applied across a piezoelectric element, thus the element expands and
decreases diametrically. So, the piezoelectric material is applied in-order to produce the
ceramic plate vibrate rapidly which would create a loud and sharp sound
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 37

4 CONNECTION AND CIRCUIT DIAGRAM

4.1 NodeMCU V3 (ESP8266 12-E) Connection and Circuit Diagram


The connection of the electronic equipment with the Node MCU V3 development board is
shown in table 17
Table 17: NodeMCU V3 (ESP8266 12-E) Pin Connection
Sl No Module Node MCU V3 pin Module Pin
3.3 V LED
D0 SCK
D2 SDA
D5 A0
1 TFT Display
D1 CS
D3 RESET
GND GND
VIN VCC
A0 A0
GND GND
2 MQ-2 GAS SENSOR
VIN VCC
OPEN-CIRCUIT DO
OPEN-CIRCUIT A0
GND GND
3 FLAME SENSOR
VIN VCC
D7 DO
D6 SOURCE
4 DHT11 GND GND
VIN VCC
D8 VIN
5 Buzzer
GND GND

Figure 17: Circuit Diagram of NodeMCU V3 (ESP8266 12-E)


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 38

4.2 ESP-32 Cam Module & FTDI-Programmer Connection & Circuit


Diagram
The connection of the ESP-32 Cam Module and FTDI-Programmer board before uploading the
code is shown in table 18
Table 18: ESP-32 Cam Module & FTDI-Programmer Pin Connection Before Upload
Sl No FTDI PROGRAMMER PIN ESP32-CAM PIN
1 RX UOT
2 TX UOR
3 VCC 5V
4 GND GND
5 NOT APPLICABLE IO0 shorted with GND

The connection of the ESP-32 Cam Module and FTDI-Programmer board after uploading the
code is shown in table 19
Table 19: ESP-32 Cam Module & FTDI-Programmer Pin Connection After Upload
Sl No FTDI PROGRAMMER PIN ESP32-CAM PIN
1 RX UOT
2 TX UOR
3 VCC 5V
4 GND GND

Figure 18: Circuit Diagram of ESP-32 Cam Module & FTDI-Programmer Before Upload (Left Fig) & After
Upload (Right Fig)
The circuit diagram shown in Figure 17 and 18 was done using Fritzing. Fritzing is an
electronics Computer Aided Design software which allows an electronic designer to design
electrical hardware before building the actual circuit to avoid Electrical accidents or mishaps.
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 39

5. PROCEDURES
Before jumping into the coding part, the designer or the developer have to do and perform
certain task in order to test the system. The steps which will be followed by the Developer are
given as follows.

5.1 Arduino IDE Setup


The first thing the developer need to setup is the Arduino IDE. Now if the developer used a
normal Arduino Compatible Development Board then they can skip this part but since a
NodeMCU V3 Development Board is used to perform Internet based operation using the
ESP8266 microcontroller , the developer have to follow the steps as given as follows.
• After opening the Arduino IDE, the developer must select the following:
File -> Preference

Figure 19: File Window of the Arduino IDE

• After clicking on Preferences, the developer will have to add the following url in the
Additional Board Manager URL section. This will ensure that the developer can
perform CURD (Create Update Read Delete) Operation using the NodeMCU
Development Board and also the ESP-32 Cam Module. The Data will be sent and
received from the internet in JSON format.
https://dl.espressif.com/dl/package_esp32_index.json
http://arduino.esp8266.com/stable/package_esp8266com_index.json

Figure 20: Preference Window of the Arduino IDE


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 40

• The next step is to install the board. To install the ESP8266 and the ESP32 board the
developer will have to navigate as follows:
Tools -> Board->Boards Manager

Figure 21: Tools Window in Arduino IDE

• Once the board manager was selected, the developer will see the window as shown in
Figure 22. Developer will search for “ESP-32” and “ESP-8266” and install the
respective boards with the latest version.

Figure 22: Boards Manager in Arduino IDE


• Now once the above mentioned steps are completed, the ESP-32 Wrover module as the
board which will be used, and for the ESP-8266 the NodeMCU ESP12-E was selected
as the development board.
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 41

• The following settings were selected for the ESP-8266 and the ESP-32 development
board

Figure 23: Settings Window for the two boards in Arduino IDE
• The next step is to install some libraries. These libraries can either be installed
externally by navigating as follows:
Tools->Manage Libraries

Figure 24: Library Manager Window of Arduino IDE

5.2 Flutter Setup

In the flow chart it was mentioned that the sensor data will be shown in a Mobile Application.
There are many Frameworks which are available for developing Application but for this project
Flutter is going to be used. Flutter is an open-source UI software development kit created by
Google. It is used to develop applications for Android, iOS, Linux, Mac, Windows, Google
Fuchsia, and the web from a single codebase.

The language which is used in Flutter is Dart. Dart is relatively a new programming language
but it’s very similar to languages like C, C++ and Java.
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 42

There are mainly two types of IDE which people use for using flutter: 1) Android Studio
2)Visual Code Studio

In this project Android Studio will be used as the IDE. Firstly, Developer must install the Flutter
and Dart extension in Android Studio. In order to install the plugins, developer will need to
navigate as follows
File->Settings->Plugins

Figure 25: File Manager Window of


Android Studio

Figure 26: Plugin


Manager Window of
Android Studio

After that developer must restart the Android Studio. The setup show in the above Figures is
for windows, for Mac the setup might be different.
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 43

Before restarting the Android Studio, the Flutter Software Development Kit (SDK) was
installed and the path for the Flutter Project was set.
Once the above steps waere performed, the Flutter Project was started to initialise the App
Development stage.

5.3 Firebase Setup

Earlier it was mentioned that Firebase will be used as the database service provider for this
project. All the sensors data will be updated to Firebase database and we can view those data
in our Flutter Application. Configuring Firebase with Arduino and Firebase is easy and simple
and requires only a few steps to get started. The steps for getting started with Firebase are given
as follows.
• Firstly developer must to navigate to the Firebase website and click on “Add Projects”
https://console.firebase.google.com/u/0/

Figure 27: Firebase Project Selection Page

• After clicking on “Add Projects” developer will be bought to a new page as shown in
Figure 28 where developer will be asked to add the name of the project. The name of
the project was added, and the continue button was clicked.

Figure 28: Firebase Project Creation-Naming Page


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 44

• Once the developer click on continue, developer will be navigated to the page shown
in Figure 29. In this page developer will be asked if the developer want to install Google
Analytics tool or not. The toggle button was turned as enable because in the future
“Event Based Cloud Function Triggering Function “will be needed.

Figure 29: Firebase Project Creation-Google Analytics Page

• The last step is to select the service account which developer want to use for the project.
For this case the “Default Account for Firebase was selected” and then “Create Project”
button was selected

Figure 30: Firebase Project Creation - Configure Google Analytics Page


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 45

• If the above steps are successfully executed, developer will be bought to the following
page shown in Fig

Figure 31: Firebase Project Creation -


Confirmation Page

If developer click on the project crated earlier, developer will be bought to the Firebase
Console. Here developer can see what the Firebase Services are currently that particular project
is using, how many people signed used our App, was there any crash reported in the last 24
hours etc. The picture shown in Figure 32 is the Firebase Console for our project. The name of
our project is “TESTFIREBASE”

Figure 32: Firebase Project Console


Now in Firebase there are two types of Database- 1) Cloud Firestore 2) Realtime Database. For
the Smart Fire Alarm Device, the use of the Realtime Database is encouraged since there are
only few sensors data that is needed for this project. The sensor data is stored in a No-SQL
format. The Realtime Database for this project is shown in Figure 33. As shown in the picture
the data is not stored in the Tabular Format, i.e. it is not stored in a SQL format. Now before
developer can store data in the Firebase Realtime Database, developer have to set some
Firebase Rules as true in order to do read and write operations by navigating to the Rules tab
of the Realtime Database
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 46

Now we have to configure our Firebase in our microcontroller and Application inorder to
perform the following operations:
• ESP 12-E: Perform for both read and write operations
• Flutter App- Only Perform Read Operations.

Figure 33: Firebase Realtime Database Console

Figure 34: Firebase Realtime Database Rules


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 47

5.4 Arduino – Firebase Setup

• The first step is to install the Firebase Library for Arduino. The installation can be done
as per the steps mentioned in section 5.1. Once the library was successfully installed,
the library was inclued in the code as follows:

• The next step is to declare or define the Firebase Account which a particular developer
is using and the Firebase API key in order to make read and write operations in the
Firebase Realtime Database

• The second step is to initialise the Firebase in the void setup () section of the code as
shown below.

• Once the above steps are done, the developer can perform read and write operations on
the Real Time Database using the following Arduino command

Table 20: Firebase Operations with any Arduino Compatible Board


Sl Types of Operations Commands Used to do the Operation Function
no
1 Create & Update Firebase.setInt(“<name>”,value) ; Setting an
integer
value
Firebase.setString(“<name>”,“String_Value”); Setting a
String
value
Firebase.setFloat(“<name>”,value) ; Setting a
floating
value
2 Reading Firebase.getInt(“<name>”,value) ; Getting an
integer
value
Firebase.getString(“<name>”,“String_Value”); Getting a
String value
Firebase.getFloat(“<name>”); Getting a
floating
value
3 Delete Firebase.remove(“<name>”); Removing
any data
from the
Database

5.5 Flutter – Firebase Setup


Unlike Arduino, setting up Firebase involves a lot of steps and if any of the process somehow
go wrong, it could result in messing up the entire application. The developer need to be carefull
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 48

while performing this operation. The steps which we did inorder to setup Firebase in Flutter
are given as follows.

• In the Firebase Console firstly The developer have to click on “+ Add App” icon and
after that select Android. For this assignment the IOS installtion part was skipped
because the available laptop was with Windows OS (Operating System) when the setup
was done. For setting up IOS, the developer will need to work with X-Code and X-
Code is only availavle in Mac devices.

Figure 35: Firebase Console of this Project

• Once the developer click on the Android Icon, the developer will be bought to page as
shown in Fig 36 and the developer will be asked to follow the steps mentioned in the
page inorder to setup Firebase SDK in the Android Devices. The package name for this
project is “com.dscmdis.fyp”. The package name can be found out in the App
Development File under “fyp> android> app> src> main> AndroidManifest.xml” as
shown in Fig 37

Figure 36: Firebase Android App Configuration Page


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 49

Figure 37: AndroidManifest.xml file inside the Android Studio


• For this project the App name was inputted as “fyp”. Now in the third row as shown in
Fig 36, Firebase will ask for SHA-1 certificate. SHA-1 certificate is needed for Apps
where the developer want to implement Sign In/ Login methods. For this project the
SHA-1 certificate is needed because Google Sign-In will be implemented within the
App as shown in the later part of the assignment. In order to get the SHA-1 certificate
the developer will have to open the Command prompt of windows or the terminal of
the Android Studio and type in the following
keytool -list -v \
-alias androiddebugkey -keystore %DEVELOPERPROFILE%\.android\debug.keystore

Once the developer run this above command, the developer will be asked to enter the
password. The developer can just click enter or the developer can input the password if
there is any password. Once the developer perform the above-mentioned steps, the
developer will get the SHA-1 certificate. Along with SHA-1 the developer will also get
a SHA-256 certificate. The SHA-256 certificate is even more secured than the SHA-1.
In the later part of this project need the SHA-256 certificate will be needed.

• Once the step-1 is completed, the developer will go to Step 2 of the installation process.
Here the developer will be asked to download the google-service.Json file as shown in
Fig 38. The file was downloaded and was put in the project under “fyp> android>
app>”. Once done, the developer must click on “Next” which will direct him/her to
Step-3.

Figure 38: Firebase Google Service.json download option


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 50

• In step 3, the developer will be asked to add Firebase Software Development Kit in the
App Development project file by using the following commands as shown in Fig 39.

Figure 39: Firebase SDK configuration option with Android


• Once the developer perform the above steps, developer will need to run the App by
clicking on the run option of Android Studio and for the Firebase side the developer
have to press “Sync now” option and then click next. Firebase will verify if the app is
successfully authenticated to the Firebase Server or not. The verification process will
usually take around 10-15 minutes. Once the App authenticates with the Firebase
Server, the developer will get the following message as shown in Fig 40 and the
developer will have to click on the “Continue Console”

Figure 40: Firebase-Android Successful Configuration Confirmation Message


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 51

• Now earlier it was mentioned that the SHA-256 key will be used for the App to be safe
from unethical hackers. In order to do that the developer will have to navigate to
Firebase Settings from our Firebase Console. The SHA-256 key was added under the
“Your App” card. In this report the key is not shared because it is private and
confidential.
• The next step which the developer needs to perform is to import the Firebase packages
which will be needed while developing the App. In order to add packages developer
will need to navigate to pubspec.yaml and add it into the dependencies section of the
“pubspec.yaml” code. “pubspec.yaml” is the file for the App Development project
where the developer adds the list of packages, list of files or assets which the developer
wants to use in the project. The format for adding the package is given as follows:
Name_of_package: <Version_of_the_package>

If the version of page is not mentioned, Flutter will assume that the developer want to
install the latest packages for our project. Once the package name was added and the
“Pub get” option was selected. After that Flutter will install the packages.

Figure 41: pubspec.yaml file of the Flutter Project


5.6 Arduino Code

This is section covers all the necessary steps and the code needed for the ESP-32 and the ESP-
8266 work smoothly and efficiently with the devices and the sensor. In the first section, the
ESP-32 cam code is shown and explained. In the second section the code for the ESP-8266 is
shown and explained. The coding for both modules are equally important, and a wrong
connection or code will result in affecting the entire circuit, and the worst-case scenario will
be the components to blow up.
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 52

5.6.1 ESP8266 coding


Before the start of this section it is assumed that the reader have already followed the steps for
setting up the Arduino IDE for making it compatible with ESP-8266 in Section 5.1. All the
fire detecting sensor and devices i.e. TFT display and the buzzer are connected with the
NodeMCU V3 development board as per the circuit shown in Figure 17. Once the circuit is
completed the following coding steps are followed to get the display working.

• Firstly, the developer must import the following libraries shown in Fig 42 to make the
ESP8266 compatible with Firebase Wi-Fi and the internet. (In Arduino “//” are used to pass
comments. This makes the programme readable and understandable for other developers
or users. During compilation of the programme, the compiler understand that double slash
indicates a comment and does not executes the commented statement.)

Figure 42: Imported Libraries


• The second step is to define and declare the pins the modules and the sensors are using or
pins which are connected to the NodeMCU development board. Developer or electronic
designer can connect the modules Digital or Analog pins to any of the Digital and Analog
pins of the NodeMCU development board. However, if different pins are used, the
declaration of the pins must be done correctly. Although pin number “D4” of the
development board should be avoided because it is attached to the inbuilt LED of the
development board.

Figure 43: Variable declaration and definition


• All Arduino programmes have two syntaxes or inbuilt function which all the developer
needs to follow. Without putting the two functions, the Arduino code will not be executed,
and the compiler will throw an error.
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 53

The first function is the “void setup ()” function. Within this function if a developer or an
electronic designer wants to execute a respective task only a single time, the developer
write their code with the curly braces of the void setup function. For example, if a device
needs to be turned on or initialised at the beginning, all the necessary commands for turning
on the device must be written within the setup function
The second function is the “void loop ()” function. If the electronic devices or modules
needed to be run repeatedly, then the developer must write their code within the loop
function. For example, a sensor need to gather and compare old data throughout the time
interval when the sensor is active, all the necessary commands for performing this case
must be written within the setup function.
• The following commands were used in the void setup () function. The explanation of all
the command used are given as follows:
Table 21: Explanation of the Commands used in void setup () function
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 54

• The setup code for the Fire Alarm Device is given as follows

Figure 44: Code inside void setup () function


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 55

• The “wifiConnect()” function is a developer defined function of type void (non-return type)
whose task is to initialise the Wi-Fi connection between the ESP8266 12-E and the Wi-Fi
source. If suppose there is any error during connection with the Wi-Fi, the ESP8266 will
again try to connect with the Wi-Fi source and the number of connection attempts will be
printed in the Serial Monitor of the Arduino by using a simple “while loop”. Once the
connection is successfully established, the IP address will be printed along with other
characters in the Serial monitor. The code for the function is given as follows:

Figure 45: Code of wifiConnect () Function


• The last and final step is to pass the necessary commands and arguments in the “void
loop()” function. As discussed earlier if the code is needed to be executed repeatedly for
cases like gathering and updating the sensor data etc, in those scenarios the developer must
write the necessary commands within the void-loop function.
• In the void loop function, firstly the DHT11 sensor’s gathered values (Humidity and
Temperature in Fahrenheit & Celsius) will be copied to “humidity, temperature_F,
temperature” respectively. The copied variables are of type “float”. The gathered data will
then be uploaded and updated to Firebase Realtime Database during each execution of the
loop function.

Figure 46: DHT-11 temperature sensor reading declaration and code for updating data on Firebase Database
• Like the DHT11 sensor, the MQ-2 sensor’s gathered values (LPG CO & Smoke) will be
copied to “lpg, co, smoke” respectively. The copied variables are of type “float”. The
gathered data will then be uploaded and updated to Firebase Realtime Database during each
execution of the loop function.

Figure 47: MQ-2 Gas sensor reading declaration and code for updating data on Firebase Database
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 56

• The gathered data will be shown in the TFT Display with various background colours and
text colours. The code used to achieve this is shown below.

Figure 48: Code for TFT Display in void loop () function

• The next step is to have a logic where the Flame Sensor will detect if there is a Flame or
not in the Flame Sensor’s range. If there is Fire or flame detected, the buzzer will be
activated, and the data will be sent to Firebase. After that Firebase will oversee sending the
push notifications or Alert Messages to developer (this part will be discussed in the later
part of the report). If there is no fire or flame detected, the buzzer will not be activated, and
the notifications will be not be triggered by Firebase. Fortunately, an if-else statement will
be used to solve the issue.
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 57

Initially the Digital pin of the Flame sensor was set to “HIGH” and since the pin is digital,
it can only take two value which are “HIGH” or “LOW”. Now whenever there is a Fire,
the Boolean variable “Flame” will change to “LOW” and the buzzer will be activated in
different tones along with a Firebase push notification will be tiggered to the developer
otherwise the buzzer will not be activated and the “Flame” will change to “HIGH”. During
execution of the code, it will also be checked whether the ESP8266 12-E is connected to
the Wi-Fi source or not. If the device is not connected with the Wi-Fi, then the
“wifiConnect()” function will be called again. The code for achieving the above scenarios
is given as follows:

Figure 49: IF-ELSE statement in the void loop () function


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 58

Code 1: Arduino Code for ESP-8266


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 59
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 60
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 61
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 62

5.6.2 ESP-32 Coding


Before the start of this section it is assumed that the reader have already followed the steps for
setting up the Arduino IDE for making it compatible with ESP-32 in Section 5.1. Once the
ESP-32 board was installed in the Arduino IDE, some examples related to ESP-32 cam module
is also installed along with it. In those examples, one of the examples shows the code for the
ESP-32 cam module. To access that code, the following steps must be followed.

• Firstly, the following option must be selected “File> Examples > ESP 32> Camera>
Camera Web Server as shown in Fig

Figure 50: Camera Web Server Example Sketch


• Once the above option is selected, the following files will load in a new Arduino IDE
window as shown in Fig 51

Figure 51: Camera Web Server Project Tabs

• Once the files are loaded, the developer will need to edit few lines of code of the
“CameraWebServer.ino” file. The first step is to define the model name of the camera
which is currently in use. For this case, the module which is in use is a
“CAMERA_MODEL_AI_THINKER”. So that’s why line number 14 of the Code given
in Fig 52 was uncommented.

Figure 52: Line number 14 of Camera Web Server Example


• The next step is to declare the Wi-Fi address and password in line no 18 and 19 of the Code
given in Fig 53. Due to security reason, the Wi-Fi SSID and password is not shown below.
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 63

Figure 53: Line number 18 and 19 of Camera Web Server Example


• The next step is to upload the edited code into the ESP-32 module. Before uploading the
code, the General-Purpose Input/Output Pin 0 (GPIO 0) must be connected to the ground
as shown in Fig 18 (left).
• Once the code is uploaded the GPIO
0 pin was disconnected from the
Ground and the reset button of the
ESP-32 cam module was pressed.
• Once the reset button is pressed, the
serial monitor for the Arduino was
opened to obtain the IP address of the
Live Streaming.
Figure 54: Generated IP Address in the Arduino Serial Monitor

• The IP address was copied and pasted in a secured browser window. The browser will
display the ESP32 camera playground console. There are multiple services like Face
Recognition, Image Resolution selection etc. For this project only real-time video
streaming is required. In the later part of this report, ways of displaying the camera
playground console in a mobile application is discussed.

Figure 55: Web Page for live streaming from the ESP 32 Camera Module
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 64

Code 2: Arduino Code for ESP-32 Cam Module


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 65
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 66

5.7 Flutter Code

In this section the code structure of the Flutter Application is going to be explained. Within the
mobile application the following things will be implemented:
• Google Sign In / Log In
• User can view the data gathered by the sensor in a nice animation format.
• In case there is a Fire, a push notification will be sent to the developer’s phone.
• User can also view the live recording from our
application.
Before going into the main section of the code it is always a
good idea to know the structure of the Flutter code, so it is easier
for other the developer to understand the code who is viewing
the application for the first time.

In Flutter all the code is written in the “lib” folder for this
project. The file which is executed in the lib folder is called the
“main.dart” file. The “main.dart” file can have multiple widgets
or file linked to it. Figure 57 shows an example of a basic
structure of a Flutter project.
Figure 56: Project Files for developing
the Flutter Mobile Application

Figure 57: A typical project structure of a Flutter Application


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 67

5.7.1 main.dart File (Path: fyp>lib>main.dart)

• The code shown in Code 3 is the code for the main.dart file.
• In Line no 1 and 2 the packages were imported which will be needed in the main.dart
file. The first one is the “material.dart” package which will be imported in almost all
the files involving widgets operation. The second one is not a package, it is actually file
which is created created that will display the Login Page of the App.
• In Line no 4, the Debugger is told to run the file whose name is “My App” within the
void function
• From Line no 6 to Line 14 it is declared that the “Main App” file is a stateless widget
and the Main App is toled to return a Material App whose home is the “Login Page”
Widget. The debugShowCheckedModeBanner is set to as false because the debug
banner should not be dispalyed to the developer or user.

Code 3: Code for main.dart file

5.7.2 LoginUI.dart File (Path: fyp>lib>SignInWithGoogle >LoginUI.dart)

• The code shown in Code 4 is the code for the LoginUI.dart file.
• The code written within this file will display the Login Screen of our App. When a
developer opens the application, in the beginning the developer will be bought to the
Login Screen.
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 68

• Before starting to code the developer must enable Google Sign In from the Firebase
Console. This will enable the use of Google Sign-In method for the application as show
in Figure 58.

Figure 58: Firebase Authentication Web Page

• From Line no 1 to 7 the packages and files were imported which will be used for this
code.
• From Line no 9 to 12 it is declared that the “LoginPage” will be a stateful widget. In
Flutter the developer have to specify the types of widget as stateless or stateful. Stateless
widget are widgets whose UI changes e.g. if a developer wants to have scrolling action
within there App, then Stateful widget will be used. Stateless widget are used when the
state of that UI doesnot change e.g. if a developer wants to display a picture within the
App, then a Stateless Widget will be used. The usage of this widgets varies for different
cases. A developer will decide the type of widget to use for this various cases
• From Line no 14 to 70 it is defined to extend the
stateless widget. Here a logic is defined for generating
push notifications within the App. Push notification
are required inorder to notify the users in case of a
Fire. In later part of this report a Cloud Function will
be written in JavaScript which will be incharge of
generating push-notification in case there is a fire.
• From Line no 72 to 181 is the logic behind display of
the UI. Here a developer will define how he/she wants
to view the Widgets. The picture shown in Figure 59
shows the widget tree off the project. This is an
excellent service by Android Studio where a
developer can view the Widget Tree which makes it
easier for a developer to change and debug the code if
needed. Scaffold, Container, ListView , Sized Box etc
are the different types of Widgets which Flutter
provides. Each of this widget as different
functionalities. Stateful or Stateless widget are the
parent widgets and ListView, Container etc. are the
child widgets. Figure 59: Widget Structure for
LoginUI.dart code
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 69

Code 4: Code for LoginUI.dart file


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 70
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 71

5.7.3 authentication.dart File (Path: fyp>lib>SignInWithGoogle >authentication.dart)

• The code shown in Code 5 is the code for the authentication.dart file.
• The code written within this file is the backend logic for Login UI file. This is the
file where the authentication logic for the Google Sign In along with Firebase is
defined.
• If the user authenticates successfully, user will be navigated to the “MainSection”
page of the Application.
• From Line no 1 to 3 the packages and
files were imported which will be used
for this code.
• From Line no 5 to 9, the name of the
parameters of the function were
declared.
• From Line no 11 to 51, the
authentication logic and data which
will be collected from the
authentication like Profile Image,
Name, Gmail-Id is defined.
• From Line no 53 to 57, the Google
Sign-out logic is defined. The picture
shown in Figure 60 shows the code
structure of this file. Figure 60: Widget Structure for
authentication.dart code
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 72

Code 5: Code for authentication.dart file


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 73

5.7.4 Main_Section.dart File (Path: fyp>lib> Main_Section.dart)

• The code shown in Code 6 is the code for the Main_Section.dart file.
• The code written within this file defines the basic
layout for our Application i.e. App Bar & Bottom
Navigation Bar. Once the user successfully Login to
the App, user will land into this Main Section Page
• If the user authenticates successfully, user will be
navigated to the “MainSection” page of the
Application.
• From Line no 1 to 5 the packages and files were
imported which will be used for this code.
• From Line no 7 to 12 it is declared that the
“MainSection” will be a stateful widget.
• From Line no 13 to 104, the UI of the App is defined
or specified. In this section the pages which the user
is going to see if the user clicks on any of the button
is also specified.The picture shown in Figure 61 Figure 61: Widget Structure for
shows the code structure of this file. Main_Section.dart code

Code 6: Code for Main_Section.dart file


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 74
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 75

5.7.5 First_Screen.dart File (Path: fyp>lib>SignInWithGoogle >First_Screen.dart)

• The code shown in Figure 62 is the code for the


First_Screen.dart file.
• The code written within this file will show the
profile of the user who signed into the application.
Profile picture, name and Email-Id of the user will
be displayed in this page along with the Sign-out
button.
• From Line no 1 to 3 the packages and files were
imported which will be used for this code.
• In Line 5, it is defined that the widget “FirstScreen”
is a stateless widget
• From Line no 6 to 86, the UI of this particular page
is defined.
• The picture shown in Figure 62 shows the code
Figure 62: Widget Structure for
structure of this file. First_Screen.dart code

Code 7: Code for First_Screen.dart file


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 76
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 77

5.7.6 dht.dart File (Path: fyp>lib> dht.dart)

• The code shown in Figure 63 is the code for the dht.dart file.
• In this section a class is written and it is named as “DHT”. In this class the variables
are defined which will be fetched from Firebase in JSON format. There will be four
variables returned for this DHT class which are
1) Temperature in Celsius scale
2) Temperature in Fahrenheit scale
3) Humidity
4) Heat Index
• The Heat-Index will not be shown within
the App. However heat index will be
declared otherwise it will mess up the
Firebase Logic
• The picture shown in Figure 63 shows the
code structure of this file. Figure 63: Widget Structure for dht.dart code

Code 8: Code for dht.dart file


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 78

5.7.7 MQ2.dart File (Path: fyp>lib> MQ2.dart)

• The code shown in Code 9 is the code


for the MQ2.dart file.
• In this section a class is written and it
is named as “SmokeSensor”. ”. In this
class the variables are defined which
will be fetched from Firebase in JSON
format. There will be four variables
returned for this class which are
1) Carbon Monoxide Value in ppm
2) LPG Value in ppm
3) Smoke Value in ppm
• The picture shown in Figure 64 shows
Figure 64: Widget Structure for MQ2.dart
the code structure of this file. code

Code 9: Code for MQ2.dart file


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 79

5.7.8 Temperature.dart File (Path: fyp>lib>Sensor >First_Screen.dart)

• The code shown in Code 10 is the code for the Temperature.dart file.
• The code written within this file will show data gathered from the Firebase Real
Time Database which is gathered from the DHT11 sensor.
• From Line no 1 to 4 the packages and files were imported which will be used for
this code.
• From Line no 6 to 9 it has been declared that the “SinglePageApp” will be a stateful
widget.
• From Line no 11 to 20, the varibles were
declared and the Stateful Widget was
told to return another Function which is
of type Widget which is named as
“mainScaffold()”.
• From Line no 22 to 48, the code for the
“mainScaffold()” function is written.
Here the the logic on what the user is
expecting to return and what will the
function return if a certain condition is
not met by the implementation of a
simple “If-else” statement. In the
statement again another function is
returned of widget type whose name is
“_temperatureLayout()”.
• From line 51 to 147, the
“_temperatureLayout” function is
defined. This is the function which
specifies the UI for this particular page
i.e. the types of animations and the format
in which the users will be able to veiw the
DHT-11 sensors data is specified.
• The picture shown in Figure 65 shows the
code structure of this file. Figure 65: Widget Structure for
Temperature.dart code

Code 10: Code for Temperature.dart file


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 80
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 81
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 82

5.7.9 Smoke.dart File (Path: fyp>lib>Sensor >Smoke.dart)

• The code shown in Code 11 is the code for the Smoke.dart file.
• The code written within this file will show data gathered from the Firebase Real
Time Database which is gathered from the MQ2-Smoke sensor.
• From Line no 1 to 4 the packages and files were imported which will be used for
this code.
• From Line no 6 to 9 it has been declared that the “Smoke” will be a stateful widget.
• From Line no 11 to 16 the
varibles were declared and the
Stateful Widget was told to
return another Function which is
of type Widget which is named
as “SmokeValue()”.
• From Line no 18 to 47, the code
for the “SmokeValue()” function
is written. Here the the logic on
what the user is expecting to
return and what will the function
return if a certain condition is not
met by the implementation of a
simple “If-else” statement. In the
statement again another function
is returned of widget type whose
name is “_smokeLayout()”.
• From line 48 to 107, the
“_temperatureLayout” function
is defined. This is the function
which specifies the UI for this
particular page i.e. the types of
animations and the format in
which the user will be able to
veiw the MQ-2 sensors data is
specified.
• The picture shown in Figure 66
shows the code structure of this
file.

Figure 66: Widget Structure for Smoke.dart code


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 83

Code 11: Code for Smoke.dart file


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 84

5.7.10 Camera_Webview.dart File (Path: fyp>lib>Sensor > Camera_Webview.dart)

• The code shown in Code 12 is the code for the Camera_Webview.dart file.
• The code written within this file will show the Web Page for the ESP32-camera
module.
• From Line no 1 to 3 the packages and files were imported which will be used for this
code.
• From Line no 5 to 8 it has been declared that the “CameraView” will be a stateful
widget.
• From line 10 to 24, it has been defined
the functionality and the type of widget
“CameraView” is going to return. For
this case it is a “WebView” widget to
simply display the web page given in
Figure 55 in the mobile application. The
JavaScript mode was set as unrestricted
to avoid the “JavaScript Disabled” Error
Message while users opens the App.
• The picture shown in Figure 67 shows the
code structure of this file. Figure 67: Widget Structure for
Camera_Webview.dart code
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 85

Code 12: Code for Camera_Webview.dart file

5.8 Alerting System


Now in case there is a fire and suppose the user is not within the close proximity of the Fire
Alarm Device, then it might lead to greater destruction and damage. To avoid that problem,
Firebase Cloud Messaging can be used. Whenever there is a fire, Firebase will send push-
notification to the mobile applications. In order to send Firebase push notification to the
developer’s mobile phone, the developer will need to write Firebase Cloud Function using
JavaScript or TypeScript. Before writing the function messaging Node.js needs to be installed
by the developer from the official “NodeJS” website.

Figure 68: Download Page of NodeJS


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 86

Once “nodeJS” is installed in the system, the developer will need to open command prompt
and install the Firebase tool kit for publishing and writing the Cloud Function. The steps needed
to be followed for initialising, writing, and publishing the Cloud Function are given as follows:
• The following command needs to be used for installing the firebase tool kit in the local
computer:
npm install -g firebase-tools

• The next step is to initialise the firebase in the local device:


firebase init

• Once the Firebase is initialised, the developer will be asked to confirm whether he or
she wants to proceed to the next step or not. The developer must type “Yes” to proceed
to the next steps.
• Once proceeded the developer will be asked to select the Firebase services which the
developer needs to be used. For writing Cloud Function, the following option was
selected.
( ) Functions: Configure and deploy Cloud Functions

• Once the developer selects the above option, the developer will be asked to select the
language which they want to code with. Currently there are only two languages which
are available for writing Firebase Cloud Function. The languages are -1) JavaScript 2)
TypeScript
For this project JavaScript was used as the language for writing Cloud Function.
• After selecting JavaScript as the language for writing the Cloud Function, The
developer will receive the following confirmation question:
Do you want to use ESLint to catch probable bugs and enforce style?

• The developer must type in “Yes” to create the “index.js” file and other types of
JavaScript File which will be required for write the Cloud Function.
• After the files are created, the developer will receive the following confirmation
question:
Do you want to install dependencies with npm now?
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 87

• Developer must type in “Yes” to install the Node.JS dependencies. Once installed, the
developer must navigate to the file where they have created the folder for writing the
Cloud Function. The folder must be opened in IDE’s which are JavaScript compatible
like Visual Code Studio IDE or
Android Studio etc. For this project
Android Studio will be used. After
opening the Folder for writing the
Cloud Function, the developer must
navigate to the “index.js” file. This
is the file where the developer will
write the Firebase Cloud Function
for sending Automated push
notifications to the developer
whenever there is a fire.
Figure 69: File Structure of Firebase Cloud Function

• The code for the index.js file is shown in Code 13


Code 13: Index.js code for Firebase Cloud Function

• From line no 1 to 3 is the function and initialiser which is set by Firebase. It is


recommended by Firebase that the developer must not edit the code in Line no 1 to 3
until and unless it is deemed necessary.

• Earlier in the earlier section it was discussed that when the flame sensor detects a flame,
the variable “FIRE” in the Firebase Realtime will be updated to 1 and if there is no fire
detected the Firebase Realtime database will be updates to 0. The logic which is created
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 88

for this project is that whenever the variable “FIRE” is updated to 1 or 0, the Cloud
Function will get triggered and Firebase will send a Firebase Push Notification to the
user’s device through the application created earlier.

• In Line no 5, the function was named as “fire”. The variable is “FIRE” and it was
specified that the Cloud Function will be activated whenever the value of “FIRE” is
updated. Other types operations involve “read”, “write”, and “delete” can also be
specified.

• From Line no 6 to 13, the description of the notification is given. The “title” is the
heading of the notification. The term “body” is what comes below the heading or the
main message. The “badge” is the number which will be displayed on the App Icon
(available only for Android OS for version above 8.0). The “sound” is the sound in the
device when the notification arrives.

• From line no 15 to 24 is the is the logic for getting the Firebase Cloud Messaging Token
and printing a message in the console along with an inbuilt function for sending the
Firebase Push notification to the developer device. Now there could be certain times
when there could be a glitch, if anything like that happens then an error message will
be printed in the console.

• Once the coding is done, developer will need to open the Command Prompt again or
the terminal of the respective IDE and will need to type the following command to
deploy the Cloud Function on Firebase.
firebase deploy

• Once the function is deployed, a message will be shown in terminal as shown in Figure
70 and the function will be deployed on Firebase as shown in Figure 71

Figure 70: Terminal Message after the deploy of Firebase Cloud Function
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 89

Figure 71: (Top) Firebase Function named as “FIRE” deployed in Firebase,


(Bottom) Firebase Cloud Message Statistics
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 90

5.9 Design and Casing

The last and final stage is to design a casing where the circuit shown in Figure 17 &18 and the
electronic devices discussed in the earlier sections of the report could fit in together. The aim
before designing the casing was that the 1) Design should be made as small as possible 2) The
device should be handy and carried and can be installed anywhere by the user.

There are multiple 3D CAD software which are available


in the market and it is up to the product designer to select
the designing software. However, for this project
“SOLIDWORKS” was used as the designing software for
designing the casing. Figure 72: Logo of Solidworks

The designing stage was divided into three stages. The first two stages were designing the two
parts 1) static part 2) movable part. The third and final stage of the design is the assembly stage
where mainly the interference between the movable part and the static part was tested before
3D-printing the two parts which are designed earlier.

5.9.1 Static Part

This part is the main part or the main body of the casing. This part is the part where all the
sensors i.e. MQ-2 Gas Sensor, DHT-11 Temperature Sensor, Flame Sensor & the electronic
devices i.e. Camera, TFT Display, Buzzer, ESP-32 camera module, FTDI Programmer, NODE
MCU 3 Development board will be attached. The aim before designing was to make the design
as small as possible without damaging the sensor or the
electronic equipment.

Before moving onto designing of the static part, the


measurement of the length, width, height for the sensor was
measured using a ruler. The measurement was not 100%
accurate, so a rough estimation was made. Solidworks offers
various tools when it comes to product designing.
However, for this design only the following design tool was
used, which are defined as follows:
• Sketch: The option allows product designer to do a 2D
sketch on a plane or on a 3D object.
• Dimension: The feature allows to insert dimension to
a shape in the 2D sketch or a 3D-design.
• Boss-Extrude: This is a feature that allows a products
designer to make a 2D-Sketch into a 3D Design.
• Cut-Extrude: This is a feature which allows a product
designer to cut a 3D object from a 2D sketch
Figure 73: Tools used for
designing the Static Part
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 91

• Fillet: This is a feature that allows a product designer to include circular curves
especially at the edges of their 3D object. The feature is also available for 2D-sketches
as well.

The design was initialised by doing a simple rectangular box of the following dimension -
50mm(width) * 100mm(length) * 69mm(height). Once the rectangular box was designed, there
were various cut-outs which were made in order to accommodate the sensor and devices in a
single box. The final box have a wall thickness of 2mm, and the base had a thickness of 5 mm.
The design was done in such a way that the sensors and the ESP-32 cam module will be
attached at the front of the casing. The TFT display and the buzzer will be placed at the top of
the casing. The microcontroller, FTDI Programmers and the wires will be placed inside of the
casing and this will be only partially visible. The four-sectional view for the casing is shown
in Figure 74

Figure 74: Four Sectional Views of Static Part


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 92

Figure 75: Isometric View of the Static Part

5.9.2 Movable Part

This is the part which will be movable and will be assembled at the back of casing. The part
was designed in such a way that it will fit into the slots
designed at the back of the Static Part. The tools used for
designing this part is like the tools used for designing the
Static part. There is only one extra tool which was used
during the design of the movable part. The tool which
was used is defined as follow:
• Linear Pattern: If a product designer want to
replicate a particular design or object on a straight
line by taking reference to a particular sketch or
object, then the product designer can use the tool
to reduce the designing time and increase the
overall time efficiency.
Figure 76: Tools used for
designing the Movable Part

The design was initialised by doing a simple rectangular object of the following dimension -
2.5mm(width) * 97.50mm(length) * 75mm(height). Once the rectangular object was designed,
there were various circular cut-outs which were made using “Extruded-Cut” and “Linear
Pattern” for cooling purpose. All electronic devices will have some heating effect and heat
needs to be dissipated. The holes were done for the electronic device to dissipate the heat in
the air. The two-sectional view for the casing is shown in Figure 77.
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 93

Figure 77: Two Sectional Views of the Movable Part

5.9.3 Assembly Stage

The last and final step is the assembly stage. This is an excellent feature which is provided by
Solidworks, where product designer can perform a virtual assembly and simulate it. This will
allow the product designer to understand if there is any interference between any parts before
the manufacturing and the physical assembly of the product. The tools which were used as
follows:

• Coincident mate: Positions selected planes, edges, and faces on the same infinite plane.
If the two vertices are chosen then it will position them so that they touch.
• Limit-Distance mate: Add a limiting distance between components by giving it a
maximum and minimum distance between
components faces, edges, or planes
(Unspecified, 2014). In this assembly, the
maximum distance until which the movable
part can slide from the static part was added
as 80mm and the minimum distance was
added as 0mm.
The interface between the static and movable part
was tested and no interferences was detected after
the virtual assembly. Figure 78: Tools used for doing
the assembly in Solidworks
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 94

Figure 79: Isometric View of the Assembly

Figure 80: No interferences detected during the Assembly

5.10 3D- Printing


The next step is to 3D print the casing. The material which will be used for 3D printing the
casing is called PLA. The diameter for the PLA which will be used is 1.75mm. There are also
other diameter PLA filaments which are available in the market, it depends on the
manufacturer on what size they want to use. The machine which will be used for 3D printing
is a Creality CR-10 (2016). Now before 3D printing the casing, some setups which will be
needed to be followed.

• First of all the SolidWorks file which is in “.SLDRT” format must be converted into a
“.STL” file. This can be done so by saving the file in “.STL” file or else using various
websites available for conversion from “.SLDRT” to “.STL” file.
• Once the above step is completed, a software named as “Cura” will be opened. “Cura”
is a software which allows manufacturer to set and edit certain 3D-printer machine
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 95

settings. The software is compatible with Creality CR-10 and these is one of the main
reasons why Cura should be used for changing the print settings.
• Once the software is opened in the local device, the “.STL” files will be imported.
There are two files and for both files are loaded in two separate windows because the
print setting was different for two of the files.
• Static Part:
There are many machine settings which are available in Cura. Each of the settings
affect the print quality, time, and overall cost & efficiency. For this part, the following
settings was adjusted:
o Infill percentage %: The infill percentage is the measure of by how much
percentage the material is fully solid. For this design, the infill% was set to
10% which means the static part is 10% solid and 90% hollow.
o Profiles: The profile was set 0.2 mm. This setting affect the accuracy of the
print. For more accurate measurement the profile should be set to a lower
number.
o Support and Adhesion: The support was enabled since there are some holes
or an hollow part in the design. For certain design, there could be a part which
has a large empty gap or separation in it. Enabling supports creates a
temporary support to the design. These supports can later be removed by hand
or by the application of certain tools.
Adhesion is required for the 3D printer where the base of the design is not
sticking to the bed of the 3D printer properly. Since a transparent glass bed
was used on the day of the printing and glass is slippery, so enabling the
Adhesion helped the design to stick properly to the bed during printing.
The next step is to click on the “Slice” option to see the estimated time and the percentage of
materials used. It was found out that the static part takes around 8hours and 6minutes to print
and takes around 55gm of PLA.

Figure 81: Static Part imported in Cura


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 96

• Movable Part:
For the movable part the following settings were adjusted:
o Infill percentage %: The infill percentage was set to 100%
o Profiles: The profile was set 0.2 mm.
o Support and Adhesion: The support was disabled, and the adhesion was
enabled.
It was found out that the movable part takes around 2hours and 59minutes to print
and takes around 17gm of PLA .

Figure 82: Movable Part imported in Cura

The next step is to 3D-print the design. This can be done either by either connecting the local
device with the 3D-printer or using an SD card to export the design. Firstly, the bed and the
extruder will heat until 50 C and 200 C respectively and once the temperature is reached, the
rest is the machine job for 3D-printing the design. The code which the machine uses for
interpreting the “.stl” file is called as “G-CODE”.

Figure 83: 3-D Printer


printing the movable part
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 97

6. RESULTS AND DISCUSSION

6.1 First Test Run

Firstly, the circuit shown in Figure 17 and 18 was implemented over a breadboard and was
tested. Due to the ongoing Covid-19 pandemic electronic equipment like buzzer and the TFT
display did not arrive during the time when the circuit shown in Figure 84 was constructed.

Figure 84: Circuit of the First Test


Now firstly the MQ-2 gas sensor and the flames sensor must be calibrated. Now it is difficult
to produce a mass scale-controlled fire and it should not be done until and unless the lab is
certified for Fire related experiments. Instead an incense stick was used for making the smoke
and the flame. There is an inbuilt LED soldered along with the board for the two sensors,
respectively. The knob of the potentiometer attached along with the PCB board was turned
until the LED of the sensors change its states from “OFF” to “ON”
whenever there is a Flame detected. Once that has been done the overall
latency or the time taken by the ESP8266 12-E to upload the data to
Firebase Realtime Database was tested. The latency depends on the speed
of the Internet Connection. It was tested that during the day of the 1st Test
the Latency was found out to be around 0.5 seconds.

For the ESP-32 cam module, the speed and the video quality was mainly
tested. Now since the camera price is quite low, so developer should not
expect it to live-stream FHD or HD quality video. There are multiple
options for the quality from the live-streaming video which are available
for the developer. The quality ranges from QQVGA(160*120) to
UXGA(1600*1200). For faster streaming and better video quality the
cam module is recommended to run at XGA (1024*768).
Figure 85: Camera Page of the App
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 98

6.2 Second Test


The second test was performed with the buzzer and the TFT display attached with the
breadboard and the ESP8266 12-E. In this test the animation of the TFT display and the sound
of the buzzer was tested at different frequencies which is given as input in the “tone” function
of the Arduino Programme. It was found out that the buzzer beeping is louder when the
frequency is set to 2000Hz. A n-p-n bipolar junction transistor can also be used to increase the
noise or the input voltage can also be increased to make the buzzer beeping noise louder.

For the TFT display, the following things were tested:


• Alignment of the text
• Size of the text
• Text Colour
• Background Colour
• Delay in displaying the text and background colour.
The circuit for the 2nd test is shown in Figure 86.

Figure 86: Circuit of the Second Test


6.3 Mobile Application Testing

In this test the UI and the latency for updating the sensor data in the mobile application was
tested. The codes which were involved for creating the mobile application is shown in Section
5.7. During the test it was found out that it took only around a maximum of one second for the
Data to get updated in the Mobile Application. The overall Application structure is shown in
Flow Chart-2.
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 99

Flowchart 2: Mobile App UI Flow Chart

User will click on the icon User will click on “Sign in with User will select the Google
labelled as “fyp” to enter the Google button” Account they wish to login with.
Mobile Application Code Involved: main.dart, Code Involved:
LoginUI.dart authentication.dart

Once the user is User can see the temperature User can see the smoke, CO User can see the live stream
authenticated, the user will and humidity value sensed and LPG value sensed by the captured by the ESP-32
be bought to the home page by the DHT-11 sensor by MQ-2 Gas sensor by cam module by clicking on
of the App. User can either navigating to the navigating to the Smoke the Camera View Page.
Sign Out by clicking on Temperature Page. Sensor Page. Code Involved:
“Sign Out” button or can Code Involved: Code Involved: Smoke.dart, Camera_Webview.dart,
navigate to other pages. Temperature.dart, main_Section.dart, MQ2.dart main_Section.dart
9.4 Casing
Code Involved: Im main_Section.dart, dht.dart
main_Section.dart,
First_Screen.dart
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 100

6.4 Casing Implementation


Now leaving the circuit as shown in Figure 86 is all right but when it comes to appearance,
selling of the product and safety, it is not at all practical. To overcome these issues, in the
earlier section it was discussed on the techniques and ways to design the casing. Now there are
multiple ways to manufacture the casing show in Figure 79. However, in this report the
manufacturing techniques are not discussed, since it is out of the scope for this particular
project.

The design for the casing discussed in Section 5.9 was manufactured using 3D printer. The
type of manufacturing for the casing is called an “Additive Manufacturing” where materials or
the ingredients are added from ground bottom to create a part of given shape and sizes. The
total weight for the casing was found out to be only 50gm. Once the casing was manufactured,
the sensors and the electronic equipment or devices were assembled using adhesives. After
putting the equipment in there respective slots of the casing, the wires were connected with as
per the circuit shown in Figure 17 & 18. Mostly male-female or female-female jumper wires
were used during the connection. After the assembly was done, the weight of the casing was
measured again, and it was found out to be only 72 gm. At the end, the movable part was put
at the back of the casing. The following picture shows the casing, and the two circuits shown
in Figure 17 & 18 implemented inside the casing.

Figure 87: Front View


of Casing

Figure 88: Side View of


Casing (Right)
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 101

Figure 89: Back View


of Casing

Figure 90: Side View of


Casing (Left)

Figure 91: Top View of


Casing (Left)
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 102

6.5 System Test within the Casing


In this test, the ESP-8266 and ESP-32 camera module was powered up to check if the system
is giving accurate readings or not. This was done after the circuit was put inside the casing.
Initially all the sensors were giving accurate readings except the MQ-2 Gas sensor. Later it was
found out that the some of the jumper wires was touching one of the legs of the sensor.
Although the jumper wires were insulated but due to this issue the sensor was giving faulty
readings. The problem was fixed and later it was found out that the sensors reading were
accurate and devices were working perfectly fine.

Figure 92: Sensors Tested with incense stick

Figure 93: Sensors Tested with the use of lighter


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 103

6.6 Alerting System Test


This is the final test for the DIY Fire Alarm Test and it is one of the most important test that
all the manufacturers need to perform before issuing the certificate for commercial and
domestic use and releasing it into the wholesale market. Now during the test, there was no labs
available which were certified to produce and deal with mass scale fire. Instead a Plastic Spark
wheel Lighter was used to produce a flame. During the test it was found out that the flame
sensor took around 5s to detect the flame, switch on the buzzer and trigger the Firebase Cloud
Function which will in turn send notification to the Flutter Application. The reason for the
delay might be due to the fact due to the execution time of the void loop() function. The other
reason might be the speed of the Internet on the day of the testing.

Figure 94: Push Notification send to user device once a Fire is detected
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 104

7. CONCLUSION

7.1 Troubleshooting
Now all devices and system have some inaccuracy and disadvantages. An engineer cannot
completely get rid of the problem but can minimise the inaccuracy through various techniques
to get accurate readings. The table shown below are some of the things which an engineer,
designer, developer or an user might encounter, and the steps required for overcoming those
problems:
Table 22: List of troubleshooting methods
Sl no Problem Statement Reason Solution
1 Buzzer and Firebase Flame sensor gets activated In order to avoid the
Cloud Function getting when it detects Infrared false alarm, the
activated when the radiation from the Fire. potentiometer will be
device is kept under Sunlight also emit Infrared needed to be calibrated
direct sunlight Radiation which triggers the to avoid this issue.
false alarm.
2 The sensors are already In the programme the Flame
To make the device
calibrated but false alarm Sensor is only responsible
more accurate, an and
are still getting triggered. for the triggering of the Fire
logic could be used
Alarm. Sometime the sensor
(“&&”) i.e. the alarm
might be activated
will get triggered only if
depending on various
a certain condition is
environmental factor. met for the three sensors
3 The triggering of the The CPU frequency of the
The CPU frequency of
Alarm is taking a few ESP8266 was set to 80MHz
the ESP8266 can be set
seconds. which means it takes the
to 160MHz which
ESP8266 12.5ns to execute
means it will take the
a single task. ESP8266 6.25ns to
execute a single task.
4 The 3D printed casing is The nozzle size for a For accurate volume a
about 2mm larger than standard 3D printer is nozzle of diameter
the original volume 0.4mm. 0.2mm could be used.
designed in SolidWorks
5 The Flutter Mobile This an issue which This will be solved by
Application size is quite currently the Flutter team is the Flutter Team in the
large. facing and trying to solve. upcoming versions.
6 Firebase Services does Firebase services are not Firebase web support is
not work in Flutter Web. configured for Web needed to be configured
separately for Flutter
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 105

7.2 Future Improvements


All designs and protypes can be improved to make better and more user friendly. However,
each and every update have certain advantages and disadvantages. In the table shown in Table
no 23 shows the advantages and disadvantages to an update.
Table 23: List of Future Improvements
Sl Update Advantages Disadvantages
no
1 A PCB or a
• The casing will be
Veroboard can
smaller.
be used instead • Lesser scope for future
• The sensor,
of a breadboard upgradation.
microcontroller, and
or connecting it • Overall cost of the
the electronics
using female- device will increase
equipment
female/ male-
connection will be
female jumper
much more secured.
wires
2 ABS can be • ABS is more expensive
used instead of • ABS is lighter and than PLA
PLA as the more heat resistant • During printing ABS
material for the compared to PLA. might cause health
casing hazards

3 Using Image
Recognition • Large number of
• The design will be images related to fire is
techniques, the
smaller needed to be gathered.
camera could
• The design will • Extra cost will be
be used to
replace the need of incurred from the Cloud
detect
using the sensor. Service provider.
Fire/Flame and
Smoke
4 GSM could be • Reduce the overall • GSM modules available
used for sending code and in the market are mostly
SMS to the user development cost. 2G. In most of the
• Eliminates the need countries 2G networks
of Internet based are getting shutdown
operation. • GSM modules with 3G
and 4G network
capabilities are
expensive.
• With the evolution of
5G, it is possible 3G
and 4G networks will
get shutdown
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 106

7.3 Design and Cost


The casing along with the circuit included weighed only about 80gm. This makes the device
really light weight and consumer can even attach the device on their walls or celling using
around 10cm double sided tape. The device is moreover smaller in size. The smaller size of the
device means that cost for packaging the device will be low and moreover less space will be
required in a warehouse which will mean that sellers have to rent a less amount of space if they
want to sell or to store the “Fire Alarm Device” in Bulk quantity. Now based on the market
research, the below table gives a rough estimation of the cost analysis and the total selling price
for the device. The cost estimation was done before December 2020, so the total cost might
vary after December 2020.
Table 24: Final Costing of Device
Type Sl no Name Cost
(SGD)
Microcontroller 1 ESP-32-cam module with FTDI Programmer 12.00
2 NodeMCU V3 Development Board (ESP8266 5.50
12-E)
Sensor 3 DHT-11 Temperature Sensor 3.90
4 MQ-2 Gas Sensor 4.00
5 Flame Sensor 4.00
Electronic 6 1.8’’ TFT Display 8.00
Devices 7 Buzzer 1.00
Casing 8 PLA 100gm 2.00
9 Electricity 1.00
Logistics 10 Packaging 1.00
11 Transportation 5.00
Total Cost 47.4

7.4 Closing Stage


The report covered all the necessary steps and procedure to create a DIY Smart Fire Alarm
Device and System. The total cost of this device is found out to be 47.4 SGD. The device can
be sold at 50 SGD. However, device and the system may not be 100% accurate but sensor could
be used which has strong accuracy. This might increase the cost if only one device is
manufactured but if multiple devices are manufactured, then the overall cost might get reduced.
Overall from these project it could be assumed that Internet of Things is a growing field and
adding IoT capibilites to Fire Alarm Device is one of the examples how IoT can be applied.
In the future, it could be concluded that 99% Fire Alarm Device and system can be upgraded
to an IoT based Fire Alarm Device and systems.
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 107

8. BIBLIOGRAPHY

• Ali, Z., 2019. TEP Technoprenuer. [Online]


Available at: https://www.theengineeringprojects.com/2019/03/introduction-to-
dht11.html
[Accessed 20 11 202].
• Anonymous, 2008. WayBack Machine. [Online]
Available at:
https://web.archive.org/web/20080820080559/http://genchem.chem.wisc.edu/demonst
rations/Inorganic/pages/Group67/chlorine_and_hydrogen.htm
[Accessed 15 11 2020].
• Anonymous, 2009. Glossary of Wildland Fire Terminology, Marana, Arizona;:
National Wildfire Coordinating Group.
• Anonymous, 2016. electronicsforu.com. [Online]
Available at: https://www.electronicsforu.com/technology-trends/learn-
electronics/difference-between-microprocessor-and-microcontroller
[Accessed 15 11 2020].
• Anonymous, 2017. Marsden Fire Saftey. [Online]
Available at: https://www.marsden-fire-safety.co.uk/resources/fire-extinguishers
[Accessed 14 11 2020].
• Anonymous, 2019. Last Minute ENGINEERS. [Online]
Available at: https://lastminuteengineers.com/mq2-gas-senser-arduino-tutorial/
[Accessed 21 11 2020].
• Ayesha Rafat Arkeri, S. s., 2019. Blind Aid Stick: Hurdle Recognition, Along with
Voice Based. IJESC, 1(1), p. 10.
• Davidegironi, 2018. OPENELECTRONICS. [Online]
Available at: https://www.open-electronics.org/presenting-mq-sensors-low-cost-gas-
and-pollution-detectors/
[Accessed 19 11 2020].
• Mybotic, 2018. Instructables. [Online]
Available at: https://www.instructables.com/id/How-to-Use-a-Piezo-Buzzer/
[Accessed 23 12 2019].
• PDAControl, 2017. PDAControl. [Online]
Available at: http://pdacontrolen.com/category/platforms/esp8266/page/3/
[Accessed 19 11 2020].
• Santos, R., 2019. Random Nerd Tutorilas. [Online]
Available at: https://randomnerdtutorials.com/esp32-cam-video-streaming-face-
recognition-arduino-
ide/#:~:text=The%20ESP32%2DCAM%20is%20a,files%20to%20serve%20to%20cli
ents.
[Accessed 19 11 2020].
• Schmidt, C. W. & Symes, S. A., 2008. Fire and Bodies. In: S. A. S. Christopher W.
Schmidt, ed. The Analysis of Burned Human Remains. London UK: Elsivier Ltd, p. 4.
• Unspecified, 2014. Types of Mates, Moscow: University of Idaho.
• Various, 2014. CO2METER.COM. [Online]
Available at: https://www.co2meter.com/blogs/news/15164297-co2-gas-
concentration-
defined#:~:text=For%20example%2C%201%2C000ppm%20of,would%20be%20som
e%20other%20gases.&text=(10%2C000%2F1%2C000%2C000%20%3D%200.01),%
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 108

2C%201ppm%20%3D%200.0001%25%20gas.
[Accessed 21 11 2020].
• Various, 2019. Wikipedia. [Online]
Available at: https://en.wikipedia.org/wiki/Flame
[Accessed 16 11 2020].

9. APPENDIX

9.1 Timeline of Project


Table 25: Timeline of Project
Sl Category Date Description
no
1 FYP Initial 15/7/2020 – 30/9/2020 The briefing was done during July to
Briefing September 2020. Here mainly the
procedures and protocols were
explained for selection of project,
communication with supervisor and
timeline of FYP was explained.
2 FYP Project 14/8/2020 – 31/8/2020 The project selection was done in mid-
Selection and August 2020. It took around a week to
Confirmation receive the confirmation for the selected
project
3 Project 31/8/2020 This is done at the end of August 2020
Briefing with for basic understanding of the project
Supervisor with the supervisor and necessary
details in order to get started
4 Research 31/8/2020 – 15/9/2020 This is done in the 1st two weeks of
September 2020. Journals, Research
Paper and various websites were digged
up in order to understand the history,
present scenarios and the future
prediction of the Fire Alarm Device &
System
5 Defining 15/9/2020 – 30/9/2020 This was done in the last two weeks of
the September 2020. Here the overall
electronic components, software
services and other necessary things were
listed down for building the prototype
6 Hardware 30/9/2020 – 15/10/2020 This was done in the first two weeks of
Setup October 2020. Here the circuit was
connected as shown in Figure 18 and 17
and the sensors were calibrated along
Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 109

with Firebase and Arduino


Programming
7 App Design 15/10/2020–30/10/2020 The UI/UX was designed in the last two
and weeks of October 2020. During this
Development phase the design and the coding for the
App was done.
8 Casing 31/10/2020-16/11/2020 This was done in the first two weeks of
Implementation November 2020. During this phase the
casing was designed, and 3D printed.
The circuit was implemented inside the
casing
9 Report Writing 16/11/2020-31/12/2020 This was done from middle of
November 2020 to mid-week of
December 2020. During this phase a
technical report was drafted for this
project
10 Poster Making 15/12/2020-31/12/2020 A poster was drafted at the end of
December 2020. The poster mainly
gives a short summary of the report.
11 Final Report 14/2/2021 The final report and poster was
and Poster submitted (both softcopy and hardcopy)
Submission was submitted to the school in January
2020
12 Presentation 8/3/2021 During this phase the poster was
and oral presented to a group of audiences. All
defence queries and doubts regarding the project
raised by the audience was cleared on
this day

9.2 Gantt Chart


Date 15/7/2020 31/8/2020 14/8/2020 31/8/2020 15/9/2020 30/9/2020 15/10/2020 30/10/2020 16/11/2020 30/11/2020 15/12/2020 31/12/2020 14/2/2021 8/3/2021
FYP Initial Briefing
FYP Project Selection and Confirmation
Project Briefing with Supervisor
Research
Defining
Hardware Setup
App Design and Development
Casing Implementation
Report Writing
Poster Making
Final Report and Poster Submission
Presentation and oral defence

University Software Hands-on


Briefing/ Work Work
Notation Meeting /
Presentation

Figure 95: Gantt Chart


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 110

9.3 Structure of a Flutter App


Flow Chart 3: A Basic Widget structure in a Flutter Project

Flow Chart 4: Difference between a stateless and a stateful widget


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 111

9.4 Dart Cheat Sheet

Figure 96: Dart Cheat Sheet


Smart Fire Alarm Device and System
Final Year Report of Alekhaya Datta 112

9.5 Arduino Cheat Sheet

Figure 97: Arduino Cheat Sheet

View publication stats

You might also like