Professional Documents
Culture Documents
03 Real Time Environment Monitoring
03 Real Time Environment Monitoring
Objective:
1.To monitor the ambient environmental condition using TMP36 and MQ2 sensors in
Tinkercad.
Components list:
Theory:
The TMP36 sensor this sensor uses the property of diodes; as a diode changes temperature the
voltage changes with it at a known rate. The sensor measures the small change and outputs an
analog voltage between 0 and 1.75VDC based on it. We can obtain the temperature from utilizing
the formula: temperature=((vout*5/1023)-0.5)*100;
MQ2 gas sensor is an electronic sensor used for sensing the concentration of gases in the air such as
LPG, propane, methane, hydrogen, alcohol, smoke and carbon monoxide. Based on the
concentration of the gas the sensor produces a corresponding potential difference by changing the
resistance of the material inside the sensor, which can be measured as output voltage.
Connection Diagram:
Procedure
1. Sign in to tinkercad.com
2. Create a new project, to create a new circuit.
3. Select the required components and place them in the circuit window.
4. Make a connection to all components as per the circuit diagram given below.
5. Click the Code menu to select the code type as Text.
6. In Code window write your code to perform given task.
7. Press start simulation and view the output.
8. Press serial monitor in a code window to view the continuous output.
9. Stop the simulation and download the developed code for future reference.
Text code:
//#include<LiquidCrystal.h>
//LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
float temperature; //variable temperature (degree Celsius)
float vout; //temporary variable sensor reading
int LED = 13;
int gas_sensor;
int piezo = 9;
void setup()
{
pinMode(A0,INPUT);
pinMode(A1,INPUT);
pinMode(LED, OUTPUT);
pinMode(piezo,OUTPUT);
//lcd.begin(16, 2);
Serial.begin(9600);
}
void loop()
{
vout=analogRead(A0); //Reading the value from sensor
//analogReference(DEFAULT);
//// convert analog values between 0 and 1023 with 5000mV/5V ADC
temperature = ((vout*5/1023)-0.5)*100;
if (temperature>=60)
{
digitalWrite(LED,HIGH);
}
else
{
digitalWrite(LED,LOW);
}
gas_sensor=analogRead(A1);
if (gas_sensor>=100)
{
digitalWrite(piezo,HIGH);
}
else
{
digitalWrite(piezo,LOW);
}
// printing values in serial monitor
Serial.print("in DegreeC=");
Serial.print(" ");
Serial.print(temperature);
Serial.print("\t");
Serial.print("gassensor=");
Serial.print(" ");
Serial.print(gas_sensor);
Serial.println();
//lcd.setCursor(3,0);
//lcd.print("Temp: ");
//lcd.setCursor(8,0);
//lcd.print(temperature);
//lcd.setCursor(2,1);
//lcd.print("Toxicity: ");
//lcd.setCursor(11,1);
//lcd.print(gas_sensor);
delay(1000);
}
Result Analysis:
We were able to monitor the environmental temperature and the toxicity of the environment using
these sensors. Two different cases were considered here, one with 220 ohm resistor and the other
with 1 kilo ohm resistor. We developed a code in such a way that if the temperature goes beyond 60
degrees Celsius the led will turn on, likewise, if the harmful gases, smoke, and natural gas leakage
number goes beyond 100, then the buzzer will start beeping. Further in this experiment different
values of resistors were considered to experiment on the sensitivity and it was concluded that the use
of 1k ohm resistor was more sensitive than the use of 220 ohm resistor
Simulation Results: Attach the verified sheet and printouts with ID cards