Skip to content

Simple script that sends alerts via Discord and toggles a Buzzer when high concentration of specific gas was detected (using MQ sensor)

Notifications You must be signed in to change notification settings

djamn/raspberry-gas-alerting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MQ Gas Alerting System

This repository contains an explanation to implement a simple gas checking system that toggles a Piezo-Buzzer when MQ-Sensor specific high concentration is detected

The script also sends a notifcation to Discord, if WEBHOOK_URL has a valid url

Getting Started

  • Needed: Transistor (to enable buzzer when GPIO Pin is triggered), Resistor for better accuracy (used 10kΩ), MQ-Sensor (used MQ-135) and Piezo-Buzzer (or similar)
  • Software: Python3 & pip
  • Hardware: Raspberry Pi 3b+

Execution of air quality script

  • python3 check-air.py is the main script
  • (Optional) Add a Discord webhook url to WEBHOOK_URL and toggle HAS_BUZZER variable
  • Remove file ending of main script -> It is executable without python3 command due to #!/usr/bin/env/python3
  • Script must then be moved to /usr/local/bin to be executable by simply writing the filename
    • sudo mv FILENAME /usr/local/bin/
    • sudo chmod +x /usr/local/bin/FILENAME - Add execution permission
  • To start the script on boot of Raspberry Pi:
    • Create **FILENAME**.sh script from repo
    • Move it to /etc/init.d and make it executable
      • sudo mv FILENAME.sh /etc/init.d/
      • sudo chmod +x /etc/init.d/FILENAME.sh
    • Register script to be executed on boot:
      • sudo update-rc.d FILENAME.sh defaults
    • Reboot Raspberry Pi or manually start the script:
      • sudo /etc/init.d/FILENAME.sh start

⚠️ Files that are moved to /usr/local/bin must be encoded in LF, not CRLF, otherwise they are not executable. Fix (VSCode): At the bottom right, change CRLF to LF Fix (Terminal): sudo sed -i -e 's/\r$//' /PATH/FILENAME

How To

Build 1
Build 2
Build 3
Build 4
Build 5 GPIO Pins (https://www.elektronik-kompendium.de/sites/raspberry-pi/bilder/raspberry-pi-gpio.png)

About

Simple script that sends alerts via Discord and toggles a Buzzer when high concentration of specific gas was detected (using MQ sensor)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published