Using RFID over MQTT to help track trains around a model railway layout

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ต.ค. 2024
  • I've been tinkering with RFID for a long time but could never seem to get it working. The penny finally dropped and I found that it's going to be a useful tool in improving the use of my DCC throttle and cab signals project.
    Links (I don't have any affiliate links)
    The library I lifted some code from for tag processing github.com/joh...
    The cheap reader www.ebay.co.uk...
    Seeed reader www.ebay.co.uk...
    Code - this is a link to the repo I use to back up all of the code for my 'live nodes' - I've put a bit of documentation in there too github.com/Vin...
    #modelrailway #modeltrains

ความคิดเห็น • 47

  • @henrybest4057
    @henrybest4057 3 หลายเดือนก่อน +1

    Can you please give a link for the tags you use?

    • @WirenwoodModelRailway
      @WirenwoodModelRailway  3 หลายเดือนก่อน

      I'm afraid it's not that easy at the moment, Henry, they seem in short supply! I'm trying out a new supplier, if they send what I've ordered I'll come back with a link. But you want to be searching for 125khz EM4100. Regards, Chris

    • @WirenwoodModelRailway
      @WirenwoodModelRailway  2 หลายเดือนก่อน

      Sorry this took so long but it's taken a while to establish a reliable supplier, which I now have! Please note - I made a mistake in the video and referred to 10mm tags - the smallest ones are not 10mm, they're 20mm, which I think is why I struggled to find any! I recommend PAC Supplies on eBay (no affiliation) - they've been really helpful with me. These are the smallest ones that you see in the video - they're 20mm rather than 10mm.
      www.ebay.co.uk/itm/202972535921

    • @henrybest4057
      @henrybest4057 2 หลายเดือนก่อน

      @@WirenwoodModelRailway Thanks. I was curious about the "10mm" ones!!! I'd never heard of them (obviously, as they don't exist). How close are the tags to the readers? I could never get mine to read farther than 10 - 15mm away. Also, the metal weights in wagons interfere with the reader/tag contact, if I want to tag them.

    • @WirenwoodModelRailway
      @WirenwoodModelRailway  2 หลายเดือนก่อน

      @@henrybest4057 There's quite a distance with the Seeed ones as they're under 12mm baseboard, so probably 20mm I guess. Most of the tags work in when stuck in any recess I can find under the train.
      And yes, I'm getting issues with metal too - some of the locos - Hornby class 43 and another loco that slips my mind right now - the tags wouldn't work underneath them, so I just stuck them under the first coach in the rake instead. Regards, Chris

  • @davidharris7249
    @davidharris7249 3 หลายเดือนก่อน

    Great video, thanks. Nice boost for you to discover JMRI tracks the trains!

    • @WirenwoodModelRailway
      @WirenwoodModelRailway  3 หลายเดือนก่อน

      Thank you and yeah, I love pleasant surprises like that !Already got my head down working what I can do with it! Regards, Chris

  • @jjcrom4280
    @jjcrom4280 3 หลายเดือนก่อน

    Another informative video. Thank you for documenting what you do.

    • @WirenwoodModelRailway
      @WirenwoodModelRailway  3 หลายเดือนก่อน

      Thanks Justin, I appreciate you taking the time! Regards, Chris

  • @deeprunrailroad_Mike
    @deeprunrailroad_Mike 3 หลายเดือนก่อน

    Yet another thing I need to try. Thanks for the post and the effort to make the video. Isn't model railroading fun. Mike

  • @anfieldroadlayoutintheloft5204
    @anfieldroadlayoutintheloft5204 3 หลายเดือนก่อน +1

    very interesting, vid on channel keep up the vid layout is looking good thanks four the update vid you do on channel

  • @rudolfabelin383
    @rudolfabelin383 3 หลายเดือนก่อน

    Super!
    Really inspiring.
    The devil is in the details!

  • @little_britain
    @little_britain 3 หลายเดือนก่อน +1

    This is a great and useful instructional video. One question: doesn't JMRI already know where our locos are (because they're DCC with unique IDs)? I can see the use of this for consists (other rolling stock) like McKinley does.

    • @WirenwoodModelRailway
      @WirenwoodModelRailway  3 หลายเดือนก่อน

      Good morning - and thank you! I'm afraid not - in the sense of controlling trains, DCC is very much a one-way protocol. The Command Station generates the digital instructions that are sent out to the decoders but nothing is sent the other way. I think maybe RailCom does something in terms of feedback but I've never used it. Regards, Chris

  • @OOElectronics
    @OOElectronics 3 หลายเดือนก่อน

    Very interesting video. Thanks for posting.

    • @John-uu6jc
      @John-uu6jc 3 หลายเดือนก่อน

      Get a life

    • @WirenwoodModelRailway
      @WirenwoodModelRailway  3 หลายเดือนก่อน

      Thank you! And thanks for taking the time to leave a message. Regards, Chris

  • @DonningtonCastleModelRailway
    @DonningtonCastleModelRailway 3 หลายเดือนก่อน

    This is really cool, thanks for sharing everything. Looks like I have another excuse to delay track laying … fitting a reader on each line so I can try this out later in the build.

    • @DonningtonCastleModelRailway
      @DonningtonCastleModelRailway 3 หลายเดือนก่อน

      One question, have you tried those tags on stock with a metal chassis? I know there are specific tags for fixing on metal surfaces but just wondered if you’ve had any issues with it, or issues with there being live rails between the reader and tag?

    • @WirenwoodModelRailway
      @WirenwoodModelRailway  3 หลายเดือนก่อน +1

      Hi Martyn - thank you! And good question - I immediately scuttled up there to do a bit of a test and confirm that metal can interfere with the reading. My initial, very scientific test was to slap a tag on the back of one of those wallpaper scraper type tools and stick a few strong magnets to it for good measure - and no response. I then too the motor car from the class 43 and it looks like I'm getting nothing from a tag stuck to the bottom of that - even though the Class 40, Class 158 and Class 370s all had metal chassis too.
      This isn't a major issue for me as I can just stick a tag to the first coach, which is almost entirely plastic. But it may affect others who intend to use RFID in a different way.
      And yes, good idea to get the readers down before too much track / track detail goes on. I would have done that on mine but thought I'd never get RFID working so never got around to it! Then I got it working and wished I'd put the sensors down earlier. Regards, Chris

    • @DonningtonCastleModelRailway
      @DonningtonCastleModelRailway 3 หลายเดือนก่อน

      @@WirenwoodModelRailway thanks for doing some testing, very useful to know. After watching the video I did some rummaging as in the past we’ve built lots of RFID learning puzzles. In the stores I found some NTAG203s that are designed for metal and we’ve used successfully (massive overkill for this application). But these are 13.56MHz tags rather than 125Khz. Did you do much research on which frequency is best for this use case, I’m guessing low frequency is probably better? I’m just wondering if I can re-use existing kit or should just go down the route you took.

    • @WirenwoodModelRailway
      @WirenwoodModelRailway  3 หลายเดือนก่อน +1

      Hi Martyn - caveat here is I haven't tried any of this - but it looks like those 13.56MHz devices use SPI for communication which complicates things a little for me as, on the Arduinos, I've got ethernet devices plugged into the SPI ports. It did look possible to have multiple SPI devices connected at once but it looks like a bit of a cabling and code faff so I thought I'd go for the simple life (especially as it took me ages to get that working anyway!) and use the relatively simpler serial 125khz devices. So my advice would be make sure you're comfortable with the whole process, from reading, to processing, to sending to JMRI or whatever, before you invest. Think about how many readers you might need, where they'll be placed and what the conduit will be (Arduino over ethernet, ESP32 over wifi etc) to get those tags to their ultimate destination - I think I saw you using JMRI in a recent video so I'll assume that's what you're using. Hope that helps - get in touch if you want to chat some more about it. Regards, Chris

    • @DonningtonCastleModelRailway
      @DonningtonCastleModelRailway 3 หลายเดือนก่อน

      @@WirenwoodModelRailway that’s really good advice, thanks. I think I’ll take a step back and do a little testing with the kit that’s sat on the shelf. I have some code that allows me to talk to the high frequency readers using python, so I can use that for testing. That might allow all comms over USB, with the data then being dumped into MQTT if the hardware works reliably. But as you suggest I won’t make any choices till I’ve got stuck in and understand things a bit better. Thanks!

  • @ClinchfieldModelRailroad
    @ClinchfieldModelRailroad 3 หลายเดือนก่อน

    That 4 wire connector is for a Grove port. I bought a 16 port Arduino type board from Seeed Studio to connect these to a PC usb.

    • @WirenwoodModelRailway
      @WirenwoodModelRailway  3 หลายเดือนก่อน

      Ah thank you that solved a mystery! I guess that would work - I hope there are extension cables available though or all your readers are going to be very close together! Regards, Chris

  • @aleopardstail
    @aleopardstail 3 หลายเดือนก่อน +1

    very interesting, and timely
    experimenting with RFID here, though using the higher frequency tags because it makes life more difficult..
    you may find the issue with tags on the underside of locos causes issues if the thing has a metal chassis, the tags don't work as well with metal behind them, a bit of spacing helps.
    the high frequency tags can be programmed with user data (e.g. stick a decoder address into the tag itself, avoids look ups), also use SPI not the serial port, didn't want to use serial due to the lower speed, also I want the interrupt stuff which the library doesn't yet support so likely writing my own
    that gibberish aside in terms of placement I'm thinking (not yet installed, nor is the track, or even half the board) on having a reader when a train enters or leaves a hidden section - useful for say turning lights on and off.
    the technology is interesting, lots of experimentation coming up, and there is a hell of a lot you can do with this - e.g. tracking individual vehicles and "doing something" with that data - my plan is to know what a train is and have a semi intelligent storage yard manager that knows what can fit where for example using RFID to identify the loco and vehicles its dragging.
    for mounting them I'm using a foam and then cork track bed, its reasonably simple to cut that away and have a thin sheet of plastic under the track covering the gaps

    • @WirenwoodModelRailway
      @WirenwoodModelRailway  3 หลายเดือนก่อน

      Hi! That sounds interesting but I think the issue I'd have is that the ethernet connectors I have use the SPI interface so the devices wouldn't have a way of communicating the tags received back to JMRI / MQTT. You do have me thinking about what I'd program the tags with though! Regards, Chris

    • @aleopardstail
      @aleopardstail 3 หลายเดือนก่อน

      @@WirenwoodModelRailway gone with an over-engineered solution here for the RFID, one reader - one ESP8266 controller.. keeps the SPI wires short and talks directly over MQTT. also means they are portable for testing and connect to the layout with just a power and ground wire.
      See! part of a layout can be "just two wires"...

    • @WirenwoodModelRailway
      @WirenwoodModelRailway  3 หลายเดือนก่อน

      @@aleopardstail I like it, good idea! Just two wires, wow. I think these days it's only the wires propping the baseboards up on this layout. If I took them out the whole thing would collapse into a dusty heap on the floor! Regards, Chris

  • @HHExpress
    @HHExpress 3 หลายเดือนก่อน

    Very Intersting stuff, I was thinking of using it as well but I'm running N scale and have not found a suitable RFID tag for it should be smaller then 10mm

    • @WirenwoodModelRailway
      @WirenwoodModelRailway  3 หลายเดือนก่อน +1

      Hmm, yeah, good luck with that! I hope you find something, it must be out there! Regards, Chris

    • @ralphj4012
      @ralphj4012 2 หลายเดือนก่อน +1

      I know nothing about trains, but wonder whether an injectable 125kHz animal tag would work (low cost in quantity from various Chinese suppliers), sizes down to 8 mm x 1.4mm. If the mounting point is metal then space the tag away using VHB tape or similar.

  • @ClinchfieldModelRailroad
    @ClinchfieldModelRailroad 3 หลายเดือนก่อน

    These might work great with a M5StickC plus. Just bring 5v bus.

    • @WirenwoodModelRailway
      @WirenwoodModelRailway  3 หลายเดือนก่อน

      Thanks I've just Googled them as I'd never heard of them - they look interesting! I'mnot sure what extra they'd bring though?! Thanks! Chris

  • @ClinchfieldModelRailroad
    @ClinchfieldModelRailroad 3 หลายเดือนก่อน

    Yes, it might be convenient to see a RGB led above each throttle knob to see the status of each loco.

    • @WirenwoodModelRailway
      @WirenwoodModelRailway  3 หลายเดือนก่อน

      Absolutely - having signal status sent to the box and being displayed for the trains that each throttle is driving is definitely interesting me! The challenge to get around to start with is there are absolutely no spare pins on the ESP driving it! Regards, Chris

  • @ianjeffery4773
    @ianjeffery4773 3 หลายเดือนก่อน

    I think I'd like to use it more for tracking goods so I can do something like, "Hey, that factory needs more goods, send it a train." Also, you could use it to determine when trains need sent for fuel/depot service. Knob box, snigger...

    • @WirenwoodModelRailway
      @WirenwoodModelRailway  3 หลายเดือนก่อน

      Hey Jeff! And yeah, sniggering here too. I realised when I was doing this actually that different people will want different things from RFID, which is interesting in itself! Chris

  • @jimrobinson6362
    @jimrobinson6362 3 หลายเดือนก่อน

    Layour 23' x 8' on 2 levels keeping track with eyeball mark 1 and baby monitor cctv - simples

    • @WirenwoodModelRailway
      @WirenwoodModelRailway  3 หลายเดือนก่อน

      Thanks for sharing how you like to operate your layout! Regards, Chris

  • @modelrailwaytheeasyway9743
    @modelrailwaytheeasyway9743 3 หลายเดือนก่อน

    I am very interested in having a go at this, thanks for sharing and look forward to having a go if you share the code.

    • @WirenwoodModelRailway
      @WirenwoodModelRailway  3 หลายเดือนก่อน +1

      Hi - thank you! The code is shared in the description - I've shared a repo that contains the code for all of my layout nodes - specifically, the ones containing RFID code are
      github.com/Vintage80sModelRailway/Nodes-for-JMRI/tree/main/MQTT_Client_PS_Node_2 - this is the one I use in the video, and two others
      github.com/Vintage80sModelRailway/Nodes-for-JMRI/tree/main/MQTT_Client_PS_C1_minimised
      github.com/Vintage80sModelRailway/Nodes-for-JMRI/tree/main/MQTT_Client_PS_Node_3_minimised
      Get going and good luck!
      Regards,
      Chris

    • @modelrailwaytheeasyway9743
      @modelrailwaytheeasyway9743 3 หลายเดือนก่อน

      @@WirenwoodModelRailway Thanks Chris sorry I did not spot the links in the description. Love what you have been doing.
      Regards
      John

    • @WirenwoodModelRailway
      @WirenwoodModelRailway  3 หลายเดือนก่อน +1

      @@modelrailwaytheeasyway9743 Thanks John, that's very kind, and no need to apologise, it was a bit of a breadcrumb trail to the code! Regards, Chris