Via Air Quality Module, you can control two servo motors attached to the mini pan-tilt kit by choosing one of the given angles - 0, 30, 45, 90, 135, 180 - and adjust the background light in RGB format - 255, 255, 255. And, most importantly, you can monitor the current air quality range generated by the MQ-135 sensor: the GUI notifies you with a warning message if the air quality is deteriorating.

Some of the mentioned products and components in this project are sponsored by digitspace:

Preview: What You Will Learn

Step 1: Read Analog Sensors with MCP3008

Unfortunately, Raspberry Pi does not have a built-in ADC (analog-to-digital converter) by which we can collect information from analog sensors easily as opposed to Arduino. Hence, we need to implement an external ADC in our circuit to collate data from analog sensors like the MQ-135 Air Quality Sensor. I used an MCP3008 8-channel ADC due to its efficiency and simple usage.

I used the Adafruit CircuitPython MCP3xxx library on Raspberry Pi to read analog sensors with MCP3008.

But, you will need to install the Adafruit_Blinka library that provides the CircuitPython support in Python to use the mentioned library.

sudo pip3 install adafruit-blinka

If it is needed, you have to enable the SPI on Raspberry Pi Configuration Settings before executing the command.

Once that's done, from your command line run the following command to install the Adafruit CircuitPython MCP3xxx library.

sudo pip3 install adafruit-circuitpython-mcp3xxx

Then, make the pin connections as follows. Even though the pin connections are well-explained on the project schematic and in the code, I'll leave the following pin connection schematic for MCP3008 besides them.

CH0 refers to the first input pin on the MCP3008 - from 0 to 7.

Step 2: Developing a GUI (Air Quality Module) and Programming Raspberry Pi

To be able to create a GUI in Python, you need to install the guizero module on Raspberry Pi. Then, you can use all the provided widgets and events by the module.

From your command line run the following command to install the guizero module.

sudo pip3 install guizero

You can inspect all instructions and widget settings from here.

RGB Color Interface

Air Quality Interface

Note: While loops are not working while executing the app.display() function.

Mini Pan-Tilt Base Interface

Mini Pan-Tilt Arm Interface

Features

1) Change the background color of the apparatus (RGB).

2) Adjust the position of the servo motors on the mini pan-tilt kit by selecting amidst angles - 0, 30, 45, 90, 135, 180.

3) Get notified when the sensor (MQ-135) detects the occurrence of the air quality deterioration - Status: DANGER.

On Menu Bar:

4) Go to the tutorial page.

5) Inspect the components.

6) Display the elevator pitch.

Connections

Pin connections are well-explained in the code and on the project schematic below.

Connect Raspberry Pi to the screen.

Attach MCP3008 and RGB LED to the mini breadboards. I used a potentiometer to test the value range before connecting the MCP3008 to Raspberry Pi.

Assemble the mini pan-tilt kit and glue the MQ-135 Air Quality Sensor on the mini pan-tilt kit (arm).

Conclusion

After completing all the steps, I affix all parts on an old plastic box and position the apparatus on my desk to collect air quality data and adjust its background color using Air Quality Module (GUI) on my Raspberry Pi :)

Videos

Demonstration