This page contains setup instructions for NFC Player Stat Trackers.
The stat trackers each use one Raspberry Pi Zero W, and contain buttons and lights and a USB NFC card reader. The blue stat tracker also connects to the cabinet via Ethernet and runs the stats client.
hivemind
user, and/or add a SSH public key.Use these instructions to install and configure an older version of the image if the above does not work for you.
Connect using SSH.
hivemind
HiveMind123
You can also configure the stat trackers by placing the following files in the SD card's boot
partition:
wpa_supplicant.conf
- WiFi network configurationconfig.json
- stats client confignfc-config.json
- card reader configThis file contains the WiFi network configuration. It is needed on both readers. This file can contain multiple networks, and the system will connect to whichever one is in range.
If using SSH, you can add a new network using the wpa_passphrase
command. See "Add a New Wifi Connection" below.
To create a new configuration file, place a file called wpa_supplicant.conf
in /etc/wpa_supplicant
or in the boot partition of the SD card. You can use https://codepen.io/LilTrublMakr/full/yRGPrv to generate this file.
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=us
network={
ssid="<SSID>"
psk="<PASSWORD>"
scan_ssid=1
}
This file controls the stats client. It is only needed on the blue reader.
On the blue reader, in your home directory or in the boot partition of the SD card, create a file called config.json
.
{
"cabinets": [
{
"sceneName": "<scene name>",
"cabinetName": "<cabinet name>",
"token": "<cabinet client token>",
"url": "ws://10.68.182.100:12749"
}
],
"servers": [
{
"name": "HiveMind",
"url": "wss://kqhivemind.com/ws/stats_listener/v3"
}
]
}
This file controls the card reader sign-in system. It is required on both readers.
The images contain a version of this file that will run the readers in test mode. In test mode, tapping any card and pressing a button will turn on the corresponding light, and pressing the button again will turn it off. This can be used to test hardware without needing to configure the reader.
If editing the existing version of this file, be sure to remove the test_mode: True
entry.
In your home directory or in the boot partition of the SD card, create a file called nfc-config.json
.
{
"pin_config": [
{ "player_id": 4, "button": 22, "light": 21 },
{ "player_id": 6, "button": 12, "light": 16 },
{ "player_id": 2, "button": 19, "light": 18 },
{ "player_id": 8, "button": 13, "light": 15 },
{ "player_id": 10, "button": 24, "light": 23 }
],
"scene": "<scene name>",
"cabinet": "<cabinet name>",
"token": "<cabinet client token>",
"reader": "blue",
"usb_device": "usb:072f:2200",
"light_mode": "low",
"button_mode": "low",
"pins_low": [26]
}
{
"pin_config": [
{ "player_id": 3, "button": 22, "light": 21 },
{ "player_id": 5, "button": 12, "light": 16 },
{ "player_id": 1, "button": 19, "light": 18 },
{ "player_id": 7, "button": 13, "light": 15 },
{ "player_id": 9, "button": 24, "light": 23 }
],
"scene": "<scene name>",
"cabinet": "<cabinet name>",
"token": "<cabinet client token>",
"reader": "gold",
"usb_device": "usb:072f:2200",
"light_mode": "low",
"button_mode": "low",
"pins_low": [26]
}
Unless you have built your own reader, you should only need to change the scene
, cabinet
, and token
values.
token
is on the HiveMind admin page for the cabinet and is the same value used by the stats client's config file.usb_device
is the vendor and product ID of the card reader from the previous section.reader
is blue
or gold
.pin_config
should contain one entry per player station:player_id
is the ID of the station - for example, 2 is Blue Queen. From left to right, these are 4, 6, 2, 8, 10 on the blue side, and 3, 5, 1, 7, 9 on the gold side.button
and light
are the pin numbers associated with the button and light for this station.light_mode
: set to "high" if the common wire to the LEDs is on a +5V pin, or "low" if connected to ground.button_mode
: set to "high" if the common wire to the buttons is on a +5V pin, or "low" if connected to ground.pins_low
is an array of pins that should always be set to ground.pins_high
is an array of pins that should always be set to +5V.test_mode
: set to True to enable test mode (see above).If you are going to be moving your NFC readers between cabinets often, and want to connect the stats to a different cabinet on HiveMind when moving, you can set up separate config files, and use symlinks to point to the correct one.
Other options include swapping out the SD cards based on location, or simply leaving the config files to point to a single "cabinet" in HiveMind that just tracks wherever you have the readers.
The blue reader uses config.json
for the stats client and nfc-config.json
for the sign-in system, while the gold reader only uses nfc-config.json
.
In this example, the readers are configured for cabinet1
, and we will add config files for cabinet2
.
cd ~
# on both blue and gold
mv nfc-config.json nfc-config.cabinet1.json
ln -s nfc-config.cabinet1.json nfc-config.json
# on blue only
mv config.json config.cabinet1.json
ln -s config.cabinet1.json config.json
# on both blue and gold
cp nfc-config.cabinet1.json nfc-config.cabinet2.json
# on blue only
cp config.cabinet1.json config.cabinet2.json
Edit the cabinet2 configuration files, changing the cabinet name and token. If your network setup is different, you may also need to edit config.cabinet2.json
so it can connect to the cabinet.
wpa_passphrase "<SSID>" "<PSK>" | sudo tee -a "/etc/wpa_supplicant/wpa_supplicant.conf"
The OS will select whichever network is in range, so this will not need to be changed every time.
# on both blue and gold
ln -s nfc-config.cabinet2.json nfc-config.json
sudo systemctl restart hivemind-nfc-reader
# on blue only
ln -s config.cabinet2.json config.json
sudo systemctl restart hivemind-client
The PN532 reader can be used as an alternative to the ACR122U.
raspi-config
hivemind
user to i2c
group:sudo gpasswd -a hivemind i2c
sudo apt -y install i2c-tools libnfc-bin libnfc-examples
i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- 24 -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
/etc/nfc/libnfc.conf
:device.name = "PN532-I2C"
device.connstring = "pn532_i2c:/dev/i2c-1"
nfc-config.json
file: "driver": "pn532_i2c"
usb_device
setting can be removed.