0
0
Raspberry Piprogramming~10 mins

Real-time sensor dashboard in Raspberry Pi - Interactive Code Practice

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

Complete the code to import the library needed to read sensor data.

Raspberry Pi
import [1]
Drag options to blanks, or click blank then click option'
Agpiozero
Btime
Cos
Dsys
Attempts:
3 left
💡 Hint
Common Mistakes
Importing unrelated libraries like os or sys.
Forgetting to import gpiozero for sensor control.
2fill in blank
medium

Complete the code to create a temperature sensor object on GPIO pin 4.

Raspberry Pi
sensor = gpiozero.TemperatureSensor([1])
Drag options to blanks, or click blank then click option'
A17
B4
C22
D27
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong pin numbers that don't match the hardware setup.
Confusing pin numbers with sensor types.
3fill in blank
hard

Fix the error in the code to read the current temperature value.

Raspberry Pi
current_temp = sensor.[1]
Drag options to blanks, or click blank then click option'
Avalue
Btemperature()
Cget()
Dread()
Attempts:
3 left
💡 Hint
Common Mistakes
Calling a method that does not exist like read() or get().
Using parentheses with a property.
4fill in blank
hard

Fill both blanks to create a dictionary with sensor name and its current value.

Raspberry Pi
sensor_data = [1]: [2]
Drag options to blanks, or click blank then click option'
A'temperature'
Bsensor.value
C'humidity'
Dsensor.read
Attempts:
3 left
💡 Hint
Common Mistakes
Using method calls instead of properties for sensor value.
Not using quotes around the dictionary key.
5fill in blank
hard

Fill all three blanks to create a dashboard update function that prints sensor data with a label.

Raspberry Pi
def update_dashboard():
    print(f"[1]: [2] °C")
    return [3]
Drag options to blanks, or click blank then click option'
A'Temperature'
Bsensor.value
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Using method calls instead of properties for sensor value.
Returning the sensor value instead of None.