0
0
Raspberry Piprogramming~10 mins

InfluxDB for time-series data in Raspberry Pi - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new InfluxDB client connection.

Raspberry Pi
from influxdb_client import InfluxDBClient

client = InfluxDBClient(url=[1], token="my-token", org="my-org")
Drag options to blanks, or click blank then click option'
A"influxdb://localhost"
B"localhost"
C"http://localhost:8086"
D"8086"
Attempts:
3 left
💡 Hint
Common Mistakes
Using only hostname without protocol and port.
Using incorrect URL format.
2fill in blank
medium

Complete the code to write a point with measurement 'temperature' and field 'value' to InfluxDB.

Raspberry Pi
from influxdb_client import Point

point = Point("temperature").field("value", [1])
write_api.write(bucket="my-bucket", record=point)
Drag options to blanks, or click blank then click option'
A25
Btemperature
C"25"
D"value"
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the number inside quotes making it a string.
Using the field name instead of the value.
3fill in blank
hard

Fix the error in the query to select temperature values from the last hour.

Raspberry Pi
query = 'from(bucket:"my-bucket") |> range(start: [1])'
Drag options to blanks, or click blank then click option'
A"-1d"
B"-1h"
C"now()"
D"1h"
Attempts:
3 left
💡 Hint
Common Mistakes
Using "now()" which is not a valid start time.
Using "1h" which is a positive duration.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each point's time to its temperature value.

Raspberry Pi
result = {record.[1]: record.[2] for record in tables.records}
Drag options to blanks, or click blank then click option'
Atime
Bget_value()
Cvalue
Dget_time()
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'value' attribute which may not exist.
Using 'get_time()' which is not a method.
5fill in blank
hard

Fill all three blanks to write a point with measurement 'humidity', tag 'location', and field 'value'.

Raspberry Pi
point = Point([1]).tag([2], "office").field([3], 60)
Drag options to blanks, or click blank then click option'
A"humidity"
B"location"
C"value"
D"temperature"
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'temperature' instead of 'humidity' for measurement.
Mixing tag and field keys.