
Weekend Showcase Challenge: Smart Campus Air Quality Monitor β An IoT + AI Agent System
Here's a description you can use for your GitHub repository: π Smart Campus Air Quality Monitor β An IoT + AI Agent system that monitors campus air quality in real-time using ESP32 sensor nodes, AWS IoT Core, Amazon Timestream, and a conversational AI agent powered by Amazon Bedrock (Nova). Built entirely on AWS Free Tier.
Vision & What It Does
Air quality is an invisible crisis on college campuses. Students and faculty spend hours in classrooms, labs, and corridors without knowing whether the air they breathe is safe. Particulate matter, volatile organic compounds, and COβ levels spike during peak hours, yet most institutions lack real-time monitoring β let alone intelligent alerting.
Smart Campus Air Quality Monitor solves this by deploying low-cost IoT sensor nodes across campus that continuously stream environmental data to the cloud. But it goes further than a simple dashboard: at the heart of the system is an AI-powered conversational agent that anyone β students, faculty, or administrators β can ask natural-language questions like:
- "How was the air quality in Block C yesterday?"
- "Which building had the highest COβ levels this week?"
- "Alert me if PM2.5 crosses 150 in the electronics lab."
The system transforms raw sensor telemetry into actionable intelligence, combining the reliability of IoT edge hardware with the accessibility of a conversational AI interface.
Key Features
- Real-time environmental monitoring β Temperature, humidity, COβ, PM2.5, and volatile organic compounds sampled every 30 seconds.
- AI Conversational Agent β Built on Amazon Bedrock (Nova model), the agent queries time-series data and responds in plain English with context-aware summaries.
- Threshold-based alerting β Automated SMS/email notifications via Amazon SNS when any parameter crosses unsafe levels.
- Historical analytics dashboard β A web-based dashboard hosted on AWS Amplify showing trends, heatmaps, and comparative charts across locations.
- Edge-first architecture β Sensor nodes perform local filtering and only transmit meaningful data, reducing bandwidth and cost.
ο»Ώ
How I Built It
Development Process
The project evolved through three phases across the summer:
Phase 1 β Hardware & Connectivity (Week 1)
I started with the sensor nodes. Each node is built around an ESP32 microcontroller connected to:
- MQ-135 β Air quality (COβ, ammonia, benzene detection)
- PMS5003 β Laser-based PM2.5/PM10 particulate sensor
- DHT22 β Temperature and humidity
- Sound sensor module β Ambient noise level
The ESP32 runs MicroPython firmware that reads sensors every 30 seconds, applies a moving-average filter to reduce noise, and publishes a JSON payload over MQTT to AWS IoT Core. I used the TLS mutual authentication model with X.509 certificates provisioned through AWS IoT Device Management.
Phase 2 β Cloud Pipeline & Storage (Week 2)
Once telemetry was flowing, I built the ingestion pipeline:
- AWS IoT Core receives MQTT messages and applies IoT Rules.
- An IoT Rule routes data to a Lambda function that validates the payload schema, enriches it with location metadata, and writes to Amazon Timestream (time-series database optimized for IoT workloads).
- A second IoT Rule evaluates threshold conditions and publishes alerts to an SNS topic, which fans out to email and SMS subscribers.
A key decision was choosing Timestream over DynamoDB for storage. While DynamoDB would work, Timestream's built-in time-series functions (interpolation, smoothing, aggregation over time windows) made analytical queries dramatically simpler.
Phase 3 β AI Agent & Dashboard (Week 3)
This was the most exciting phase. I built a conversational agent using Amazon Bedrock with the Nova model that can:
- Accept natural-language questions about air quality data
- Translate them into Timestream SQL queries
- Summarize results in a human-friendly response
The agent uses a tool-use pattern: it has access to a Lambda function that executes parameterized Timestream queries and returns results. The Nova model decides when and how to call this tool based on the user's question.
For the dashboard, I built a React application deployed on AWS Amplify that connects to an API Gateway β Lambda backend to fetch historical data and render charts using Chart.js.
Challenges & Solutions
Challenge | Solution |
|---|---|
ESP32 WiFi drops in concrete buildings | Implemented automatic reconnection with exponential backoff and local SD card buffering |
Timestream query costs during development | Created a scheduled Lambda that pre-computes hourly aggregates into a summary table |
Agent hallucinating sensor values | Constrained the agent with strict system prompts and tool-only data access β no fabrication allowed |
MQTT payload size limits | Compressed payloads using MessagePack instead of raw JSON, reducing size by 40% |
ο»Ώ
AWS Services Used / Architecture Overview
Architecture Diagram
Plain text
βββββββββββββββββββ MQTT/TLS βββββββββββββββββββββ ESP32 Sensor β βββββββββββββββββββΆβ AWS IoT Core ββ Node (x3) β β (Message Broker)ββββββββββββββββββββ ββββββββββ¬ββββββββββββββββββββββββΌβββββββββββββΌ βΌ βΌββββββββββββ ββββββββββββ ββββββββββββIoT Rule 1β βIoT Rule 2β βIoT Rule 3ββ(Ingest) β β(Alerts) β β(Archive) βββββββ¬ββββββ ββββββ¬ββββββ ββββββ¬ββββββΌ βΌ βΌββββββββββββ ββββββββββββ ββββββββββββ Lambda β β SNS β β S3 ββ(Process) β β(Notify) β β(Raw Log)βββββββ¬ββββββ ββββββββββββ ββββββββββββΌββββββββββββββββ Amazon ββ Timestream ββ (Storage) βββββββββ¬βββββββββββββββββββββββΌβββββββββββββββΌ βΌββββββββββββββββββ ββββββββββββββββββββ Amazon Bedrock β β API Gateway ββ (Nova Agent) β β + Lambda ββ + Lambda Tool β β (Dashboard API)βββββββββββββββββββ ββββββββββ¬ββββββββββΌββββββββββββββββββββ AWS Amplify ββ (React App) ββββββββββββββββββββο»Ώ
AWS Services Summary
Service | Purpose |
|---|---|
AWS IoT Core | MQTT message broker, device authentication, rules engine |
AWS Lambda | Data processing, Timestream writes, agent tool execution, API backend |
Amazon Timestream | Time-series storage for sensor data with built-in analytics |
Amazon Bedrock (Nova) | Conversational AI agent for natural-language data queries |
Amazon SNS | Alert notifications via email and SMS |
Amazon S3 | Raw data archival and static asset hosting |
AWS Amplify | Frontend hosting and CI/CD for the React dashboard |
Amazon API Gateway | RESTful API layer for dashboard data access |
AWS IoT Device Management | Certificate provisioning and device fleet management |
All services used are exclusively AWS and fall within or are optimized for the AWS Free Tier, making this project reproducible at zero cost for new builders. No third-party cloud services are used β the entire stack runs on AWS infrastructure end-to-end.
ο»Ώ
What I Learned Across the Summer
This summer's build series taught me several valuable lessons:
1. The Power of Serverless for IoT
Coming from an electronics background, I was used to thinking about dedicated servers and always-on infrastructure. Discovering that Lambda + IoT Core can handle thousands of messages per second β and you only pay per invocation β was a paradigm shift. For campus-scale IoT, serverless is not just cheaper; it is architecturally simpler.
2. AI Agents Need Guardrails, Not Just Prompts
My first iteration of the Bedrock agent would sometimes fabricate plausible-sounding sensor readings. The fix was not a better prompt β it was architectural: the agent can ONLY access data through its Lambda tool. No tool call, no data in the response. This "tool-gated" pattern is now my default for any data-retrieval agent.
3. Edge Computing Matters
Sending every raw sensor reading to the cloud is wasteful and expensive. By adding a simple moving-average filter and only transmitting when values change beyond a threshold (dead-band filtering), I reduced data transmission by 60% without losing meaningful signal. The ESP32 is powerful enough for this preprocessing.
4. Time-Series Databases Are Worth Learning
I initially stored everything in DynamoDB because it is familiar. Migrating to Timestream cut my query complexity in half. Queries like "average PM2.5 per hour for the last 7 days, grouped by location" went from complex scan-and-filter operations to single SQL statements.
5. Community Inspiration Drives Better Builds
The Summer Build Series community pushed me to think beyond "does it work?" to "is it useful and impressive?" Seeing others build creative agents and apps inspired me to add the conversational AI layer β which turned a standard IoT dashboard into something genuinely novel.
ο»Ώ
Link to App & Repository
- Live Dashboard: Β https://smart-campus-monitor.amplifyapp.comΒ
- GitHub Repository: Β https://github.com/rajkksns/smart-campus-air-monitorΒ
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article