0
0
Raspberry Piprogramming~20 mins

InfluxDB for time-series data in Raspberry Pi - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
InfluxDB Time-Series Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this InfluxDB query?

Given the following InfluxDB query executed on a Raspberry Pi collecting temperature data every minute, what will be the output?

SELECT mean("value") FROM "temperature" WHERE time > now() - 1h GROUP BY time(10m)

Assume the data has consistent temperature readings every minute for the last hour.

ARaw temperature values for every minute in the last hour
BA list of average temperature values for each 10-minute interval in the last hour
CAn error because GROUP BY time requires a fill() clause
DA single average temperature value for the entire last hour
Attempts:
2 left
💡 Hint

Think about how GROUP BY time() works in InfluxDB queries.

🧠 Conceptual
intermediate
1:30remaining
Which InfluxDB data type is best for storing Raspberry Pi CPU temperature?

You want to store the Raspberry Pi CPU temperature readings in InfluxDB. Which data type should you use for the temperature field?

AFloat
BBoolean
CString
DInteger
Attempts:
2 left
💡 Hint

Temperature values can have decimal points.

🔧 Debug
advanced
2:30remaining
Why does this InfluxDB write command fail on Raspberry Pi?

Consider this Python code snippet trying to write a temperature point to InfluxDB:

from influxdb_client import InfluxDBClient, Point
client = InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org")
write_api = client.write_api()
point = Point("temperature").tag("device", "raspberry_pi").field("value", "45.3")
write_api.write(bucket="sensors", record=point)

It raises a type error. What is the cause?

AThe bucket name "sensors" does not exist
BThe tag key "device" is invalid
CThe field value is a string instead of a float
DThe client URL is incorrect
Attempts:
2 left
💡 Hint

Check the data type passed to the field method.

📝 Syntax
advanced
2:00remaining
Which InfluxDB Flux query correctly calculates max temperature per hour?

Choose the correct Flux query to get the maximum temperature per hour from the "temperature" measurement.

Afrom(bucket: "sensors") |> range(start: -24h) |> filter(fn: (r) => r._measurement == "temperature") |> aggregateWindow(every: 1h, fn: max)
Bfrom(bucket: "sensors") |> range(start: -24h) |> filter(fn: (r) => r._measurement == "temperature") |> window(every: 1h) |> max()
Cfrom(bucket: "sensors") |> range(start: -24h) |> filter(fn: (r) => r._measurement == "temperature") |> max(every: 1h)
Dfrom(bucket: "sensors") |> range(start: -24h) |> filter(fn: (r) => r._measurement == "temperature") |> aggregateWindow(every: 1h, fn: mean)
Attempts:
2 left
💡 Hint

aggregateWindow is used to group data by time intervals and apply aggregation.

🚀 Application
expert
3:00remaining
How many points are stored after this batch write?

You run this Python code on your Raspberry Pi to write temperature data points to InfluxDB:

from influxdb_client import InfluxDBClient, Point
client = InfluxDBClient(url="http://localhost:8086", token="token", org="org")
write_api = client.write_api()
data = [
  Point("temperature").field("value", 20.1).tag("device", "pi1"),
  Point("temperature").field("value", 21.3).tag("device", "pi2"),
  Point("temperature").field("value", 19.8).tag("device", "pi1"),
  Point("humidity").field("value", 55).tag("device", "pi1")
]
write_api.write(bucket="sensors", record=data)

How many points are stored in the "sensors" bucket?

A1 point
B3 points
C2 points
D4 points
Attempts:
2 left
💡 Hint

Each Point object represents one data point.