0

I built a little setup with a raspberry pi and a temperature and humidity sensor. Every 5 minutes it reads sensor values and sends them both + a timestamp and a custom ID (there are multiple pis, each with its own ID) to a nodejs API which then stores them in a single mongodb collection. A GET request to this API then returns all objects from the collection with the id provided via GET.

Here is a json sample object of the data structure from my collection:

{
    "_id": "5c935a046b4fcc27f2a81cd8",
    "id": "livingroom",
    "time": "2019-03-21 10:31:48.601374",
    "temp": "22.0",
    "hum": "46.0"
}

Im pretty new to mongodb and databases in general but my programming experience tells me that just dumping everything into a single collection is not a good way to handle my data (propably, I really don't know).

So my question is: Are there any big gotchas of me handling my data like this or am I fine for this projects scope? Do I need to expect big performance hits if this collection gets too big?

0

The data you are generating from raspberry pi, temperature and humidity sensor is a time series data. MongoDB has documented some best practices and key tips for storing the time series data.

Time Series Data and MongoDB: Part 2 – Schema Design Best Practices

This explains the following schema patterns for time series data.

Scenario 1: One document per data point

Scenario 2: Time-based bucketing of one document per minute

Scenario 3: Size-based bucketing

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.