📖 Scenario: You are working on a simple IoT project to manage Bluetooth Low Energy (BLE) devices like wearables and beacons. These devices send small packets of data that you want to organize and analyze.Imagine you have a list of BLE devices with their IDs and signal strengths. You want to filter and display only the devices with a strong enough signal to connect reliably.
🎯 Goal: Build a small program that stores BLE device data, sets a signal strength threshold, filters devices based on this threshold, and then displays the filtered list.
📋 What You'll Learn
Create a dictionary with device IDs as keys and their signal strengths as values
Add a variable to set the minimum signal strength threshold
Use a dictionary comprehension to filter devices with signal strength above the threshold
Print the filtered dictionary showing only strong signal devices
💡 Why This Matters
🌍 Real World
BLE devices like wearables and beacons send small data packets with signal strength. Filtering helps decide which devices to connect to for better performance.
💼 Career
Understanding BLE data handling is useful for IoT developers, network engineers, and DevOps professionals managing device fleets.
Progress0 / 4 steps
1
Create BLE devices data
Create a dictionary called ble_devices with these exact entries: 'device_1': -70, 'device_2': -85, 'device_3': -60, 'device_4': -90
IOT Protocols
Hint
Use curly braces to create a dictionary. Each device ID is a key, and its signal strength is the value.
2
Set signal strength threshold
Create a variable called signal_threshold and set it to -75 to represent the minimum signal strength to consider a device strong.
IOT Protocols
Hint
Just assign the number -75 to the variable signal_threshold.
3
Filter devices with strong signals
Use a dictionary comprehension to create a new dictionary called strong_devices that includes only devices from ble_devices with signal strength greater than signal_threshold.
IOT Protocols
Hint
Use the syntax: {key: value for key, value in dictionary.items() if condition}
4
Display strong BLE devices
Write a print statement to display the strong_devices dictionary.
IOT Protocols
Hint
Use print(strong_devices) to show the filtered devices.
Practice
(1/5)
1. What is the main advantage of using BLE (Bluetooth Low Energy) for wearables and beacons?
easy
A. It requires no pairing or security.
B. It provides very high data transfer speeds.
C. It uses very little power, extending battery life.
D. It works only with smartphones.
Solution
Step 1: Understand BLE's design goal
BLE is designed to use minimal power to keep small devices running longer on batteries.
Step 2: Compare options
High speed is not BLE's focus, pairing is often needed, and BLE works with many devices, not just smartphones.
Final Answer:
It uses very little power, extending battery life. -> Option C
Quick Check:
Low power = A [OK]
Hint: Remember BLE is for low power, not high speed [OK]
Common Mistakes:
Confusing BLE with classic Bluetooth speed
Thinking BLE needs no pairing always
Assuming BLE only works with phones
2. Which of the following is the correct BLE advertising packet type used by beacons to broadcast data without connection?
easy
A. Connectable Directed Advertising
B. Extended Advertising
C. Scan Response Advertising
D. Non-Connectable Undirected Advertising
Solution
Step 1: Identify advertising types
Beacons typically use Non-Connectable Undirected Advertising to broadcast data without needing a connection.
Step 2: Eliminate other options
Connectable Directed requires connection, Scan Response is a reply to scans, Extended Advertising is newer but not typical for simple beacons.
Final Answer:
Non-Connectable Undirected Advertising -> Option D