1. Learn
  2. /
  3. Courses
  4. /
  5. Analyzing IoT Data in Python

Exercise

Cache Datastream

You will now gather data from 2 energy counters. This is a very minimalistic data stream, which only provides the measurement device and the value, separated by a colon.

This looks as follows: C331,6020

Since there is no time in the measurement itself, you need to rely on the time the message was submitted to the MQTT broker. This timestamp is available as payload.timestamp in epoch format.

Instructions 1/2

undefined XP
    1
    2
  • Within the callback function, combine message timestamp and payload, separated by a colon (,) and store it as data.
  • Append data to the caching list cache.