Main Content

O3-enabled BLE Weather Station Predicting Air Quality w/ TF

Via Nano 33 BLE, collate local weather data, build and train a TensorFlow neural network model, and run the model to predict air quality.

Since the risk of breathing polluted air with poor quality has been increased precipitously in recent decades, measuring air quality to take precautions so as to keep our respiratory system healthy is crucial, especially for sensitive groups, which include people with lung disease such as asthma, older adults, children, teenagers, and people who are active outdoors[1]. Even though there are international efforts to reduce air pollution and deplete air pollutants, tracking air quality locally to get prescient warnings regarding pulmonary risk factors is yet a pressing issue.

Although many factors can lead to poor air quality, the two most common are related to elevated concentrations of ground-level ozone and particulate matter. Ground-level ozone forms when nitrogen oxides (NOx) from sources like vehicle exhaust and industrial emissions react with organic compounds in the presence of heat and sunlight. In other words, ozone forms when two types of pollutants (VOCs and NOx) react in sunlight. These pollutants usually come from vehicles, industries, power plants, and products such as solvents and paints. On the other hand, the particulate matter in the air consists of solid and liquid particles, including smoke, dust, and other aerosols - some of which are by-products of chemical transformations[2].

Furthermore, air pollutants may affect people differently depending on weather conditions. Since different aspects of the weather affect the amounts of ozone and particulates present in a specific area, the vagaries of the weather have a veritable impact on air quality. Sunshine, rain, higher temperatures, wind speed, air turbulence, and mixing depths fluctuate pollutant concentrations. Therefore, tracking air quality levels locally is essential to prevent respiratory disease risks, especially for sensitive groups. However, unfortunately, we still have paltry or inadequate appliances (air quality monitors or weather stations) to track air quality locally in some regions.

After perusing recent research papers on air quality and pollution, I decided to utilize ozone concentration in the air as an indicator of air pollution and create a budget-friendly weather station forecasting air quality levels in the hope of making monitoring air quality levels accessible to anyone. Ground-level ozone (O3) can cause breathing difficulty, aggravate chronic respiratory diseases, make the lungs more susceptible to infection, and increase the frequency of asthma attacks[1]. Therefore, ozone concentration in the air can be utilized as a parameter in addition to local weather data to forecast air quality levels so as to prevent detrimental respiratory disease risks.

Since air quality fluctuates according to various phenomena, some of which are not fully fathomed yet, it is not possible to extrapolate and construe air quality by only employing limited local weather data with ozone concentration without applying algorithms. Hence, I decided to utilize local Air Quality Index (AQI) assessments provided by IQAir as labels to build and train an artificial neural network model to forecast air quality levels based on local weather data with ozone concentration.

I decided to utilize an Arduino Nano 33 BLE in this project since it can easily collect local weather data with ozone concentration and run my neural network model outdoors after being trained. To collect the required data to train my model, I connected an I2C ozone sensor, an anemometer, and a BMP180 precision sensor to the Nano 33 BLE. Then, I added an SSD1306 OLED display to monitor the collected data in the field.

Since I collected local weather data with ozone concentration on my balcony, I was able to transmit the collected data from the Nano 33 BLE to a Raspberry Pi 4 in my house over BLE instead of sending data packets to a web server as usual. In that regard, I was able to transfer data packets via the Nano 33 BLE without requiring any additional procedures.

After completing my data set, I built my artificial neural network model (ANN) with TensorFlow to make predictions on air quality levels (classes) based on local weather data with ozone concentration. By the given date, I assigned an air quality class (label) based on local Air Quality Index (AQI) assessments provided by IQAir for each input:

After training and testing my neural network model, I converted it from a TensorFlow Keras H5 model to a C array (.h file) to execute the model on the Nano 33 BLE. Therefore, the weather station is capable of detecting air quality levels (classes) by running the model in the field precisely.

Lastly, to make the weather station as sturdy and robust as possible while enduring harsh weather conditions, I designed a windmill-themed case (3D printable).

So, this is my project in a nutshell 😃

In the following steps, you can find more detailed information on coding, logging data over BLE, building an artificial neural network model with TensorFlow, and running it on the Nano 33 BLE.”

Link to article