Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is a device shadow (digital twin) in IoT?
A device shadow is a virtual copy of a physical device that stores its last reported state and desired future state. It helps applications interact with devices even when they are offline.
Click to reveal answer
beginner
How does a device shadow help when a device is offline?
It keeps the device's last known state and desired state so applications can read or update the device's status. When the device reconnects, it syncs with the shadow to update its actual state.
Click to reveal answer
intermediate
What are the main parts of a device shadow document?
The main parts are: 1. Desired state - what the device should be. 2. Reported state - what the device actually is. 3. Metadata - info about timestamps. 4. Version - tracks updates.
Click to reveal answer
beginner
Which protocol commonly uses device shadows for IoT devices?
MQTT (Message Queuing Telemetry Transport) is commonly used with device shadows to send and receive state updates efficiently.
Click to reveal answer
beginner
Why is a device shadow also called a digital twin?
Because it acts like a digital copy of a physical device, mirroring its state and behavior in software to enable remote monitoring and control.
Click to reveal answer
What does the 'desired state' in a device shadow represent?
AThe state the device should have
BThe last reported state from the device
CThe device's hardware specifications
DThe network status of the device
✗ Incorrect
The desired state is what the device should be set to, as requested by applications or users.
How does a device shadow help when the physical device is offline?
AIt turns off the device remotely
BIt deletes the device data
CIt stores the device's state so apps can still read and update it
DIt disables network communication
✗ Incorrect
The device shadow keeps the last known and desired states so apps can interact with the device virtually.
Which protocol is most commonly used with device shadows?
AMQTT
BFTP
CHTTP
DSMTP
✗ Incorrect
MQTT is a lightweight messaging protocol ideal for IoT and device shadow communication.
What happens when a device reconnects after being offline?
AIt ignores the device shadow
BIt syncs its actual state with the device shadow
CIt resets to factory settings
DIt deletes the device shadow
✗ Incorrect
The device updates the shadow with its current state and applies any desired state changes.
What is the main benefit of using a device shadow?
ABlocks unauthorized access
BIncreases device battery life
CImproves device hardware speed
DAllows remote control and monitoring even if the device is offline
✗ Incorrect
Device shadows enable apps to interact with devices virtually, improving reliability and control.
Explain what a device shadow is and how it helps in managing IoT devices.
Think of it as a mirror of your device in the cloud.
You got /4 concepts.
Describe the main components of a device shadow document and their roles.
Consider what information is needed to track device status and changes.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of a device shadow in IoT?
easy
A. To keep a virtual copy of a device's state for synchronization
B. To physically store device hardware components
C. To replace the device's firmware remotely
D. To encrypt device communication data
Solution
Step 1: Understand device shadow concept
A device shadow is a virtual representation of a device's state, not a physical component or firmware.
Step 2: Identify its main use
It stores desired and reported states to keep device and cloud synchronized, especially when devices are offline.
Final Answer:
To keep a virtual copy of a device's state for synchronization -> Option A
Quick Check:
Device shadow = virtual state copy [OK]
Hint: Device shadow = virtual device state copy [OK]
Common Mistakes:
Confusing device shadow with physical device hardware
Thinking device shadow replaces device firmware
Assuming device shadow encrypts data
2. Which JSON field in a device shadow document holds the desired state of the device?
easy
A. "reported"
B. "desired"
C. "metadata"
D. "version"
Solution
Step 1: Recall device shadow JSON structure
The device shadow JSON has fields like "desired" and "reported" to represent states.
Step 2: Identify desired state field
The "desired" field contains the state the cloud wants the device to have.
Final Answer:
"desired" -> Option B
Quick Check:
Desired state = "desired" field [OK]
Hint: "desired" field stores target device state [OK]
What will the device shadow report after the device updates its state to match the desired power?
medium
A. {"state": {"desired": {"power": "off"}, "reported": {"power": "off"}}}
B. {"state": {"desired": {"power": "on"}, "reported": {"power": "off"}}}
C. {"state": {"desired": {"power": "on"}, "reported": {"power": "on"}}}
D. {"state": {"desired": {}, "reported": {"power": "on"}}}
Solution
Step 1: Understand initial shadow states
The desired state requests power "on"; the reported state shows power "off" initially.
Step 2: Update reported state after device changes
When the device matches the desired state, the reported state updates to "power": "on".
Final Answer:
{"state": {"desired": {"power": "on"}, "reported": {"power": "on"}}} -> Option C
Quick Check:
Reported state matches desired after update [OK]
Hint: Reported state updates to match desired after device sync [OK]
Common Mistakes:
Assuming desired state changes after device update
Leaving reported state unchanged
Removing desired state incorrectly
4. You receive this device shadow update error:
{"error": "Invalid JSON format"}
Which of these shadow update requests is causing the error?
medium
A. {"state": {"desired": {"temperature": 22}}}
B. {"state": {"desired": {"temperature": 22}, "reported": {"temperature": 22}}}
C. {"version": 1, "state": {"desired": {"temperature": 22}, "reported": {"temperature": 22}}}
D. {"state": {"desired": {"temperature": 22}, "reported": {"temperature": 22}"}}
Solution
Step 1: Check JSON syntax of each option
{"state": {"desired": {"temperature": 22}, "reported": {"temperature": 22}"}} has an extra double quote after the reported object closing brace, breaking JSON format.
Step 2: Identify invalid JSON causing error
Invalid JSON causes the "Invalid JSON format" error in device shadow update.
Final Answer:
{"state": {"desired": {"temperature": 22}, "reported": {"temperature": 22}"}} -> Option D
Quick Check:
Invalid JSON syntax = error [OK]
Hint: Look for extra or missing quotes/braces in JSON [OK]
Common Mistakes:
Overlooking extra quotes or commas
Confusing valid JSON with similar invalid syntax
Assuming error is from device, not JSON format
5. You want to ensure a device shadow only updates the reported state if the device is online. Which approach best achieves this?
hard
A. Use a device shadow update callback to confirm device state before updating reported state
B. Delete the device shadow when device is offline
C. Update reported state immediately on cloud request without device confirmation
D. Set desired state to null when device is offline
Solution
Step 1: Understand device shadow update flow
Reported state should reflect actual device state, so cloud must confirm device is online and updated.
Step 2: Choose method to confirm device state
Using a callback or acknowledgment from the device before updating reported state ensures accuracy.
Final Answer:
Use a device shadow update callback to confirm device state before updating reported state -> Option A
Quick Check:
Confirm device state before reported update [OK]
Hint: Confirm device state via callback before updating reported [OK]
Common Mistakes:
Updating reported state without device confirmation
Deleting shadow causing loss of state info
Setting desired state to null instead of managing reported