The beginning

Two hamsters in the dorm. One question: are they actually nocturnal?

One infrared sensor and a weekend later, I had a data pipeline.

Architecture

Three layers:

Key code

from influxdb_client import InfluxDBClient, Point

point = (Point("rat_activity")
    .tag("cage", cage_id)
    .field("motion", 1)
    .time(datetime.utcnow()))

write_api.write(bucket=BUCKET, record=point)

What the data showed

Activity spikes at 11pm, stays high until 4am. They're nocturnal. The data confirmed it.

Flux query language is counterintuitive at first, but for time-series aggregation it's genuinely nicer than SQL.