Chapter 21 of 22Part V: Artificial Intelligence and Intelligent Devices
NFC: The Secret Power of a Tap
Each project below is tailored to a specific algorithm and scientific question from Chapter 21, with concrete inputs, verifiable numerical outputs, boundary cases, and links to the related lab and pioneer.
Project 1 of 3 · v1-c21-p01Intermediate · ~25 min
13.56 MHz Inductive Coil Coupling Model
Lab activity: 1. Model two coils · Related code: block-01.js · Pioneer: View profile
Real-World Problem: Transit cards and museum tags work with zero battery by harvesting energy from a reader's magnetic field.
Scientific Question: Why does NFC work at 2 cm yet fail completely at 15 cm?
Objective: Model near-field magnetic coupling vs. coil separation d and find the exact activation cutoff distance.
Hypothesis to Test: Because near-field dipole coupling decays rapidly (~1 / (1 + (d/R)^2)^(3/2)), induced voltage falls below chip threshold within a few centimeters.
Step-by-Step Implementation
Evaluate the normalized inductive coupling curve across distances 0 to 10 cm.
Find the maximum operating distance where induced voltage >= chip turn-on threshold.
Test tilting the tag coil by angle θ (multiplying coupling by cos θ); observe 90° null.
Explain why short physical range provides an intentional physical-proximity boundary.
Concrete Input: Coil radius R = 2.0 cm, activation threshold = 2.5 V; sweep distance d from 0 cm to 10 cm.
Expected Output: d=1 cm -> active; d=3 cm -> marginal; d>=5 cm -> unpowered (below 2.5 V threshold).
Test Cases: d=0, θ=0° -> max coupling; θ=90° -> 0 induced voltage; d=10 cm -> below threshold.
Boundary Condition: Metal surfaces behind a tag induce eddy currents that detune 13.56 MHz antennas unless shielded with ferrite.
Common Mistake to Avoid: Confusing NFC's 13.56 MHz magnetic near-field with 2.4 GHz far-field Bluetooth/Wi-Fi radio.
Interpreting Results: Physics (Faraday's law of induction) directly sets NFC's tap-distance user experience.
Show Hint, Extension Challenge & Reflection
Hint: Review the worked example and equation in Chapter 21 before testing the boundary case: Metal surfaces behind a tag induce eddy currents that detune 13.56 MHz antennas unless shielded with ferrite.
Extension Challenge: Compare coil radii R = 1 cm (smart ring) vs. R = 3 cm (transit card) on activation distance.
Reflection Question: Why is tapping a transit card at 2 cm more practical in a crowded station than a 10-meter wireless link?
Boundary Condition: Payloads >= 256 bytes cannot use the Short Record (SR) 1-byte length field and need a 4-byte length.
Common Mistake to Avoid: Counting JavaScript string .length instead of UTF-8 byte length for international URLs.
Interpreting Results: Protocol headers and abbreviation tables squeeze maximum utility out of tiny low-cost chips.
Show Hint, Extension Challenge & Reflection
Hint: Review the worked example and equation in Chapter 21 before testing the boundary case: Payloads >= 256 bytes cannot use the Short Record (SR) 1-byte length field and need a 4-byte length.
Extension Challenge: Add support for multi-record NDEF messages (e.g., 1 URI record + 1 plain-text description record).
Reflection Question: Why do smart posters use short redirect paths like /go/21/ instead of long tracking URLs?
Lab activity: 3. Design a cautious tap interface · Related code: block-03.js · Pioneer: View profile
Real-World Problem: Tapping an unknown public NFC sticker could trigger an unwanted webpage, pairing prompt, or phishing link.
Scientific Question: What distinct security boundaries separate reading raw bytes, parsing NDEF, opening a URL, and granting permissions?
Objective: Implement a safe tap-preview state machine that inspects decoded NDEF payloads and requires explicit confirmation for external actions.
Hypothesis to Test: Treating raw byte read, parser validation, URL preview, and user-confirmed open as four separate states eliminates silent redirects.
Classify record type (plain text, HTTPS URL, unsupported/privileged action).
Render full destination origin clearly as plain text before offering an Open button.
Block dangerous URI schemes (javascript:, data:, file:) outright.
Concrete Input: 3 simulated NFC tags: trusted museum link, suspicious lookalike URL, and malformed oversized NDEF record.
Expected Output: Malformed tag -> parser rejects safely; Suspicious URL -> domain highlighted with Cancel default; Trusted -> preview shown before open.
Test Cases: Malformed length > buffer -> rejected cleanly; javascript: URI -> blocked; https:// -> preview + confirm.
Boundary Condition: Never claim reading an untrusted tag is unconditionally risk-free; parser safety matters too.
Common Mistake to Avoid: Auto-opening decoded URLs without showing the domain to the user.
Interpreting Results: Good security UX makes privilege boundaries visible and gives users informed control.
Show Hint, Extension Challenge & Reflection
Hint: Review the worked example and equation in Chapter 21 before testing the boundary case: Never claim reading an untrusted tag is unconditionally risk-free; parser safety matters too.
Extension Challenge: Add a domain-comparison warning when a tag displays text claiming one site while linking to another.
Reflection Question: How do QR codes (Chapter 4) and NFC tags (Chapter 21) share similar human-factor phishing risks?