Workshop – MQTT attached RFID-Reporter for JMRI v2

Recommended reading:

For this newer implementation I decided to use cheap PN532 modules via I2C, which simplifies wiring somewhat. The RFID hub will have up to eight RFID readers attached to an ESP-32 MCU. That’s the theory.

Various ESP-32 MCUs (left) with a PN532 (red) and an RC522 Mini (black) RFID-Reader

As these particular readers are not easily programmed to use individual I2C addresses, I’ll be using a TCA9548A I2C multiplexer which supports eight devices with identical I2C addresses sequentially.

Sequentially means that the MCU will poll each reader in sequence,which causes a delay between reading the first and reading the last reader in the setup. If the reading process isn’t tolerant to these delays, I plan to implement some trigger mechanism. Either a push button to signal the MCU which reader should be polled or an automatic event like the following.

An optional addition will be an event triggered selection of the appropriate readers. This can be achieved by monitoring the status of a track occupancy sensor near the readers. As I plan to install MQTT attached IR sensors on each block, I already have a trigger implemented. The sketch now only subscribes to the respective time sensors for each reader and activates the device, as soon as the sensor shows „active“.

I only need to find a way, to discard reads when pulling out of the respective track (where the reader is situated in front of the IR sensor and not behind) in regard to the direction of movement. It that case the reader would be triggered one car to late (assuming a one car spacing between occupancy detection and rfid reader). In that case it would be far more convenient to trigger each reader from buttons in the fascia. This way car movements, that are not meant to contribute to switching operations or train building, can be ignored by simply not activating the rfid reader.