The LEGO Dimensions game makes
use of NFC technology to allow some interaction between physical LEGO creations
(characters, vehicles and gadgets) and the videogame.
The LEGO Toy Pad is in fact just a custom USB triple NFC reader that can read
NFC tags (not only the LEGO Toy Tags but also several other tags including those
used in other games like Disney Infinity) and change the color of the RGB light
associated to each reader.
Credits
Since the beginning of 2015 several people have been reverse engineering the
LEGO Toy Pad.
This tutorial is strongly based on @woodenphonework available at GitHub.
Requirements
You will need:
a proper LEGO Dimensions Toy Pad
a Mindstorms EV3
an available USB port
python and pysub
udev rule
Several people reported a difference between PS3/PS4/Wii devices and Xbox so
this tutorial most probably will not work with the Xbox type.
You don’t really need a Mindstorms EV3 as this tutorial can be used on almost any
recent linux system (like my Ubuntu laptop or my Raspberry Pi). If using ev3dev,
just be sure to use a recent version - this tutorial was tested with kernel
4.4.15-13-ev3dev-ev3.
Of course, you need an available USB port so if you’re already using the Mindstorms
EV3 with an USB Wi-Fi dongle you will also need an USB Hub.
After you connect the LEGO Toy Pad it should be recognized as an HID device:
robot@ev3dev:~# dmesg
...
usb 2-1.2: new full-speed USB device number 8 using ehci-pci
usb 2-1.2: New USB device found, idVendor=0e6f, idProduct=0241
usb 2-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-1.2: Product: LEGO READER V2.10
usb 2-1.2: Manufacturer: PDP LIMITED.
usb 2-1.2: SerialNumber: P.D.P.000000
hid-generic 0003:0E6F:0241.0006: hiddev0,hidraw3: USB HID v1.00 Device
[PDP LIMITED. LEGO READER V2.10] on usb-0000:00:1d.0-1.2/input0
You can also check with lsusb:
robot@ev3dev:~# lsusb
...
Bus 002 Device 008: ID 0e6f:0241 Logic3
...
You also need python and pyusb. Most Linux distributions already
include python as default so you probably only need to install the pyusb library
with:
The following script will check for the presence of a LEGO Toy Pad and initializes
it, turning the middle (round) pad red for one second:
If everything was OK the output should be:
LEGO READER V2.10
and of course the center pad should stay red for one second.
Changing pad colors
In the above script we’ve seen that all commands sent to the LEGO Toy Pad have
the same size: 32 bytes.
The first bytes define the command, some other bytes the arguments and the
remaining bytes are just to assure proper communication (checksum).
I’ll show just how to change the color of each pad but there are some other
commands available (switch on/off, fade, flash…). You can see these commands
in @woodenphone’s lego_dimensions_gateway.py script.
Reading tags
Whenever a tag is inserted or removed the LEGO Toy Pad sends a 32-byte message
starting with 0x56. The message also contains:
the number of the pad affected
the UID of the tag inserted or removed
the action itself (tag was inserted or removed)
So if we already know the UID of a tag we can track it with the LEGO Toy Pad (I
use my Android phone to read my tags but we can also use the LEGO Toy Pad).
For the next script we’ll track Darth Vader from Disney Infinity 3.0 (a Mifare
Classic Mini tag) but we can track several types of NFC tags - LEGO Toy Tags are
Mifare Ultralight C (also known as NTAG213) and Nintendo amiibo are also Mifare
Ultralight (but not C, so NTAG215).
The script also tracks unknown UIDs. So:
if it recognizes Darth Vader, it turns the corresponding pad RED;
if it doesn’t recognize the tag, it turns the pad GREEN;