Jump to content
 

RfID, Arduino and JMRI


Wagonmaster
 Share

Recommended Posts

Has anyone tried experimenting with RfID, Arduino's and JMRI? I have an Arduino Uno connected to a MFRC522 13.56MHz reader. I have found a couple of sketches (code) that enable me to read the tags and display the ID on the Serial Monitor. What I can't seem to do is get that tag ID into JMRI. I'm pretty sure it's something to do with the serial output format of my Arduino not being of a type recognised by the various JMRI RfID options. Has anyone had any success with this and maybe have a working sketch they could share or some pointers on how to code the correct output format please?

 

I have a working MERG CBUS RfID installation on one layout and have had the Arduino working with the 125kHz Seeed Studios reader on another layout. However, I would like to standardise on 13.56MHz so models may be used and read on either layout. I have scoured the Internet but not found anything yet.  I'm sure it can be done, but I am at a bit of a loss with coding.

 

Thanks

Link to post
Share on other sites

I'm sure this question is bouncing around multiple forums at present.   Your best chances of finding a solution would be found on (a) MERG, (b) jmriusers (groups.io) and (c) RFID4MRR  (groups.io).   
An alternative approach (faffy with Arduino) is to swap to a wireless report over MQTT.  Fairly simple with an ESP32 or a RaspberryPi Pico-W processor.  The Pico-W is very cheap.  

 

Link to post
Share on other sites

Thanks for your reply Nigel. I have tried posting this question around various Forums, but without any luck so far. So I thought I'd try this Forum!

 

I'm sure someone must have done this somewhere, just a case of finding them!

 

Link to post
Share on other sites

Thanks for the replies. I am aware of The McKinley Railway and the work done on its RFID system, very impressive.

 

However, all I'm trying to do is get the tag id into JMRI as a Reporter. The reader works and data is recieved by the JMRI rfid command monitor, it just doesn't get any further. That's the bit I'm trying to find out.

Link to post
Share on other sites

On 09/03/2023 at 08:52, Nigelcliffe said:

I'm sure this question is bouncing around multiple forums at present.   Your best chances of finding a solution would be found on (a) MERG, (b) jmriusers (groups.io) and (c) RFID4MRR  (groups.io).   
An alternative approach (faffy with Arduino) is to swap to a wireless report over MQTT.  Fairly simple with an ESP32 or a RaspberryPi Pico-W processor.  The Pico-W is very cheap.  

 

It's  probably my question bouncing around! 

 

The Raspberry Pi option seems interesting and I did follow it up. The Pico W is cheap, only £6! It's the rest of it I'm not sure about. The WiFi is sort of useful as it reduces some wiring and connections. The downside is getting that message into the main computer, a PC. Maybe a wired connection to a serial/usb port? The other point is, once I've got the data to the PC, how is JMRI going to process that as an ID Tag?

 

Are we sure that we're not just swapping the same issue to a different bit of kit? Have you managed to do this with your system?

Link to post
Share on other sites

13 minutes ago, Wagonmaster said:

It's  probably my question bouncing around! 

 

The Raspberry Pi option seems interesting and I did follow it up. The Pico W is cheap, only £6! It's the rest of it I'm not sure about. The WiFi is sort of useful as it reduces some wiring and connections. The downside is getting that message into the main computer, a PC. Maybe a wired connection to a serial/usb port? The other point is, once I've got the data to the PC, how is JMRI going to process that as an ID Tag?

 

Are we sure that we're not just swapping the same issue to a different bit of kit? Have you managed to do this with your system?

 

My Pico stuff (and Arduino) is for RailCom data, but once its data it is data. 

 
I didn't write the Arduino code we're using, but it transmits over CBUS using the same data format as the MERG RFID.  That's fine into JMRI (comes into computer over a CANUSB device).  The data over CBUS is several bytes (many of them zeros). 

 

The PicoW sends things over MQTT.   The device has a topic of approx:  "/mylayout/reporters/reportername"  (a user preference inside JMRI), and a payload which is "address further-data" (as a string, with a space between the two parts).   "reportername" is the name of the reporter setup in the reporters table inside JMRI.   The address in the data string is picked up inside JMRI as the ID-Tag, and the "further-data" is available to scripts/LogixNG  (I'm using it for orientation - which way the loco is facing).   The MQTT Reporter stuff in JMRI is in the current test release (new code in January).  

 

MQTT needs a MQTT broker somewhere.  I use Mosquitto, running on a Raspberry PI 3.  There are Mosquitto builds for Windows (and I guess MacOS), as well as Linux.  And there are public brokers on internet services.    An advantage of MQTT, once you've got the basic broker running, is its simple to manually create and read data,  either command line stuff, or there are various MQTT apps for phones/tablets.       

 

The JMRI computer has a connection to the MQTT broker ( a JMRI connection option).   That's to an IP address for the broker, doesn't matter if its wired network or WiFi (JMRI doesn't know or care).    

 

 

The RFID I've got is a couple of the McKinley's readers and tags, which report over MQTT (their hardware is an Eccel C1).  The MQTT payload is a JSON structure, which needs translating into a string for JMRI's reporter.  I've some trivial python which does that, reposts a new MQTT message in the form which JMRI can subscribe to and process through the reporter structure.   

 

 

Though I've got it all running into JMRI, we've decided the processing we were doing inside JMRI can be done as easily in a PicoW out in the layout.   So, we don't need to deploy the JMRI part, we think we'll stop at the MQTT broker, and have display devices which subscribe to the relevant MQTT topics and that does all we need.     But the JMRI side does work.  

 

 

 

- Nigel

 

 

 

 

Link to post
Share on other sites

Thanks for your reply Nigel. That sounds a very complicated, but impressive system! Thanks for explaining for me, it is an area I haven’t looked at.

 

However, it sounds a bit overly complicated for what I want to do. I just have one reader on the exit of the fiddle yard and would like to read the tag of any loco, railcar etc. that goes onto the 'mainline'. JMRI's block tracking would then pick that up and display it on the panel.

 

I just need to get the Arduino's output into JMRI!

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...