Bug 1 of 3 · inspired by my IoT Inventory Tracker

“The scanner has déjà vu.”

You tap one water bottle on the reader. The reader notices it 3 times in a row, and now the shelf has 3 water bottles.

A water bottle on a scan pad next to an RFID reader. The reader detected its tag 3 times. Before the fix, the inventory shelf holds 3 bottles; after the fix, it holds 1. READER SAW (newest →) TAG-04A7 TAG-04A7skip TAG-04A7skip SCAN PAD TAG-04A7 3 ADDED1 ADDED READER INVENTORY SHELF 3 BOTTLES (2 COPIES)1 BOTTLE ✓
1 tap → 3 bottles on the shelf.1 tap → 1 bottle on the shelf. The repeats are skipped.

scanner.pseudothe buggy code

when the reader sees a tag:    add the tag to the shelf// the reader often sees the same tag// a few times in a row
when the reader sees a tag:    if this tag was added in the last 2 seconds:        skip it    add the tag to the shelf
Which change fixes it?

About this demo

What was the bug?

The code added every detection to the shelf. But a reader can see one tag several times while you hold it there. The fix remembers when each tag was last added and skips repeats that come in too soon.

Honest label: a simplified demonstration inspired by my IoT Inventory Tracker. It isn’t a real bug from that project.

Read about the IoT Inventory Tracker · Its source on GitHub (opens in a new tab)