Bird
Raised Fist0
Raspberry Piprogramming~20 mins

Real-time sensor dashboard in Raspberry Pi - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Real-time Sensor Dashboard Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🎯 Scenario
intermediate
2:00remaining
Identify the best data refresh strategy for a real-time sensor dashboard

You are building a dashboard on a Raspberry Pi to display temperature sensor data in real-time. The sensor updates every second. Which data refresh strategy ensures the dashboard shows the latest data without overloading the device?

ARefresh the entire dashboard every second by reloading all data and visuals.
BUse a streaming data connection to update only the temperature value every second.
CRefresh the dashboard once every minute to reduce CPU usage.
DManually refresh the dashboard only when the user clicks a button.
Attempts:
2 left
💡 Hint

Think about updating only what changes frequently to save resources.

❓ dax_lod_result
intermediate
2:00remaining
Calculate average temperature over last 5 minutes using DAX

Given a sensor data table with columns Timestamp and Temperature, which DAX measure correctly calculates the average temperature for the last 5 minutes?

Raspberry Pi
AverageTempLast5Min = CALCULATE(AVERAGE(SensorData[Temperature]), FILTER(SensorData, SensorData[Timestamp] >= NOW() - TIME(0,5,0)))
AAverageTempLast5Min = CALCULATE(AVERAGE(SensorData[Temperature]), SensorData[Timestamp] > NOW() - 5)
BAverageTempLast5Min = AVERAGE(SensorData[Temperature]) WHERE SensorData[Timestamp] >= NOW() - TIME(0,5,0)
CAverageTempLast5Min = CALCULATE(AVERAGE(SensorData[Temperature]), FILTER(SensorData, SensorData[Timestamp] >= NOW() - TIME(0,5,0)))
DAverageTempLast5Min = AVERAGE(FILTER(SensorData, SensorData[Timestamp] >= NOW() - TIME(0,5,0))[Temperature])
Attempts:
2 left
💡 Hint

Use CALCULATE with FILTER and NOW() minus 5 minutes.

❓ visualization
advanced
2:00remaining
Choose the best visualization for showing sensor temperature trends over time

You want to show how temperature changes every second over the last 10 minutes on your dashboard. Which visualization type is best for this purpose?

AA pie chart showing percentage of time temperature was in different ranges.
BA bar chart showing average temperature per minute.
CA scatter plot showing temperature vs humidity.
DA line chart showing temperature on Y-axis and time on X-axis.
Attempts:
2 left
💡 Hint

Think about showing continuous data over time.

🔧 Debug
advanced
2:00remaining
Identify the error in this DAX measure for latest sensor reading

Given this DAX measure to get the latest temperature reading:
LatestTemp = MAXX(FILTER(SensorData, SensorData[Timestamp] = MAX(SensorData[Timestamp])), SensorData[Temperature])
What is the problem with this measure?

AIt returns blank because MAX inside FILTER does not evaluate correctly in row context.
BIt returns the maximum temperature instead of the latest temperature.
CIt causes a circular dependency error because MAX is used inside FILTER on the same column.
DIt returns the latest timestamp but not the temperature value.
Attempts:
2 left
💡 Hint

Consider how MAX inside FILTER behaves in row context.

❓ data_modeling
expert
3:00remaining
Design a data model for multiple sensors with real-time updates

You have multiple sensors sending temperature and humidity data every second. You want to build a dashboard on Raspberry Pi that shows each sensor's latest readings and historical trends. Which data model design is best?

AA table with SensorID and latest readings only, plus a separate archive table for historical data.
BSeparate tables per sensor, each with Timestamp, Temperature, Humidity columns; join them in the dashboard.
COne large table with columns: SensorID, Timestamp, Temperature, Humidity; update this table every second with new rows.
DStore all data in a single JSON file updated every second and parse it in the dashboard.
Attempts:
2 left
💡 Hint

Think about efficient queries for latest and historical data separately.

Practice

(1/5)
1. What is the main purpose of a real-time sensor dashboard on a Raspberry Pi?
easy
A. To run heavy data processing tasks offline
B. To store sensor data for long-term analysis only
C. To display live sensor data instantly for monitoring
D. To control the Raspberry Pi remotely

Solution

  1. Step 1: Understand the dashboard function

    A real-time sensor dashboard shows live data as it changes, helping users monitor conditions instantly.
  2. Step 2: Compare options to purpose

    Only To display live sensor data instantly for monitoring describes displaying live sensor data instantly, which matches the dashboard's main goal.
  3. Final Answer:

    To display live sensor data instantly for monitoring -> Option C
  4. Quick Check:

    Real-time dashboard = live data display [OK]
Hint: Real-time means showing data as it happens [OK]
Common Mistakes:
  • Confusing storage with live display
  • Thinking dashboard controls the device
  • Assuming heavy processing is done on dashboard
2. Which Python code snippet correctly reads a sensor value on Raspberry Pi for real-time updates?
easy
A. sensor_value = sensor.read()
B. sensor_value == sensor.read()
C. sensor.read = sensor_value()
D. sensor_value := sensor.read

Solution

  1. Step 1: Identify correct assignment syntax

    In Python, to assign a value from a function call, use single equals: variable = function().
  2. Step 2: Check each option

    sensor_value = sensor.read() uses correct assignment and function call syntax. Options B and C misuse operators or assignment. sensor_value := sensor.read uses walrus operator incorrectly without parentheses.
  3. Final Answer:

    sensor_value = sensor.read() -> Option A
  4. Quick Check:

    Assignment uses =, not == or := alone [OK]
Hint: Use single = to assign function output to variable [OK]
Common Mistakes:
  • Using == instead of = for assignment
  • Trying to assign function call incorrectly
  • Misusing walrus operator without parentheses
3. Given this Python code snippet for updating a dashboard:
import time
sensor_value = 0
for _ in range(3):
    sensor_value += 5
    print(sensor_value)
    time.sleep(1)

What will be the printed output?
medium
A. 5\n10\n15
B. 0\n5\n10
C. 5\n5\n5
D. 0\n0\n0

Solution

  1. Step 1: Analyze the loop increments

    Initially, sensor_value = 0. Each loop adds 5, so values become 5, then 10, then 15.
  2. Step 2: Confirm printed values

    Each iteration prints the updated sensor_value, so output lines are 5, 10, and 15.
  3. Final Answer:

    5\n10\n15 -> Option A
  4. Quick Check:

    Increment by 5 each loop = 5,10,15 [OK]
Hint: Add increments stepwise and print each [OK]
Common Mistakes:
  • Printing before incrementing
  • Resetting sensor_value inside loop
  • Ignoring loop iterations count
4. You wrote this code to update a sensor dashboard:
while True:
    sensor_value = sensor.read
    print(sensor_value)
    time.sleep(1)

Why does the dashboard not show updated sensor values?
medium
A. Because time.sleep(1) pauses too long
B. Because sensor.read is missing parentheses to call the function
C. Because print() does not display values
D. Because while True causes an infinite loop

Solution

  1. Step 1: Identify function call syntax error

    sensor.read is a function and must be called with parentheses: sensor.read()
  2. Step 2: Understand impact on sensor_value

    Without parentheses, sensor_value stores the function object, not the sensor data, so printed values don't update.
  3. Final Answer:

    Because sensor.read is missing parentheses to call the function -> Option B
  4. Quick Check:

    Function call needs () to get value [OK]
Hint: Always add () to call functions [OK]
Common Mistakes:
  • Ignoring missing parentheses on function calls
  • Blaming sleep for no updates
  • Thinking print() doesn't show output
5. You want to build a real-time dashboard on Raspberry Pi that updates sensor data every second and shows the average of last 5 readings. Which approach is best?
hard
A. Calculate average once at start, then display static value
B. Store all readings forever and calculate average of all data each second
C. Update dashboard only when sensor value changes, ignoring average
D. Store last 5 readings in a list, update every second, calculate average, then update dashboard

Solution

  1. Step 1: Understand real-time averaging requirement

    To show average of last 5 readings updated every second, you must keep a rolling list of last 5 values.
  2. Step 2: Evaluate options for efficiency and accuracy

    Store last 5 readings in a list, update every second, calculate average, then update dashboard correctly stores last 5 readings, updates average each second, and refreshes dashboard. Calculate average once at start, then display static value is static, C ignores averaging, D is inefficient and grows data indefinitely.
  3. Final Answer:

    Store last 5 readings in a list, update every second, calculate average, then update dashboard -> Option D
  4. Quick Check:

    Rolling average needs recent 5 values updated regularly [OK]
Hint: Keep fixed-size list for rolling average updates [OK]
Common Mistakes:
  • Calculating average only once
  • Ignoring rolling window for average
  • Storing unlimited data causing slowdowns
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard