0
0
IOT Protocolsdevops~10 mins

IoT analytics and dashboards in IOT Protocols - Interactive Code Practice

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

Complete the code to subscribe to the MQTT topic for receiving sensor data.

IOT Protocols
client.subscribe('[1]')
Drag options to blanks, or click blank then click option'
Adisconnect
Bconnect
Csensor/data
Dpublish
Attempts:
3 left
💡 Hint
Common Mistakes
Using MQTT client methods like 'connect' or 'publish' instead of a topic name.
2fill in blank
medium

Complete the code to filter incoming data points where temperature is above 30 degrees.

IOT Protocols
filtered_data = [d for d in data if d['temperature'] [1] 30]
Drag options to blanks, or click blank then click option'
A>
B<
C==
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' or '<=' which would filter lower temperatures.
3fill in blank
hard

Fix the error in the code to publish JSON data to the MQTT topic.

IOT Protocols
client.publish('sensor/data', [1].dumps(payload))
Drag options to blanks, or click blank then click option'
Axml
Bjson
Cyaml
Dcsv
Attempts:
3 left
💡 Hint
Common Mistakes
Using unsupported formats like 'yaml', 'xml', or 'csv' which cause errors.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps device IDs to their latest temperature readings if above 25.

IOT Protocols
{device['id']: device['temperature'] for device in devices if device['temperature'] [1] [2]
Drag options to blanks, or click blank then click option'
A>
B25
C<
D30
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' or wrong threshold values which filter incorrect devices.
5fill in blank
hard

Fill all four blanks to create a dictionary comprehension that maps sensor names in uppercase to their values if the value is below 50.

IOT Protocols
{ [1]: [2] for [3], [4] in sensors.items() if [2] < 50 }
Drag options to blanks, or click blank then click option'
Aname.upper()
Bvalue
Cname
Dsensor
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variable names or forgetting to convert names to uppercase.