Workshop – JMRI MQTT-RFID-Reporters

This topic slumbered for some time, while I was occupied with otjer things, like an ESP32 based WiFi Throttle or designing an EMD SD20 shell for my Proto2000 SD7 and Atlas SD24 chassis‘.

While cleaning up the workshop, I thought about my next project. Of course that would be the test layout. But prior to securing the track to the roadbed, I had to make my mind up regarding what’s meant to be situated under the track in the very roadbed.

Please disregard the actual readers shown on the title image. The red one is a PN532 which might have a few issues on the ESP32 MCU also shown. I bought them for the I2C interface, but documentation of how to change the default addres 0x48 to something else to have more than one communicate on the same I2C bus isn’t well documented on the web. The other is a tiny variant of the well known MFRC522 reader I mentioned earlier, which reportedly has a very insignificant reading distance, which in turn would disqualify if from this project (but it looks cool and might be worthwhile for use in N-Scale). So this project will likely be based either on the MFRC522 or PN532 and both in SPI mode. Just to mention it.

The has two main GitHub repositories referenced and maintained, that have all the necessary code in them. These are:

MQTT-Connected JMRI-Layout with DCC-EX

This Subtitle already suggests, that this will become a major topic. As I plan to employ lots of different sensors on my Layout, I’m planing on utilizing the Internet-of-Things (IoT for short) in some way. Espcially MQTT looks like a more than promising communication method between JMRI and all those interconnected sensors, reporters, turnouts, signals and the like.

This YouTube playlist got me actually started:

RFID-Reporters and IR Sensors

This is the JMRI terminology for what’s basically a track occupation measurement method. In JMRI reporters report more complex information than sensors, which teport states like ON or OFF (true or false). Reporters deliver for example an ID number to JMRI.

Okay. Setting up MQTT for Win10 is nit trivial, but manageable. I set up three PN532 RFID readers on an ESP-32 WROOM-32 v.1.0 using the second repo mentioned above abd using the latest sketch (v0.11).

First sidenote up front: that sketch doesn’t support non-anonymous MQTT brokers. That cost me the whole afternoon, after sucessfully creating a password file with encrypted passwords, and set up JMRI MQTT connection using its dedicated username for MQTT. Well the sketch scanned for MQTT brokers on broadcast and various IPs but only reported something along the line of „not found“.

Only after I allowed anonymous subscribers, the sketch subscribed successfully to MQTT.

So testing went on. I scanned an RFID-Tag and it worked instantly according to the serial monitor.

However, I accidentally used the last initialized reader of the three I had set up. None of the others worked at all. No error, but no tag read. Man, this is becoming frustrating. I read about the problem, that only the last reader was correctly working somewhere, so more research is necessary.

I think I will be switching the the first repo and set up everything acording to Tom Seitzs sketches, which had done magic for me a year ago.

But not in the next couple of weeks. I’ll be gone walkabout and won’t have access to all that stuff (which is good during a vacation). More to come. Cheers.