Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/iswarya-singaram/gas_level_monioring-raspberry-pi

This project demonstrates a simple application of a gas sensor connected to a Raspberry Pi. The system detects the presence of gas and outputs a message indicating whether gas is present or not.This project involves using a MQ2 gas sensor with a Raspberry Pi to detect the presence of gas in the environment
https://github.com/iswarya-singaram/gas_level_monioring-raspberry-pi

Last synced: about 2 months ago
JSON representation

This project demonstrates a simple application of a gas sensor connected to a Raspberry Pi. The system detects the presence of gas and outputs a message indicating whether gas is present or not.This project involves using a MQ2 gas sensor with a Raspberry Pi to detect the presence of gas in the environment

Awesome Lists containing this project

README

        

# Gas_level_monioring-Raspberry-pi
This project demonstrates a simple application of a gas sensor connected to a Raspberry Pi. The system detects the presence of gas and outputs a message indicating whether gas is present or not.This project involves using a MQ2 gas sensor with a Raspberry Pi to detect the presence of gas in the environment. When gas is detected, the system outputs a message indicating the presence of gas. This can be useful for safety applications and environmental monitoring.



## Components
Raspberry Pi 4 or 5

Gas Sensor (e.g., MQ-2, MQ-3)

Breadboard and Jumper wires



## Hardware Setup
1. VCC to 3.3V
2. GND to GND
3. D0 to GPIO-7 (digital output pin on Raspberry pi)

## Circuit Diagram



## Software Setup
1.Booting the Raspberry Pi OS

1. If you have already booted your Raspberry Pi and have the OS running, skip to the next step.

2. If not, refer to the following repository https://github.com/Iswarya-Singaram/Raspberry-Pi-Booting-and-VNC-Viewer-Setup for instructions on how to install and boot the OS and viewing the Raspberry Pi via VNC

3. Once connected to your Raspberry Pi, open the Terminal.



4. Download the necessary libraries
~~~
sudo apt-get install python3-rpi.gpio
~~~

If python3 is not install in your pi use,

~~~
sudo apt-get install python3
~~~
5. Open nano

  • To check if nano is installed, type:
  • ~~~
    nano --version
    ~~~

  • If nano is not installed, install it by typing:
  • ~~~
    sudo apt-get update
    sudo apt-get install nano
    ~~~

    7. Use the following command to open nano and create a file name gas.py

    ~~~
    nano gas.py
    ~~~



    8. Paste the following Source code:
    ~~~
    import RPi.GPIO as GPIO
    import time

    # Set up the GPIO mode
    GPIO.setmode(GPIO.BCM)

    # Set up the GPIO pin for reading the DO output
    DO_PIN = 7 # Replace with the actual GPIO pin number
    GPIO.setup(DO_PIN, GPIO.IN)

    try:
    while True:
    # Read the state of the DO pin
    gas_present = GPIO.input(DO_PIN)

    # Determine if gas is present or not
    if gas_present == GPIO.LOW:
    gas_state = "Gas Present"
    else:
    gas_state = "No Gas"

    # Print the gas state
    print(f"Gas State: {gas_state}")

    time.sleep(0.5) # Wait for a short period before reading again

    except KeyboardInterrupt:
    print("Gas detection stopped by user")

    finally:
    # Clean up GPIO settings
    GPIO.cleanup()
    ~~~

    9. Now, click Ctrl+X to exit nano.
    10. Run the python script by

    ~~~
    python gas.py
    ~~~

    ## Troubleshooting

  • Ensure all connections are secure.

  • Check the power supply to the gas sensor.

  • Verify that the correct GPIO pin is used in the script.

  • Consult the gas sensor's datasheet for specific details about its operation and requirements.
  • ## Contributing
    Contributions are welcome! Please fork this repository and submit pull requests.