• nithya7rns

Fire Alarm System Project by Interfacing Arduino with Temperature & Gas Sensor using TinkerCad

Updated: Dec 31, 2020

Simulation software is generally used before the circuits and devices are built. It is not only that small devices can be designed on software, complex and large circuits/devices can be simulated. By this, damage can be avoided when all the hazards and implications can be avoided in the simulation itself.


In this article, we are going to design a Fire Alarm circuit using a few electrical components like Temperature and Gas sensors using TinkerCad and interface it with Arduino. Let's start with the components we will require to build the circuit in the #TinkerCad software.


Hardware Requirements.

These components are not required while building it in the simulation software. To build the circuit manually, click on the links given below to buy the components required.


  1. Arduino UNO Board.

Develop a stronger concept in Arduino through this article:- What is Arduino?

Arduino UNO

#Arduino board is a microcontroller that is used to accept inputs from sensors connected and provide an output action on the desired device connected to it. The sensor inputs can be from light-detecting sensors, motion sensors (Ultrasonic or IR), temperature sensors, etc. The output from this device can be received through other output devices such as LED, Buzzer, Serial monitor, etc.


Buy Arduino UNO from here.


2. LM-35 Temperature Sensor


LM-35 Flame Sensor

LM-35 #Temperature Sensor gives an analog output based on the instantaneous temperature value. This analog output is proportional to the instantaneous input.


Buy LM-35 Sensor from here.


3. Gas sensor


MQ2 Gas sensor

The gas #sensor is used to measure the concentration or presence of gas in the atmosphere. It is also used to detect smoke in the air. Based on the gas, a potential difference is generated by changing the resistance of the material present inside the sensor. The output is measure in terms of Voltage.


Buy Gas sensor from here.


4. Resistors


1k Ohm Resistor

Resistors are passive devices that restrict the flow of current or divide the voltage through the circuit. The input power passes through these resistors and then to the sensors to avoid damage.


Buy Resistors from here.


5. Breadboard


Breadboard

The breadboard is the basic component of any circuit building process. All components, be it input sensors or output display devices are connected to the power supply, microcontroller using wired connections through a breadboard. The holes in the breadboard are in series. There are various sizes like full-sized, half-sized, and mini breadboard.


Buy breadboard from here.


6. LED


LED

Light Emitting Diode is a commonly used light source. It is a semiconductor that emits light when current flows through it.


Buy LED from here.


7. Piezo Buzzer


Piezo Buzzer

It is an electrical component that generates a beep sound on receiving an input. It works on the principle of #piezo crystal.


Buy Piezo buzzer from here.


8. Jumper Wires


Jumper Wires

These are the main components that are used to establish the connections between different devices of the circuit.


Buy Jumper Wires from here.


NOTE: The description of the electrical components is given for reference. We don't need the physical components for this project. The circuit simulation is done in the TinkerCad software.


Software Requirement


TinkerCad circuit simulation software.



TinkerCad Logo

It is an online simulation software used for circuit design. It has all the electrical components required to built circuits and runs them.


Visit the TinkerCad website.


Circuit Connections



Circuit Diagram


The circuit connections are as follows.


Firstly, we need to connect one line of the breadboard to the ground and the other to the power supply. This is done by connecting the 5V pin of the Arduino Board to one line of connection pins on the breadboard. The other line of the breadboard is connected to the ground terminal of the Arduino Board. These lines will be connected to other devices.


The Temperature sensor has three pins. Ground, Vout, and Vs (Supply). The Vs pin that has a range of 4-20V is connected to the power supply line of the breadboard. The Ground terminal of the sensor is connected to the ground line of the breadboard. The Vout terminal of the temperature sensor is connected to one of the Analog pins of the Arduino Board, A1.


Now let us learn how the connections are done with the Gas sensor. This sensor has 6 pins. 3 pins of the gas sensor are directly connected to the power supply line of the breadboard. Amongst the other 3 pins of the sensor, one pin is connected to one of the Analog pins of the Arduino Board, A0. The pin in the middle is connected to the ground line of the breadboard. The third pin of the sensor is connected to a resistor and then connected to the ground line.


The piezo buzzer is externally connected to the circuit. The ground pin of the #buzzer is connected to the ground line of the breadboard. Another pin of the buzzer is connected to the digital pin, PIN 7 of the Arduino Board.


Lastly, the LED is connected to the Arduino directly. The cathode of the LED is connected to the GND pin of Arduino and the anode of the LED is connected through a resistor to the digital pin 13 of the Arduino.


Code


float temp; 
float vout; 
float vout1; 
int LED = 12; 
int gasSensor; 
int piezo = 4; 

Every program code starts with the declaration of the variables we require for the execution of the program. A floating-point variable "temp" is declared for the temperature value that is going to be taken as input from the temperature sensor.


Another floating-point variable "out" is declared to store the value of the output from the temperature sensor. The variable "vout1" is going to store the value of the output from the gas sensor. The value of the pin to which the LED is connected is store in the variable "LED". Integer variables for Gas-sensor and Piezo buzzer are declared.


void setup() 
{ 
pinMode(A0,INPUT); 
pinMode(A1, INPUT); 
pinMode(LED,OUTPUT); 
pinMode(piezo,OUTPUT); 
Serial.begin(9600); 
} 

The setup( ) function uses pinMode functions to assign the Mode for the pins declared. A0 pin is going the take the input from the Gas sensor, so it's assigned as input mode. The PIN A1 is going to take input from the Temperature sensor, so it is assigned as an input pin.


The #LED is going to be the output indicator for the Gas sensor hence declared as Output. The piezo buzzer indicates the output of the Temperature sensor, hence it is declared as output. The #Baudrate for serial transmission, 9600 is given to begin the execution of the code.

void loop() 
{ 
vout=analogRead(A0); 
vout1=(vout/1023)*5000

The variable "vout" will hold the value read from the analog pin A0 which is the input from the Gas sensor. analogRead( ) function uses to take the input. The vout1 holds the value based on "vout". The above expression in the code shows the same.

if (temp>=80) { 
digitalWrite(LED,HIGH); } 
else { 
digitalWrite(LED,LOW); } 

A set of if-else statements are used to assign values that could give the output. The first "if" condition checks if the input temperature is Greater than 80 C. If the temperature goes above 80, the LED is HIGH and it glows. Otherwise, the LED remains OFF (LOW). This function is done using digitalWrite( ) function.

if (gasSensor>=1000) { 
digitalWrite(piezo,HIGH); } 
else { 
digitalWrite(piezo,LOW); } 

The next set of "if" conditions check the input from the gas sensor. If the input value goes above 1000, the Piezo Buzzer buzzes (HIGH) and if the value is less than 1000, the value sent to the buzzer remains LOW.

Serial.print("in DegreeC= "); 
Serial.print(" "); 
Serial.print(temp); 
Serial.print("\t"); 
Serial.print("GasSensor= "); 
Serial.print(" "); 
Serial.print(gasSensor); 
Serial.println(); 
delay(1000); 
}

This series of print statements will print the output received from the sensor. The temperature is printed first in terms of degree celsius. The gas sensor output is printed consecutively. A delay of one second is given for every output. This happens in a loop until the circuit is plugged off.


COMPLETE CODE


float temp; 
float vout; 
float vout1; 
int LED = 12; 
int gasSensor; 
int piezo = 4; 
void setup() 
{ 
pinMode(A0,INPUT); 
pinMode(A1, INPUT); 
pinMode(LED,OUTPUT); 
pinMode(piezo,OUTPUT); 
Serial.begin(9600); 
} 
void loop() 
{ 
vout=analogRead(A0); 
vout1=(vout/1023)*5000; 
temp=(vout1-500)/10; 
gasSensor=analogRead(A1); 
if (temp>=80) 
{ 
digitalWrite(LED,HIGH); 
} 
else 
{ 
digitalWrite(LED,LOW); 
} 
if (gasSensor>=1000) 
{ 
digitalWrite(piezo,HIGH); 
} 
else 
{ 
digitalWrite(piezo,LOW); 
} 
Serial.print("in DegreeC= "); 
Serial.print(" "); 
Serial.print(temp); 
Serial.print("\t"); 
Serial.print("GasSensor= "); 
Serial.print(" "); 
Serial.print(gasSensor); 
Serial.println(); 
delay(1000); 
}

NOTE: The default code present in the TinkerCad window needs to be removed and the program code needs to be written. Download the document and copy-paste the code in Tinkercad to simulate the circuit.

Code for Fire Alarm System with Temperat
.
Download • 11KB

Working


Circuit when working.

Let us first learn how to work on TinkerCad #simulation software. Once on the TinkerCad page, select circuits, and search for the components required. The components are to be dragged and brought to the circuiting screen. The connection needs to be made by selecting the jumper wires. Corresponding colors for the wires can be selected.

Learn more about TinkerCad in detail.


Coming to the working of the circuit, we can understand it in two parts.


Part 1: Temperature sensor and its output.


The Temperature sensor takes in input and when the temperature increases, the voltage increases, and hence the output initiates the functioning of the Buzzer. For every one degree increase in temperature, there is a 10mV increase in the voltage.


Part2: Gas sensor and its output.


A gas sensor is also used to detect smoke along with the concentration of gases. Based on the type of gas present in the atmosphere, a potential difference is developed by changing the Resistance of the material present inside the sensor and the same is measured as output.


The Concentration of the gas is measured in ppm and the output analog value is needed to be converted into digital which is done by the #ADC (Analog to Digital Converter) present in the sensor itself. Based on the condition given in the code, the LED glows or remains OFF.


Watch the below-given project video for the practical explanation of designing the circuit and to know how the simulation #software works.


Project Video By - Navya Tatiparthi

Simulation software plays a major role in the building of large circuits as they help analyze the working of the circuit before it can be built practically. It helps us create a #virtual design of the circuit we want to build and avoid damages to the circuit if in case we don't know, beforehand about the correct circuit connections.


For more projects through TinkerCad click here.


Simulation software can help us build more effective and efficient projects as it provides validation for the circuit we will be building using the actual components. Design your own circuit, run the code in the software, and validate your project.


SEE ALSO:

  • Facebook
  • YouTube
  • Instagram
  • LinkedIn
LearnElectronics
Contact Us
© Copyright - LearnElectronics 2021