Dhaka consistently ranks among the most polluted cities in the world. But knowing the air is "bad" isn't enough to solve the problem. Micro-climates exist; the air quality in an industrial zone like Tejgaon is drastically different from a residential area like Dhanmondi at any given hour. To combat a problem of this scale, we need localized, real-time data.
This engineering log documents VSC.BD's most ambitious infrastructure project to date: building a decentralized, district-wide Air Quality Index (AQI) monitoring network using Raspberry Pi nodes. We are moving from single-device robotics to large-scale, distributed IoT architecture.
1. The Core Philosophy: Grid Over Gadget
A single, highly expensive air quality monitor placed on top of a government building provides a generalized average, but it ignores the reality of street-level exposure. Our approach is different. We designed affordable, scalable "Nodes" that can be deployed by students, schools, and volunteers across 64 districts. It is the power of a synchronized network.
// LOGICAL_ENGINEERING_NOTE
In distributed systems, the failure of one node should never crash the network. By utilizing a publish-subscribe (Pub/Sub) messaging protocol like MQTT, our architecture ensures that if a sensor in Mirpur goes offline due to a power outage, the central server continues to aggregate data from all other active nodes seamlessly.
2. The Hardware Node Architecture
Each deployment node needs to be self-sufficient, weather-resistant, and capable of transmitting data over Wi-Fi or Cellular networks. Here is the hardware stack for a single VSC.BD AQI Node:
- The Processing Unit (Raspberry Pi Zero 2 W): Why not an Arduino? Because a Raspberry Pi runs a full Linux OS (Debian). It can natively run Python scripts, handle secure MQTT connections, and temporarily store data locally if the internet connection drops, preventing data loss.
- The Sensor (PMS5003): This is a high-precision laser dust sensor. Unlike cheap analog sensors that guess dust levels, the PMS5003 uses laser scattering to physically count airborne particles, giving us accurate readings for PM1.0, PM2.5, and PM10.
- Environmental Sensor (BME680): We paired the dust sensor with a Bosch BME680 to measure Temperature, Humidity, Barometric Pressure, and Volatile Organic Compounds (VOCs).
- Enclosure: A custom 3D-printed, weather-proof Stevenson Screen enclosure that allows air to flow freely while protecting the electronics from rain and direct sunlight.
3. The Data Pipeline: MQTT & Python
To transmit the data, we use MQTT (Message Queuing Telemetry Transport), the industry standard for IoT. It is extremely lightweight, meaning it consumes very little bandwidth—perfect for unstable internet connections in remote areas.
Each Raspberry Pi reads the Serial (UART) data from the PMS5003 sensor, formats it into a JSON payload, and publishes it to our central broker under a specific topic (e.g., vscbd/dhaka/dhanmondi/aqi).
4. The Codebase: Reading Laser Data
Below is a simplified Python script running on the Raspberry Pi. It demonstrates how we read raw bytes from the PMS5003 laser sensor, decode the checksum, and extract the precise PM2.5 particle concentration.
import serial
import time
import paho.mqtt.client as mqtt
import json
# Configure Serial Port for PMS5003
ser = serial.Serial('/dev/ttyS0', baudrate=9600, timeout=2)
# MQTT Broker Configuration
BROKER = "mqtt.vscbd.org"
TOPIC = "vscbd/dhaka/node-01/aqi"
client = mqtt.Client()
client.connect(BROKER, 1883, 60)
def read_pms5003():
while True:
# Wait for start bytes (0x42, 0x4D)
if ord(ser.read()) == 0x42 and ord(ser.read()) == 0x4D:
data = ser.read(30) # Read the remaining 30 bytes
if len(data) == 30:
# Extract PM2.5 and PM10 (Standard Particle)
pm25 = (data[10] << 8) | data[11]
pm10 = (data[12] << 8) | data[13]
return pm25, pm10
while True:
try:
pm25_val, pm10_val = read_pms5003()
# Package data as JSON
payload = {
"node_id": "DHAKA_01",
"pm25": pm25_val,
"pm10": pm10_val,
"timestamp": int(time.time())
}
# Publish to VSC.BD Cloud
client.publish(TOPIC, json.dumps(payload))
print(f"Published: PM2.5 = {pm25_val} µg/m³")
time.sleep(60) # Sample every minute
except Exception as e:
print(f"Sensor Error: {e}")
time.sleep(5)
5. Real-World Challenges and Deployment
Engineering in the lab is easy; engineering on the streets of Dhaka is hard. Our biggest challenge was power. Many deployment locations lacked a continuous 5V power supply. To solve this, we integrated a solar charging circuit with an 18650 Lithium-Ion battery pack for each node. During the day, the solar panel powers the Pi and charges the battery, ensuring uninterrupted data collection through the night.
Furthermore, the dust in Bangladesh is highly abrasive. The intake fans on the PMS5003 sensors required periodic maintenance. We implemented a self-cleaning script where the sensor fan runs at maximum RPM for 10 seconds every 24 hours to blow out accumulated large particles.
6. The Future: AI-Driven Pollution Forecasting
With dozens of nodes continuously feeding data into our central servers, we are building one of the largest open-source environmental datasets in the country. Our next phase involves feeding this historical data into a Machine Learning model (LSTM networks) to predict air quality spikes 24 to 48 hours in advance.
At VSC.BD, we believe that logical engineering isn't just about building robots; it's about utilizing technology to protect our communities and drive systemic change.