» » » Environmental pollution monitoring system

Environmental pollution monitoring system

posted in: Others, Sensors | 0

The environmental pollution is getting bigger and bigger everyday. The reason for this is the extensive use of vehicles and the emerging industries. We have no check on what gases are being emitted from them or sometimes government just check the gases like CO2 etc, ignoring the other malign pollutants such as Ozone and Carbon monoxide. Moreover, the gas concentration measuring devices available are costly.

Here is an effortless way to make a pollutants measuring device which works without any hassle. It does not require you to solder anything. It is uncomplicated, quick and inexpensive.

So let’s set out!

Components Required:


  1. Raspberry Pi 2
  2. I2C shield
  3. I2C cables
  4. Micro USB and Ethernet cable
  5. ADC121C_MQ131
  6. ADC121C_MQ9

About the sensors used:

  • ADC121C_MQ131 :
    The ADC121C_MQ131 Gas sensor which is meant to monitor the concentration of ozone in the atmosphere where it is incorporated. It is an I2c module which can be connected to the Raspberry Pi using I2C header and cable. It’s operating voltage is 5VDC. It can sense in the range between 10ppb to 2ppm
  • ADC121C_MQ9 :
    The gas sensor ADC121C_MQ9 has high sensitivity to combustible gases like Methane, Propane and CO. We are using it to measure the concentration of Carbon monoxide in the air. It can be connected using I2C cable. It operates at 5VDC. It senses CO between 10-1000ppm.



The requisite connections are as follows:

  • Firstly, take a Raspberry Pi board and an I2C header.
  • This will work over I2C. We will place the I2C shield over  Raspberry pi(as shown in the picture below) and gently connect it on to  the gpio pins of Raspberry Pi.
  • Connect the one end of I2C cable to the in-port of MQ9 sensor and the other end to the I2C shield.
  • Then, Connect the MQ131 sensor’s in-pot to the MQ9’s out using I2C cable.
  • Connect the Ethernet cable to Raspberry Pi .Wi-Fi router can also be used for the same.
  • Then, power the Raspberry Pi using a Micro USB adapter.

Communicating using I2C Protocol:


To make Raspberry Pi I2C enabled, proceed as mentioned below:

  • In terminal, type the following command to open the configuration settings:
    sudo raspi-config
  • Select “Advanced Options” in here.
  • Select “I2C” and Click “Yes”.
  • Reboot the system to set it up as per the changes made using the command reboot.


Programming the module:


The reward of using Raspberry Pi is, that is provides you the flexibility to opt a the programming language in which you want to program to interface the sensing device with Raspberry Pi. Harnessing this advantage of Raspberry Pi, we are demonstrating here its programming in the Java.


To set up the Java environment, Install the “pi4j libraby” from http://pi4j.com/install.html. Pi4j is a Java Input/Output Library for Raspberry Pi.
An easy and most preferred method to install the “pi4j library” is to execute the undermentioned command directly in your Raspberry Pi:

curl -s get.pi4j.com | sudo bash
curl -s get.pi4j.com




import com.pi4j.io.i2c.I2CBus;

import com.pi4j.io.i2c.I2CDevice;

import com.pi4j.io.i2c.I2CFactory;

import java.io.IOException;

public class GasMonitoring


public static void main(String args[]) throws Exception


// Create I2C bus

I2CBus Bus = I2CFactory.getInstance(I2CBus.BUS_1);

I2CBus Bus1 = I2CFactory.getInstance(I2CBus.BUS_1);

// Get I2C device, ADC121C_MQ131 I2C address is 0x50(80)

I2CDevice device = Bus.getDevice(0x50);

// Get I2C device, ADC121C_MQ9 I2C address is 0x50(80)

I2CDevice device1 = Bus1.getDevice(0x52);


// Read 2 bytes of data

// raw_adc msb, raw_adc lsb

byte[] data = new byte[2];

device.read(0x00, data, 0, 2);

// Read 2 bytes of data

// raw_adc msb, raw_adc lsb

byte[] data1 = new byte[2];

device1.read(0x00, data, 0, 2);

// Convert the data to 12-bits

int raw_adc = ((data[0] & 0x0F) * 256) + (data[1] & 0xFF);

double ppm = (1.99 * raw_adc) / 4095.0 + 0.01;

// Convert the data to 12-bits

int raw_adc1 = (((data[0] & 0x0F) * 256) + (data1[1] & 0xFF);

double ppm1 = ((1000.0 / 4096.0) * raw_adc1) + 10;

// Output data to screen

System.out.printf("Ozone Concentration : %.2f ppm %n", ppm);

System.out.printf("Carbon Monoxide Concentration : %.2f ppm %n", ppm1);









This has its applications in industry or at places where one needs to monitor concentration of gases like CO and Ozone.

  • Gas leakage detection
  • Industrial pollutants detection
  • Vehicles pollutants detection



ADC121C datasheet

MQ131 datasheet

MQ9 datasheet


Leave a Reply