Skip to main content

Soil Moisture sensor with Arduino in Tinkercad | how to use soil moisture sensor in Tinkercad

  Soil Moisture sensor with Arduino in Tinkercad | how to use soil moisture sensor in Tinkercad Circuit diagram: Arduino Sketch: // C++ code // int moisture_data = 0; void setup() {   pinMode(A0, INPUT);   Serial.begin(9600);   pinMode(12, OUTPUT);   pinMode(6, OUTPUT); } void loop() {   moisture_data = analogRead(A0);   Serial.println(moisture_data);   if (moisture_data < 21) {     digitalWrite(12, HIGH);     digitalWrite(6, HIGH);   } else {     digitalWrite(12, LOW);     digitalWrite(6, LOW);   }   delay(10); // Delay a little bit to improve simulation performance }

Interfacing of smoke sensor (MQ2) with an Arduino in tinkercad. [Gas leakage detector]

                   Interfacing of smoke sensor (MQ2) with an Arduino in tinkercad.

[Gas leakage detector]

In this project, we will see how to interface the smoke sensor with Arduino in tinkercad and we will make the gas leakage detector. and also, we will learn about gas Sensors, how a gas sensor works and simulate the circuit in tinkercad. Here we are using MQ2 Gas Sensor Module. This gas sensor module is basically suitable for detecting LPG, SmokeAlcoholPropaneHydrogenMethane and Carbon Monoxide concentrations in the air. This gas sensor can be used make projects like indoor air quality monitoring, alcohol checker or LPG leakage detecting.

 

Circuit Diagram:


 

Components Required:

§  Arduino UNO

§  Gas sensor

§  Resistor-04

§  LED-02

§  Connecting wires

§  Buzzer

 

Connection:

The hardware a part of this project is quite simple and easy to place together. First of all, make the connections for the gas sensor with the Arduino. The connections for the gas sensor with the Arduino given in the above circuit diagram.

Gas sensor has six pins here we used the MQ2 sensor alone.MQ2 gas sensor module has 4 pins power, ground, analog out, digital out. will see how to do the connection for MQ2 sensor.



A basic gas sensor has 6 terminals in which 4 terminals (A, A, B, B) acts as input or output and the other 2 pins (H, H) are for heating the coil.

Connect the A1, H1, A2 to the power pin of an Arduino.

Connect the B1 to the analog pin A5 of an Arduino.

Connect the h1 to the GND pin of an Arduino.

Connect the B1 to the GND through resistor.

Connect the buzzer positive pin to digital pin 10 of an Arduino.

Connect the LED with resistor to digital pin 11 of an Arduino.

Connect the LED with resistor to digital pin 12 of an Arduino.

Connect the negative of the buzzer and cathode of LED to the GND pin of an Arduino.

 

What is MQ2 Gas Sensor?

MQ2 gas sensor is one of most used in MQ sensor list. It is a Metal Oxide Semiconductor (MOS). Gas sensor is one which use to detect the variation in the concentration of toxic gases in environment, industries in various places.

How does it work?

Sensor gives the analog output that is changing voltage output based on smoke/gas level that exists in the atmosphere. The sensor outputs a voltage that is proportional to the amount of concentration of smoke/gas in the environment.

In simple words, I can put the relationship between voltage and gas concentration is the following:

§  If there is more the gas concentration, the more the output voltage

§  lesser the gas concentration, the lesser the output voltage



Pinout:-


List of Gas Sensors and What Gases They Sense



Arduino Code Explanation:

Define the LED and buzzer pins, led1 is connected to the pin 12 and led2 is connected to the pin 11 and last buzzer is connected to the pin 10.

Ø  int led1=12;

Ø  int led2=11;

Ø  int buzzer=10;

 define where the gas sensor is connected, it is connected to the analog pin A5 of an Arduino.

Ø  int gas_sensor=A5;

 

declared variable named sensorthreshold to store the threshold value of gas sensor

Ø  int sensorthreshold=600;

 

Inside the void setup we will define the pin which are input and which are output pin, this set of code runs only once.

Initialize the serial monitor for displaying the value at baud rate of 9600.

 

void setup()

{

pinMode(led1,OUTPUT);

pinMode(led1,OUTPUT);

pinMode(buzzer,OUTPUT);

pinMode(gas_sensor=A5,INPUT);

  Serial.begin(9600);

}

the code inside the void loop runs over and over as long as the Arduino Board is turned on.

 Here inside the loop defined one variable called analog sensor to store the gas sensor value

 

void loop()

{

  int analogsensor=analogRead(gas_sensor);

  Serial.println("sensor  ");

  Serial.println(analogsensor);

The if() conditional statement  basic coding control structures. One can make something happen or not, it depend whether the condition is true or not. It looks like this:

If the value stored in analogsensor variable is greater than threshold value then led1 will tun on and buzzer start producing sound

  if (analogsensor>sensorthreshold)

  {

    digitalWrite(led1,HIGH);

    digitalWrite(led2,LOW);

    tone(buzzer,1000,350);

  }

If the exact opposite happens then led2 will turn on and buzzer turned off.

  else

  {

    digitalWrite(led1,LOW);

    digitalWrite(led2,HIGH);

    noTone(buzzer);

  }

}


Watch Working Video part 1:


Watch Working Video part 2:


Complete Arduino Sketch:

int led1=12;

int led2=11;

int buzzer=10;

int gas_sensor=A5;

int sensorthreshold=600;

 

void setup()

{

pinMode(led1,OUTPUT);

pinMode(led1,OUTPUT);

pinMode(buzzer,OUTPUT);

pinMode(gas_sensor=A5,INPUT);

  Serial.begin(9600);

}

 

void loop()

{

  int analogsensor=analogRead(gas_sensor);

  Serial.println("sensor  ");

  Serial.println(analogsensor);

  if (analogsensor>sensorthreshold)

  {

    digitalWrite(led1,HIGH);

    digitalWrite(led2,LOW);

    tone(buzzer,1000,350);

   

  }

  else

  {

    digitalWrite(led1,LOW);

    digitalWrite(led2,HIGH);

    noTone(buzzer);

  }

}

  

Like share and comment :


                                                     Our FaceBook Page                                                           







For Any queries please contact:

impulseTech101@gmail.com

Comments

Popular posts from this blog

Water level monitoring system using IoT | IoT based water level using Nodemcu ESP8266 & ESP32

Water level monitoring system using IoT | IoT based water level using Nodemcu ESP8266 & ESP32 Hello Everyone! I have come up with new tutorial Water level monitoring system using IoT | IoT based water level using Nodemcu ESP8266 & ESP32 For Code & Circuit Diragram: In this video what you will learn about? 1. How to configure the new Blynk IoT Platform. 2. How to setup web dashboard 3. How to create template in blynk iot 4. How to interface ultrasonic sensor with node mcu esp8266. 5. How to read ultrasonic sensor with esp8266 1.You can Watch Playlist on New Blynk IoT Platfom New Blynk IoT platform with esp32 | how to setup automation in Blynk IoT app https://youtu.be/O2HZuu4KtIc 2.How to create events in blynk IoT platform | events in new Blynk IoT platform 🔥🔥 https://youtu.be/X5zVaGk8QV0 3.IoT Based smart garden monitoring system | Smart plant monitoring using Blynk IoT https://youtu.be/GTdxD5vQwy0 4.Water level monitoring system using IoT | IoT based...

Soil Moisture sensor with Arduino in Tinkercad | how to use soil moisture sensor in Tinkercad

  Soil Moisture sensor with Arduino in Tinkercad | how to use soil moisture sensor in Tinkercad Circuit diagram: Arduino Sketch: // C++ code // int moisture_data = 0; void setup() {   pinMode(A0, INPUT);   Serial.begin(9600);   pinMode(12, OUTPUT);   pinMode(6, OUTPUT); } void loop() {   moisture_data = analogRead(A0);   Serial.println(moisture_data);   if (moisture_data < 21) {     digitalWrite(12, HIGH);     digitalWrite(6, HIGH);   } else {     digitalWrite(12, LOW);     digitalWrite(6, LOW);   }   delay(10); // Delay a little bit to improve simulation performance }

DS18B20 Temperature sensor with new Blynk IOT Platform | DS18B20 with Esp32 & Blynk IoT Cloud

DS18B20 Temperature sensor with new Blynk IOT Platform | DS18B20 with Esp32 & Blynk IoT Cloud   Hello Everyone! I have come up with new tutorial based on the all new Blynk IoT platform. which is DS18B20 Temperature sensor with new Blynk IOT Platform | DS18B20 with Esp32 & Blynk IoT Cloud #iot #blynk In this video what you will learn about? 1. How to configure the new Blynk IoT Platform. 2. How to interface DS18B20 sensor with esp32 4. How to configure mobile blynk IoT platform 5. How to setup Automation in Blynk IoT 1.You can Watch Playlist on New Blynk IoT Platfom New Blynk IoT platform with esp32 | how to setup automation in Blynk IoT app | #iot #blynk #esp32 https://youtu.be/O2HZuu4KtIc 2.How to create events in blynk IoT platform | events in new Blynk IoT platform 🔥🔥 #blynk #esp32 #iot https://youtu.be/X5zVaGk8QV0 3.IoT Based smart garden monitoring system | Smart plant monitoring using Blynk IoT #iot #blynk #esp32 https://youtu.be/GTdxD5vQwy0 4.Wa...