swatisingh
Published © GPL3+

Pollution Detecting System

This system detects the pollution emitted by vehicles and informing the respective owners about the requirement of service of their cars.

IntermediateFull instructions provided12 hours1,343
Pollution Detecting System

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1
Grove - Gas Sensor(MQ2)
Seeed Studio Grove - Gas Sensor(MQ2)
×1
5 mm LED: Yellow
5 mm LED: Yellow
×1
5 mm LED: Green
5 mm LED: Green
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
Male/Male Jumper Wires
×1

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
Bolt IoT Android App
Bolt IoT Android App
SMS Messaging API
Twilio SMS Messaging API
Snappy Ubuntu Core
Snappy Ubuntu Core

Story

Read more

Schematics

Circuit diagram of pollution detecting system

It shows all the connections of all the modules, sensor and devices.

Schematic Diagram of MQ-2 gas sensor

It shows the inner circuitry of the MQ-2 sensor.

Schematic Diagram of Bolt IoT Wi-Fi module

It shows the inner circuitry of the Bolt Wi-Fi module.

Code

Code for whole execution of the project

Python
It is code for running the whole product system.
Import conf #fetches all the credentials
from boltiot import Sms, Bolt #imports sms & Bolt from boltiot library
import json, time #imports json & time from python library

maximum_limit = 400 #threshold of the sensor

mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID) #mybolt object fetches api key & device ID
sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER) #sms object fetches SID, Auth token, To number and from number

while True: 
    print ("Reading sensor value")
    mybolt.digitalWrite('1', 'HIGH') #turns ON the green LED /ignition system
    response = mybolt.analogRead('A0') #read the output of MQ2 gas sensor
    data = json.loads(response) #convert sensor output into data
    print("Sensor value is: " + str(data['value'])) #prnt sensor value to console
    try: #used to avoid traceback errors
        sensor_value = int(data['value']) 
        if sensor_value > maximum_limit: #verifies the outout to be in limits
          response = mybolt.digitalWrite('0', 'HIGH') #turn ON yellow LED depicting requirement of service
          print(response) #print the status of output
          print("Making request to Twilio to send a SMS")
          response = sms.send_sms("The Current pollution level is " +str(sensor_value) +  "Your vehicle needs servicing in concern with pollution emission") #message sent to owner
          print("Responses received from Twilio is: " + str(response))
          print("Status of SMS at Twilio is :" + str(response.status))
          time.sleep(45) #delay for the owner to get vehicle serviced
          mybolt.digitalWrite('1', 'LOW') #turns OFF ignition system/green LED
          response = sms.send_sms("The engine has been cut off since pollution service period had been expired.") #message sent to owner/RTO on expiry of pollution service period
    except Exception as e: 
        print ("Error occurred: Below are the details")
        print (e)
    time.sleep(60)

Code for controlling LEDs for system

HTML
The LEDs of the project could be controlled by using Bolt IoT app
<!DOCTYPE html>
<html>
    <head>
        <title>Bolt IoT Platform</title>
        <script type="text/javascript" src="https://cloud.boltiot.com/static/js/boltCommands.js"></script>
        <script>
        setKey('{{ApiKey}}','{{Name}}');
        </script>
    </head>
    <body>
        <center>
<br><br><br><br>
        <button style="background-color:green; height:150px; width:250px;" onclick="digitalWrite(0, 'HIGH'), digitalWrite(1, 'HIGH');"> 
<font size="7"><B>ON</B></font></button>
        <br><br><br>
        <button style="background-color:red; height:150px; width:250px;" onclick="digitalWrite(0, 'LOW'), digitalWrite(1, 'LOW');">
 <font size="7"><B>OFF</B></font></button>
        </center>
</body>
</html>

Credits

swatisingh

swatisingh

1 project • 0 followers

Comments