MQ-2, MQ-3, MQ-4, MQ-135, MQ-6, MQ-7, MQ-8, MQ-9 air sensors combined together in a Raspberry project.

George Soloupis
2 min readApr 23, 2022


Written by George Soloupis ML GDE.

This is an effort to combine together all the basic air sensors to a single Raspberry project and create a solution that can help those with smell impairment identify food degradation. Raspberry Pi is used to collect data from air sensors over time during the food degradation process. The sensors collect data of the chemical elements such as ammonia (NH3), H2s, O3, CO, CH4. The data is then evaluated with the help of Tensorflow. As an end result the users with no advanced technical knowledge will be able to see food quality values on an app built on Android, Kotlin.

The final set up looks like this:

Set up of combined simple air sensors.

Sensors that have been used:

  • MQ-2 (Methane, Butane, LPG, smoke)
  • MQ-3 (Alcohol, Ethanol, smoke)
  • MQ-4 (Methane, CNG Gas)
  • MQ-135 (Benzene, Alcohol, smoke)
  • MQ-6 (LPG, butane gas)
  • MQ-7 (Carbon Monoxide)
  • MQ-8 (Hydrogen Gas)
  • MQ-9 (Carbon Monoxide, flammable gasses)

Each sensor’s diagram is:

Sensor’s circuit diagram.

Other hardware that has been used:

  • MCP3008 analog-to-digital converter

Explanation of the whole set up and usage of the Raspberry Pi can be found at this tutorial.

Python scripts with details and data that are derived from the sensors’ pdfs:

After usage of the init script then with intervals of 60 seconds the data that are collected are like:

Data that are collected every 60 seconds.


This was an effort to update every script for the basic sensors used above. You can view the pdfs with the details and all the sensor values inside the python scripts. Usage of the sensors are with the Circuit python library that is up to date. Stay tuned for the machine learning processing of the data.



George Soloupis

I am a pharmacist turned android developer and machine learning engineer. Right now I’m a senior android developer at Invisalign, a ML & Android GDE.