Bird
0
0

You want to store sensor data with multiple tags and fields in InfluxDB on Raspberry Pi. Which Python dictionary correctly represents a data point for writing with the client?

hard🚀 Application Q9 of 15
Raspberry Pi - Data Logging and Databases
You want to store sensor data with multiple tags and fields in InfluxDB on Raspberry Pi. Which Python dictionary correctly represents a data point for writing with the client?
A{"measurement": "sensor", "tags": {"temp": 21.5, "humidity": 45}, "fields": {"location": "lab", "device": "A1"}}
B{"measurement": "sensor", "fields": {"location": "lab", "device": "A1"}, "tags": {"temp": 21.5, "humidity": 45}}
C{"measurement": "sensor", "fields": {"temp": "21.5", "humidity": "45"}, "tags": {"location": "lab", "device": "A1"}}
D{"measurement": "sensor", "tags": {"location": "lab", "device": "A1"}, "fields": {"temp": 21.5, "humidity": 45}}
Step-by-Step Solution
Solution:
  1. Step 1: Understand tags vs fields

    Tags are indexed strings used for metadata; fields are actual data values (numbers or strings).
  2. Step 2: Check data types and placement

    {"measurement": "sensor", "tags": {"location": "lab", "device": "A1"}, "fields": {"temp": 21.5, "humidity": 45}} correctly places location and device as tags, temp and humidity as fields with numeric values.
  3. Final Answer:

    {"measurement": "sensor", "tags": {"location": "lab", "device": "A1"}, "fields": {"temp": 21.5, "humidity": 45}} -> Option D
  4. Quick Check:

    Tags = metadata strings, Fields = data values [OK]
Quick Trick: Tags = strings, Fields = numeric or string data [OK]
Common Mistakes:
MISTAKES
  • Swapping tags and fields
  • Using numeric tags
  • Storing numbers as strings in fields

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes