Jump to content

Read/Write NFC Tags


xperiment

Recommended Posts

Posted · Read/Write NFC Tags

Yes, the tags can be read and written. What do you want to achieve?

We wanted to implement ndef records, but we made a mistake causing no other app to understand the data

  • Like 2
Link to post
Share on other sites

Posted · Read/Write NFC Tags

hiya,

I wouldn't mind to understand this subject.

Being able to re-write these with data of a material that isn't ultimaker's like Ninja flex or if you prefer another brand of material or simply because you want to use a colour that UM can't supply. transfer the filament over to a UM spool and reset the data on the spool.

something like that anyways

bex

  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    It would be a cool addition to the UM3 app to be able to read the tags. I have unmarked spools so can't confirm what the material unless I load it into the printer.

    But I would also like to write my own rags somehow.

  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    The tags only contain a material identifier, the actual data about the material is contained with the material database (in Cura and on the printer). So you cannot suddenly add ninjaflex without those being in the database.

  • Link to post
    Share on other sites

    Posted (edited) · Read/Write NFC Tags

    The tags only contain a material identifier, the actual data about the material is contained with the material database (in Cura and on the printer). So you cannot suddenly add ninjaflex without those being in the database.

     

    But what if you could clone the TPU and *Name* it as NinjaFlex. Same with cloning say a CPE+ or nylon but naming it PETG.

    In a way, that is what we are doing now....choose a profile in Cura that matches closely to what we want to start with and then choose the generic variant on the machine.

    Although not a technically elegant solution, it could save a few steps for users and prevent the need to remember which variant you are starting from.

    Edited by Guest
  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    I bought a few spools on special of the non NFC ulitmaker filament and would love to be able to program my own tags with the material ID. I dumped one of the tags and it shows an NTAG216, but the memory space appears to only be less than half used. 

     

    Has anyone had any luck creating their own identifier tags? I tried to SSH into my S5 to try and find the database for the materials but came up with nothing. (I attached my dump of my spool of Black Tough PLA if that helps)

    04-7A-95-92-66-5A-80_2019-07-13 19-46-05_taginfo_scan.log

  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags
    5 hours ago, Rainbowdashboard said:

    I tried to SSH into my S5 to try and find the database for the materials but came up with nothing.

     

    One can retrieve a list of materials from the printer with:

    http://xxx.xxx.xxx.xxx/cluster-api/v1/materials/

     

    And all installed materials are available in Cura, in the program/AppImage folder (".../resources/materials") and in the configuration folder (".../materials" - in addition and optional)

     

    AFAIK the GUID is the most important thing (if not the only one) that is used for comparison between gcode file and NFC data.

     

  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    Boom! That was the answer. Thank you for this insight. Now I need to solve the the NDEF issue Daid mentioned above. Only done a cursory look into duplicating my tag without success, so I may attempt to write my own interface for the tags to write with my phone. 

    Capture.PNG

    • Like 1
    Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    Hey - Did you ever end up making your own interface for this? Would love to create my own tags and define them 

    • Like 1
    Link to post
    Share on other sites

    Posted (edited) · Read/Write NFC Tags

    @Daid This is now more important that the material station cannot accept anything other than one colour of each non ultimaker filament.

     

    Even material alliance filaments cannot have more than one colour loaded into the material station.

    Edited by Sassw
  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    @Sassw please be aware that @Daid is not working anymore at Ultimaker - he still might follow a few topics but maybe not those clearly Ultimaker hardware-related.

  • Link to post
    Share on other sites

    Posted (edited) · Read/Write NFC Tags

    After adding some materials via the API you can now just load them as different types of material for now.

     

    See the attached lock out due to not having break positions etc and then the result of using a more up to date xml.fdm_material with those fields.

     

    Good news is that custom writes to the tags works and selects colour GUIDs as expected.

     

    Ultimaker you should document the schema for the xml, there is a double entry for the U3 in most profiles.

     

     

    IMG_20191015_135214.jpg

    IMG_20191015_145451.jpg

    Edited by Sassw
  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    Which RFID reader/writer are you using? Did you find a source for the RFID tags? Thanks,

     

          Greg

     

  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags
    On 10/11/2019 at 12:50 PM, mhigginsmoy said:

    Hey - Did you ever end up making your own interface for this? Would love to create my own tags and define them 

    I ended up abandoning this a while ago. I hope to pick it up again now that I have a fancy pants Proxmark. 

  • Link to post
    Share on other sites

    Posted (edited) · Read/Write NFC Tags

    Even though the tags are not marked to contain NDEF records, the data stored in the NFC memory adhere to the standard. There are four records one of which contains the material UUID and two others storing the amount of material on the spool. The tasks of understanding the individual data structures and how to fill them in gets much easier consulting the relevant python code on the printer.

     

    This way I managed to successfully write the UUID of a 3rd-party material to the tag of an empty spool and transfer the tag to a fresh spool of said material. I also managed to create a cura plugin for this material with both the generic and the vendor specific definitions, together with a set of profiles (which now need to be refined to meet their intent). This way, Cura uploaded the fdm_material file to the printer which now fully recognizes the material. We can even use it with the material station without any obvious restrictions.

     

    However, I am still a bit uncertain as to how to tune in the material station related parameters. For starters, I used a fdm_material file of a material with similar properties, but I'd feel much more at ease if I knew the relevance of each parameter and which material properties I need to take into account. Is there any sort of documentation on this?

     

    Another question is where we could source a small number of these circular tags, right now we don't have enough empty spools to live off recycled tags.

    Edited by gandy
    typo
  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    Hello

    I would like to use old spool chips or new NFC chips just to identify .. actually whatever, at least generic PLA but including color. I want to use NFC tools. Any advice if it is possible?

    • Like 1
    Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    Bump!  I have a UM3 and am just finishing a spool of ultimaker PLA, would like to reuse this roll for another brand, the main reason is that the other brand spool is incompatible with the rear holder.

     

    That means, I think, that I have to reset the material amount.  I don't know what hardware I need to write to this NFC tag or whether a UM3 can do that.  I have to think it can as it updates the material amount?

     

    Thanks John

     

  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    It would be great to:

    1. add the new non-Ultimaker filament in Cura DB (es. Filamentum Vertigo Starlight, with all of its data).

    2. obtaing the new material identifier from Cura db

    3. write an NFC tag with this identifier.

     

    Still unpossible?

    Given I use so many different brands materials... I'd love such an (easy) solution!

  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    @gmeardi If you can love the solution depends on how much you are willing to stretch 'easy', so here we go.

     

    Before working with the Ultimaker S5, I've never really put my mind to NFC technology, so there are very probably some gaps in my understanding. Most of what I've learned, I've deduced from comparing the data from different spools and with different amounts of remaining material. The rest I could fill in reading the relevant python code of the firmware after ssh-ing into the printer.

     

    As @Daid pointed out earlier, Ultimaker tried to implement NDEF records. According to the NFCForum-TS-Type-2-Tag standard, NDEF records need to be embedded in a NDEF Message TLV, which is missing on the Ultimaker NFC tags. That's why NFC apps report there are no NDEF records on the tags. Other than that though, the data adheres to the NDEF standard, so I was able to use the python package ndeflib to add custom record types to decode and encode the tag data.

     

    The code on https://gist.github.com/gandy92/a7eef12009045f7b3fc01d778c3b79a7 demonstrates just that. Based on this code, you can decode the data from your spools to check how much material is left (usually given in mg) or plug in the UUID from your custom material profile and the amount of material on the spool and create the data to write to your NFC tag. I will not elaborate on how to actually write the data. This depends heavily on your tag writer and OS and would by far exceed the scope of this comment.

     

    For our spools, we carefully extract the NFC tags from empty spool and transfer them to the third-party spools. Make sure to always write complete blocks to the tag: There are two stat-records on the tag, apparently with usage data at different times. My first guess was this is used for redundancy in case a stat-record gets corrupted, e.g. by the printer loosing power during a write operation. In my first writing attempts however, I failed to write the last block, rendering the whole tag unreadable for the UM-S5. I'm not sure if this is due to design or simply a bug in the firmware, but if any of the two stat-records show the wrong checksum, the whole spool is simply ignored by the printer.

     

    In Cura, I've learned it is important to actually have two filament profiles:

    • {brand}_{material}.xml.fdm_material, where brand and color are set to "Generic" (in the profile, not in the filename)
    • {brand}_{material}_{color}.xml.fdm_material fills in the actual values and additionally provides the amount of material

    Say you have material M of brand B in color C, you want two files, B_M.xml.material and B_M_C.xml.material. For a new brand and material combination, I suggest to select an existing material in Cura as template: When creating a new custom profile, Cura will pick a new UUID for it. Then add one profile for each color, each with a different UUID. Use these UUIDs for the tags. You will need to use a text editor to adjust the profiles. Later, Cura will sync the profiles with the printer, so there is no need to upload them yourself. Just make sure to increase the profile version number and never again change the UUID.

     

    There's one caveat however, when using the material station: The profile tells the printer how to load/unload the filament, but so far I couldn't find documentation on the parameters, so maybe using the profile of a material with similar properties would be a good idea. Being extra careful and standing by the printer is another good idea.

     

    For perfect integration in Cura, it would be great having intent profiles for the material, which we are still struggling to figure out how to create. If anyone managed, I'll be happy for tips or suggestions.

     

    • Like 5
    • Thanks 1
    Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    @gandy thanks for the wonderful explanation.

    I'm not an NFC expert, but if I can find some time, I'll try going through (and in case let you know)!

  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    @gmeardi good luck with that. I guess you don't really need to be an expert, I certainly am not. A little python knowledge can surely help and you definitely need some nfc reader/writer hardware. I'm using a ACR122U-A9 with a raspberry pi for that purpose. Got it working out of the box with pscd:

    sudo apt-get install pcscd pcsc-tools
    echo 'SUBSYSTEM=="usb", ACTION=="add", ATTRS{idVendor}=="072f", ATTRS{idProduct}=="2200", GROUP="plugdev"' | sudo tee -a /etc/udev/rules.d/nfcdev.rules
    

    idVendor and idProduct may be different and both udev and pcscd may have to be restarted before it works.

     

    For actually writing the data to the tag, I'm using something along the lines of this short script:

    https://gist.github.com/gandy92/1f9df107b049e12173657e28e20dc56e

     

    I'll be happy to learn how this turned out for you.

    • Like 2
    Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    I'm starting to look into this now that we have multiple S5s with material stations.

     

    Since the material station reads and writes to these chips, is there a way to do that ourselves using the material station?

     

    I have tried a PUT request via the API to the material station using an empty spool that is currently loaded. I attempt to set the material remaining back to 1, but it never updates. I was hoping it would be that simple, but of course it's not. I do get a 200 response, but the number never updates.

  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    I'd be surprised if the NFC reader is actually exposed by any of the high level APIs or even the machine's dbus. My recommendation is to get one of those 20€ USB NFC readers and go with Python or whatever language you're comfortable with as long as it works with the reader.

    I'd be happy to stand corrected, though, so if you find a way with the native NFC hardware, please share.

  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    @gandy I came across your example scripts for creating and writing spools while trying to write my own tags for some 3rd party spools. I just wanted to say the scripts worked really well! (I ended up getting the ACR122U-A9 as you were using)

     

    I combined your 2 scripts together, and then wrote some extra modules and a qt interface on top so I could easily create new spools as needed or check on my existing spools. I also added a lookup function to determine the material from the guid by reading all the material xml files in both the user and system cura material directories.

     

    spool_ui.thumb.png.77fe8c3297ef535032316491dceae126.png

     

    I do wonder if it would work as a cura plugin, but not sure how to even start with that yet.

    • Like 4
    • Thanks 1
    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

    • Our picks

      • UltiMaker Cura 5.7 stable released
        Cura 5.7 is here and it brings a handy new workflow improvement when using Thingiverse and Cura together, as well as additional capabilities for Method series printers, and a powerful way of sharing print settings using new printer-agnostic project files! Read on to find out about all of these improvements and more. 
         
          • Like
        • 20 replies
      • S-Line Firmware 8.3.0 was released Nov. 20th on the "Latest" firmware branch.
        (Sorry, was out of office when this released)

        This update is for...
        All UltiMaker S series  
        New features
         
        Temperature status. During print preparation, the temperatures of the print cores and build plate will be shown on the display. This gives a better indication of the progress and remaining wait time. Save log files in paused state. It is now possible to save the printer's log files to USB if the currently active print job is paused. Previously, the Dump logs to USB option was only enabled if the printer was in idle state. Confirm print removal via Digital Factory. If the printer is connected to the Digital Factory, it is now possible to confirm the removal of a previous print job via the Digital Factory interface. This is useful in situations where the build plate is clear, but the operator forgot to select Confirm removal on the printer’s display. Visit this page for more information about this feature.
          • Like
        • 0 replies
    ×
    ×
    • Create New...