Gaurav Ghosalkar
Published

LPG Leakage Detection

This project is about detecting the leakage of LPG at home. The sensor used is MQ2 which detect leakage in surrounding and a buzzer will buz

IntermediateFull instructions provided395
LPG Leakage Detection

Things used in this project

Story

Read more

Custom parts and enclosures

Device setup

BreadBoard

Bolt IoT module

MQ2 Sensor

Schematics

Circuit Diagram of Device

First of the MQ2 Sensor requires 5V of current to power up so the 5V pin of Bolt module is been connected to VCC pin of MQ2 sensor.

Then, the GND pin of MQ2 sensor is been connected to the GND of bolt module as well as the negative part of buzzer is also connected to the GND of bolt module.

Now as the MQ2 sensor read the analog value the A0 pin of sensor is been connected with the A0 pin in bolt module.

And the final one the buzzer to blow when the alert is their so, positive pin is connected to pin 1 of bolt module, which get set to high when sensor value is above threshold.

Code

Leakage.py

Python
This is main file where the sensor value detected will match the threshold value and alert according to the sensor value is read.
import conf
from boltiot import Sms,Bolt
import json,time

maximum_limit=800
mybolt=Bolt(conf.API_KEY,conf.DEVICE_ID)
sms=Sms(conf.SID,conf.AUTH_TOKEN,conf.TO_NUMBER,conf.FROM_NUMBER)
while True:
    print("Reading Values")
    response=mybolt.analogRead('A0')
    data=json.loads(response)
    print("Sensor Value is:"+ str(data['value']))
    my=Bolt(conf.API_KEY,conf.DEVICE_ID)
    res=my.digitalWrite('1','LOW')
    print(res)
    try:
      sensor_val=int(data['value'])
      if sensor_val > maximum_limit:
        my=Bolt(conf.API_KEY,conf.DEVICE_ID)
        res=my.digitalWrite('1','HIGH')
        response=sms.send_sms("There is a leakage")
        print("Sms Send:"+str(response.status))
    except Exception as e:
      print(e)
time.sleep(10)

Credits

Gaurav Ghosalkar

Gaurav Ghosalkar

1 project • 0 followers

Comments