Skip to main content

Raspberry Pi Traffic Light Changes Based on Air Quality

Raspberry Pi
(Image credit: Dmytro Panin)

This Raspberry Pi project looks like a toy but it's actually a useful air quality reporting system. It was created by maker Dmytro Panin who used a toy traffic light alongside a Raspberry Pi 3B+ to create the final design.

The best Raspberry Pi projects improve our quality of life and this project is no exception. According to Panin, his area is currently experiencing a season of peat fires which can cause the smog levels of the city to increase dramatically and unexpectedly. This project aims to reduce unwanted exposure to higher pollution levels.

The Raspberry Pi is housed inside of a Lego-compatible case. The toy traffic light is connected to the GPIO of the Pi which pulls air quality data from an aggregated API. When the air quality levels change, the light changes to correspond with the level of pollution. The green light is optimal while the red light indicates poor quality air.

The script used to pull air quality data was written using Go while a Python script is responsible for changing the lights on the traffic signal. The LEDs are controlled using GPIO Zero, an easy to use Python library designed to simplify electronics, created by Ben Nuttall who we recently had the pleasure of featuring on our Raspberry Pi-themed podcast, The Pi Cast.

To take a closer look at this project, check out the project page at GitHub and follow Dmytro Panin for more cool creations.