Sefism is free for learners. We are here to help you grow, one step at a time.Join for free
Sefism.
IoT & Embedded

IoT Sensor Readings Store with Bucketed Time Series in MongoDB

Build a temperature and humidity monitoring system for vaccine and medicine fridges in small clinics and pharmacies, storing millions of sensor readings in MongoDB. The core of the project is a measured comparison of the hand-built bucket pattern with native time series collections, plus TTL retention and live dashboards built from aggregation pipelines.

Difficulty

Intermediate

A small team, or one strong student willing to learn something new.
Effort

1 semester · 2 to 3 students

Deliverables

8 to ship

4 optional extras

Suggested stack

ESP32 with DHT22 or DS18B20 sensorsMQTT (Mosquitto)Node.js or Python ingestion serviceMongoDB time series collectionsReact or Next.js dashboardmongosh and Compass
A suggestion, not a requirement. Swap anything for what you already know.

What you should ship

  • At least two physical sensor nodes sending readings every 30 seconds over MQTT, plus a simulator that generates 100 or more virtual sensors
  • An ingestion service that writes readings in batches and survives a database or network outage without losing buffered readings
  • Two storage designs holding the same data: a hand-built bucket pattern collection and a native time series collection
  • A benchmark report comparing storage size, index size, write throughput and dashboard query latency for both designs
  • Retention: raw readings expire automatically with a TTL setting, while hourly summaries are kept for a year
  • A dashboard showing live readings, 24-hour and 7-day charts per fridge, and minimum, maximum and average per hour
  • Excursion alerts when a fridge stays outside a safe range for a set time, with an acknowledgement flow
  • A weekly compliance report per site built from an aggregation pipeline, exportable as PDF or CSV

If you have time left

  • Detect a fridge door left open or a failing compressor from the shape of the curve, using window functions
  • Fill gaps from power cuts in charts with $densify and $fill, clearly marked as missing data
  • Offline buffering on the device itself, with readings back-filled when Wi-Fi returns
  • A multi-tenant model where a pharmacy chain sees all its branches and each branch sees only its own

The problem: small clinics cannot see their cold chain

Vaccines, insulin and many other medicines must be stored within a narrow temperature range, commonly 2 to 8 °C. Large hospitals and national programmes use dedicated temperature loggers, but many small clinics and pharmacies still rely on a thermometer checked once or twice a day and a paper log. A fridge that warms up overnight during a long power cut, or because a door was left ajar, can go unnoticed until the stock has to be thrown away.

Sensors are cheap. The hard part is the data: a fridge reporting every 30 seconds produces nearly three thousand readings a day, a pharmacy chain with a hundred fridges produces millions a month, and the dashboards still have to be fast. How you store that time series in MongoDB decides whether the system stays quick and affordable, which is what makes it a good final year project.

What already exists and the gap

  • WHO prequalified temperature monitoring devices, such as 30-day electronic temperature loggers, are used in national immunisation programmes, but they are standalone devices and their data is often read manually.
  • ThingSpeak, AWS IoT SiteWise and Azure IoT offer IoT data platforms, powerful but general, with pricing and setup that do not suit a single pharmacy.
  • InfluxDB and TimescaleDB are databases built for time series, and Grafana is the usual dashboard on top.

The gap is a small, affordable monitoring system built for clinics, with alerts and compliance reports they can actually use, and a backend whose storage design you have measured rather than assumed.

Inspiration

MongoDB's Building with Patterns series introduced the bucket pattern using exactly this kind of IoT example: group many readings into one document per sensor per time window instead of one document per reading. MongoDB later built the same idea into the database as time series collections, which bucket readings internally. Comparing the two, on your own data, is the heart of this project.

What you build

  • Clinic staff: see every fridge's current temperature, get an alert on excursions, acknowledge it with a note.
  • Pharmacy or clinic manager: see all sites, open 24-hour and 7-day charts, download a weekly compliance report.
  • Devices: ESP32 boards with a sensor, sending readings over MQTT to an ingestion service.

Main flows: device sends readings, dashboard updates, a fridge drifts out of range, an alert fires and is acknowledged, a weekly report is generated.

The technically interesting part

  • One document per reading versus buckets. Start with the naive design so you have a baseline, then build a bucket pattern collection: one document per sensor per hour with an array of readings plus pre-computed count, sum, min and max (the computed pattern), updated with $push and $inc in a single upsert. Watch for the unbounded array trap and cap each bucket.
  • Native time series collections. Create a time series collection with a timeField, a metaField holding the sensor and site, and a suitable granularity. Measure it against your hand-built buckets on storage, index size, write throughput and query speed. Check the current manual for which update and delete operations time series collections allow, since that affects corrections to bad readings.
  • Retention with TTL. Expire raw readings after a set period with expireAfterSeconds, while hourly summaries written by a scheduled $merge pipeline are kept longer. Decide and justify the retention periods.
  • Dashboards from aggregation. Use $match on sensor and time range first, $dateTrunc or $group to roll readings up per hour, and $setWindowFields for moving averages. Every chart should be one pipeline you can explain.
  • Indexes. A compound index on sensor and time for the bucket design; the time series collection's own indexing for the other. Prove both with explain output.

Show your supervisor the three schemas side by side, the benchmark table, and a dashboard query's explain plan.

How to evaluate it

  • Storage: data and index size per million readings for each design, from collection statistics.
  • Writes: sustained readings per second from the simulator before errors or backlog appear.
  • Reads: p95 latency for the 24-hour chart, the 7-day chart and the weekly report on 10 million readings.
  • Alerts: time from a fridge leaving the safe range to the alert appearing, measured on real hardware with a warm hand or an open door.
  • Resilience: unplug the network for ten minutes and show no readings were lost.

Mind the free tier: an Atlas free cluster has 512 MB of storage, so run large benchmarks on a local MongoDB and keep the free cluster for the demo.

Suggested plan

  • Weeks 1 to 2: hardware, MQTT, a simulator, and the naive one-document-per-reading store.
  • Weeks 3 to 5: ingestion service with batching and buffering, bucket pattern design.
  • Weeks 6 to 8: time series collection design, TTL, hourly summaries.
  • Weeks 9 to 11: benchmarks at scale, dashboard, alerts.
  • Weeks 12 to 15: compliance report, field test in a real or borrowed fridge, report.

Path to a product

Cold chain monitoring is a real business: pharmacies, clinics, vaccine stores, blood banks, restaurants and food distributors all need it, and many still use paper logs. A low-cost sensor kit plus a monthly subscription for dashboards, alerts and compliance reports is a proven model. Start with one pharmacy chain or clinic network willing to pilot it, and let their compliance reports sell it to the next.

Scope warning

Do not design custom PCBs or build your own mobile app in the core scope; development boards and a responsive web dashboard are enough. Support one sensor type well. Do not attempt certification of the device as a medical instrument.

Learn what you need on Sefism

Get help with this idea

The risk here is spending the semester on hardware and leaving the storage design untested. Tauseef can help you set up the schema comparison early, size the benchmark to your hardware, and turn the results into the core of your report. If you are new here, create a free account first.

Ideas and guidance, not finished projects

These are project ideas and scoping guidance, published free for students to use as a starting point. I do not build, write, or sell final-year projects, and I do not complete coursework for anyone. Take an idea, make it yours, and build it.

Not sure this one fits you?

I help students pick an idea that matches their skills and their deadline, then scope it down until it is finishable. Guidance only, never done for you.

Discuss this idea
Work with me

Stuck on something specific?

Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.