RFID
Selecting a locomotive by tag, with an optional MySQL lookup.
Hold a tagged car or loco to the Dial’s built-in RFID reader to select it. The reader can be turned off under System in the settings menu.
Lookup order
A tag UID is resolved to a loco address in this order:
- A MySQL lookup on the same host as the WiThrottle server, if enabled.
- The local
RFID_LOCO_MAPtable inconfig.h. - The last 4 hex digits of the tag UID, normalized to an address in
1..9999.
The status line shows which one matched: RFID-DB, RFID-MAP or RFID-TAIL.
MySQL lookup
Set these in config.h:
| Setting | Purpose |
|---|---|
ENABLE_RFID_MYSQL_LOOKUP | Turn the lookup on |
RFID_MYSQL_HOST | Server IP address, as a numeric string |
RFID_MYSQL_PORT | Server port |
RFID_MYSQL_USER, RFID_MYSQL_PASS | Credentials |
RFID_MYSQL_DB, RFID_MYSQL_TABLE | Database and table |
RFID_MYSQL_UID_COLUMN | Column holding the tag UID |
RFID_MYSQL_LOCO_COLUMN | Column holding the loco ID |
RFID_MYSQL_IS_LONG_COLUMN | Optional long-address flag column |
RFID_MYSQL_HOSTmust be an IP address. Host names aren’t resolved.
A loco_id value can be prefixed (S3, L128) or numeric only (3, 128). A numeric value
above 127 is treated as a long address.
The repository includes a sample schema with seed data:
mysql -h <server-ip> -u <user> -p < rfid_mysql_schema.sql
Verification checklist
- In
config.h, setENABLE_RFID_MYSQL_LOOKUP = true, setRFID_MYSQL_HOSTto the server’s IP address, and match the credentials and column names to your table. - Confirm a row exists for a test tag:
SELECT loco_id, is_long FROM wifithrottle.rfid_loco_map WHERE rfid_uid='DEADBEEF' LIMIT 1; - Flash the firmware and open the serial monitor.
- Scan the tag. The console shows source
(db)and the status line showsRFID-DB. - Remove or rename that row and scan again. It falls back to
(map)/RFID-MAP. - Remove the local map entry too and scan again. It falls back to
(tail)/RFID-TAIL. - Confirm the address is in
1..9999and that JMRI acquires it.