0
0
Raspberry Piprogramming~30 mins

Real-time sensor dashboard in Raspberry Pi - Mini Project: Build & Apply

Choose your learning style9 modes available
Real-time sensor dashboard
📖 Scenario: You are building a simple real-time dashboard on a Raspberry Pi to monitor temperature and humidity sensors in a greenhouse. The dashboard will collect sensor data, filter readings above a certain threshold, and display the results.
🎯 Goal: Create a Python program that stores sensor readings in a dictionary, sets a threshold for temperature, filters the readings above that threshold, and prints the filtered results.
📋 What You'll Learn
Create a dictionary with sensor names as keys and their temperature readings as values.
Create a variable to hold the temperature threshold.
Use a dictionary comprehension to filter sensors with temperature above the threshold.
Print the filtered dictionary showing sensors exceeding the threshold.
💡 Why This Matters
🌍 Real World
Monitoring environmental conditions like temperature and humidity in places such as greenhouses or server rooms helps maintain optimal conditions and prevent damage.
💼 Career
Skills in handling sensor data and filtering it in real-time are useful for IoT developers, embedded systems engineers, and automation specialists.
Progress0 / 4 steps
1
Create sensor data dictionary
Create a dictionary called sensor_readings with these exact entries: 'sensor1': 22.5, 'sensor2': 27.0, 'sensor3': 19.8, 'sensor4': 30.2
Raspberry Pi
Need a hint?

Use curly braces {} to create a dictionary with keys and values separated by colons.

2
Set temperature threshold
Create a variable called temp_threshold and set it to 25.0
Raspberry Pi
Need a hint?

Assign the value 25.0 to the variable temp_threshold.

3
Filter sensors above threshold
Use a dictionary comprehension to create a new dictionary called high_temps that contains only the sensors from sensor_readings with temperature values greater than temp_threshold
Raspberry Pi
Need a hint?

Use {sensor: temp for sensor, temp in sensor_readings.items() if temp > temp_threshold} to filter the dictionary.

4
Print filtered sensor readings
Write a print statement to display the high_temps dictionary
Raspberry Pi
Need a hint?

Use print(high_temps) to show the filtered dictionary.