Measuring Nairobi’s air quality using locally assembled low-cost sensors

How low cost sensors are tracking air quality in East Africa’s largest city



Air quality sensor inside a protective plastic tube with air intake on the left.

Like many African cities, Nairobi does not regularly monitor its urban air quality, even as the levels of air pollution worsen to the point where a brown haze regularly develops over the central business district.

While Kenya has gazetted laws such as the Air Quality Regulations passed in 2014 to limit air pollution and protect the air that we breathe, there is limited information on the level of particulate air pollutants in Nairobi, and this lack of data makes it difficult to assess the potential impact of air pollution in order to adequately respond to the threats posed by poor air quality.

To plug this information gap, Code for Africa’s sensors.AFRICA project is collecting data on air pollution across the continent, with 22 low-cost air quality sensors collecting data that can be used by the media, citizens, civic watchdogs and governments to push for regulations that will ensure cleaner air, and for people living in polluted environments to take action to protect themselves.

Three of these sensors are located in Nairobi, with one situated at Code for Africa’s civic lab along Nairobi’s Ngong Road. This area is mainly residential, with several commercial buildings as well, meaning that the area sees a significant amount of traffic, and consequently a lot of air pollution, every day.

Three sensors have been deployed in Nairobi, one at the Code for Africa office on Ngong Road, another at Muthurwa Primary School, and one at Lenana.

The sensors measure levels of particulate matter and pollutants such as carbon monoxide and nitrous oxides that have been linked to respiratory ailments and health problems linked to lung cancer and other deadly diseases.

Particulate matter is one of the deadliest air pollutants, and its width is measured in micrometers. PM10 is particulate matter 10 micrometers or less in diameter, and PM2.5 is particulate matter 2.5 micrometers or less in diameter. For comparison, a human hair is about 100 micrometers, so roughly 40 PM2.5 particles could be placed on one hair’s breadth.

The air quality sensor consists of an SDS011 particulate matter sensor, a DHT22 Temperature and Humidity Sensor, and a GSM SIM800L tool that transmits data in real time. All these components are connected to a NodeMCU microcontroller, which reads data from the various sensors and controls their operations.

The NodeMCU microcontroller has a wifi module onboard making communication of IoT projects a breeze.

The SDS011 particulate matter sensor can measure PM10 and PM2.5 particles for concentration ranges between 0–999 micrograms per cubic meter. It uses laser scattering to measure particle concentration between 0.3 to 10 micrograms in the air.

Components of the air quality sensor

Air passes through an inlet and then through the detection area before being ejected from the sensor through the inbuilt fan. The particles pass a laser, scattering the light and transforming it into electrical signals. These signals show the number and diameter of the particles contained in the air sample.

The sensor has a response time of 10 seconds, making data collected near real time.

In order to establish a baseline on air quality levels, it is therefore necessary to check just how much air pollution is linked to motor vehicle exhaust fumes. It is not often that Nairobi’s roads are cleared of vehicles, but last year’s repeat presidential election provided the chance to measure what the city’s air quality looks like with no cars on the roads.

In 2017, October 25 and 26 were declared public holidays in Kenya on the occasion of the repeat presidential election, which meant there were few cars — mainly police and emergency service vehicles — on the streets of Nairobi. As a result, we had a chance to see what a ‘car-free’ day would look like.

By graphing the air quality from October 26, as well as the week of the election and the whole month of October, we can then determine the quality of the city’s air over the period in question.

The graphs were made on Tableau Public, and the datasets are available on

From the graph, we can see that there was a sharp decline in the level of particulate matter on election day, with levels going back up as normal traffic resumed. The dip started from 2pm on the 25th, lasting until noon on the 26th.

There was a spike in particulate matter detected on the days leading up to election day, presumably as people traveled out of Nairobi, but it is clear that on the day of the election, the levels of particulate matter detected were much lower than normal.

Therefore, we can see that the limited number of vehicles on the roads on the 26th led to much lower levels of air pollution than normal, as would be expected.

With this project in place, we hope to collect accurate and reliable data on Nairobi’s air quality, making it possible to put intervention measures in place to reduce the threat posed to human health, and improving the overall well-being of the city’s residents.

Written by Eric Mugendi, Programme Manager at Code for Africa

Are you worried about #AirQuality in your community? You can host your own air sensor or find neighbours who care about the issue in your city by joining here:

sensors.AFRICA is a pan-African citizen science initiative that uses simple open source sensors to monitor air, water and sound pollution. We work with watchdog media and civil society organisations to turn the resulting data into actionable information for citizens.

sensors.AFRICA is incubated by Code for Africa, with seed-funding from the innovateAFRICA.Fund, and additional support from the Global Partnership for Sustainable Development Data and Liquid Telecom and the World Bank.

Follow Us
Like Us
Email Us

Code for Africa (CfA) builds digital democracies. It is the continent’s largest network of civic technology and open data laboratories, with labs in 5 African countries, affiliate labs in another 5 African countries and funded projects in a further 15 countries. CfA manages the and, as well as key digital democracy resources such as and, and also incubates a range of pioneering initiatives ranging from to




A pan-African citizen science initiative using sensors to monitor air, water and sound pollution to give citizens actionable information about their cities.