Jump to content

Read/Write NFC Tags


xperiment

Recommended Posts

Posted · Read/Write NFC Tags

@Bunnyman21 cool to see what you made of it. Do you host this on an open source site like GitHub? I'd love to give it a try. I see the potential of this being a Cura plugin, possibly with access to Cura's material database, but a standalone GUI is already a big plus over the CLI tool I wrote.

  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags
    On 9/16/2020 at 9:22 AM, Bunnyman21 said:

    @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.


    Hi,

     

    oh man: Could you share that, please? I'm getting crazy with not knowing how to use the scripts.

     

    Thanks a lot,

     

    Josef

  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    @gandy @jomeier No problem, I put the link below. Still had some things I wanted to fix before uploading which are done now. Note it doesn't detect directories automatically for Mac or Linux yet, but can detect Cura for Windows just fine. For Mac/Linux, just give it the file paths. The script should work on a Pi too, but better to use command line for that rather than GUI.

     

    https://github.com/DA-Osborne/Spool-Maker

     

    @gandy A cura plugin would definitely make it easier to match up Materials. Looks like Cura has a page dedicated for making plugins that work within Cura I need to read sometime. For now the CuraMaterial.py file can load all installed materials. (in a crude sort of way)

     

    I normally run it from within Visual Studio Code, as double clicking it doesn't always work. I added a resource loader so you can also run pyinstaller to make an exe version if that's easier. Otherwise, the main function allows the creation of a spool by simply filling in the required variables at the bottom of the NFCSpool.py file. (The GUI is launched from the SpoolMaker.py file on the other hand)

     

    I have used it for some PolyWood material so far by winding it onto a depleted Ultimaker spool, and overriding the tag with the correct ID and remaining length. Very useful for knowing if there is enough material left!

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

    Posted · Read/Write NFC Tags

    This is very timely.  I ordered the ACR122U reader, which arrived today.  I'll run this within Visual Studio Code as well.  While probably off topic, as I am new to running an NFC reader, am I right to assume I have to set up a Raspberry Pi to bridge the reader to my windows desktop, or is there an easier way?

     

    A second question - when you loaded the PolyWood and overrode the tag with the 'correct ID'.  I'm assuming one can only use IDs that are recognized materials in both Cura and the machine firmware?  (I have a UM3 very reliably running very old firmware and a similarly old but stable Cura....)

     

    Thanks again for this initiative!

  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags
    21 minutes ago, JohnInOttawa said:

    This is very timely.  I ordered the ACR122U reader, which arrived today.  I'll run this within Visual Studio Code as well.  While probably off topic, as I am new to running an NFC reader, am I right to assume I have to set up a Raspberry Pi to bridge the reader to my windows desktop, or is there an easier way?

     

    A second question - when you loaded the PolyWood and overrode the tag with the 'correct ID'.  I'm assuming one can only use IDs that are recognized materials in both Cura and the machine firmware?  (I have a UM3 very reliably running very old firmware and a similarly old but stable Cura....)

     

    Thanks again for this initiative!

    I just plug my ACR122U directly into the windows PC. Windows recognises it as a smartcard reader and Python then interfaces with it directly, no Pi needed.

     

    This is correct, you must have the material installed in Cura first if using the GUID. (or for PolyWood I created a new Material which generates a new one) The GUI searches for all installed materials, including custom materials. If you use the main function from the command line, technically you could give it whatever GUID you like, but if it's not in the printer I imagine nothing would happen.

     

    I find it best to backup custom Materials too, otherwise, if they get lost the GUID would change upon creating the material again.

     

    I always use the latest versions for Cura/UM3 firmware so I have not tested anything with older versions, but it should work fine.

    • Thanks 1
    Link to post
    Share on other sites

    • 1 month later...
    Posted · Read/Write NFC Tags
    On 10/21/2020 at 12:07 AM, Bunnyman21 said:

    @gandy @jomeier No problem, I put the link below. Still had some things I wanted to fix before uploading which are done now. Note it doesn't detect directories automatically for Mac or Linux yet, but can detect Cura for Windows just fine. For Mac/Linux, just give it the file paths. The script should work on a Pi too, but better to use command line for that rather than GUI.

     

    https://github.com/DA-Osborne/Spool-Maker

    I really hate to ask, since you've done so much awesome work on this already, but I'm not much of a coder (dabbler, only) and I'm really not up to speed on Visual Studio Code. I keep getting errors about missing module PyQt5. Could I possibly impose on you to give us programming noobs either a step-by-step or a compiled executable? Thank you so much!

  • Link to post
    Share on other sites

    Posted (edited) · Read/Write NFC Tags
    Finally got this to work, once I got all the right Python modules installed. The one that really got me stuck was that I installed ndef instead of ndeflib. Also took me a while to figure out SWIG so I could install the pyscard module. Anyway, got it sorted, but I'm sure others following would still appreciate a handy executable. Thanks!
    Edited by rachael7
  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    Has anyone been able to make new tags from scratch, rather than reprogramming the UM spools?

  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    Has anyone managed to produce a how to/Step by Step guide on this yet?

     

    Thanks

  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    Well, I was able to answer one question myself. This script is perfectly capable of writing new tags on blanks, in addition to changing existing spool tags. The trick is finding the right tag to use.  After some trial, error, and research, it appears the tags you need are Mifare Ultralight NTAG216.  The NTAG216 part really is the essential bit and what you should search on. I can confirm that these ones, from Amazon, work: https://www.amazon.com/gp/product/B07BF8MSN9/. Just select your material from the list, put the blank on the reader, and click "Write Tag". Couldn't be easier.         

    • Like 2
    Link to post
    Share on other sites

    Posted (edited) · Read/Write NFC Tags

    Thanks, Rachel et al.

    I’ve found the NFC reader/writer ACR122U based on Amazon, as well as the tags (NTAG216).

    I’ll try it in MacOS (BigSur) asap...

     

    Question: but having a latest iPhone (nfc write capable), with app like “NFC Tools” that can write NTAG216, might you simply program each tag with the correct ID (copy & paste from Cura) to have a similar solution?

     

    thanks

     

    Edited by gmeardi
  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags
    14 hours ago, gmeardi said:

    Thanks, Rachel et al.

    I’ve found the NFC reader/writer ACR122U based on Amazon, as well as the tags (NTAG216).

    I’ll try it in MacOS (BigSur) asap...

     

    Question: but having a latest iPhone (nfc write capable), with app like “NFC Tools” that can write NTAG216, might you simply program each tag with the correct ID (copy & paste from Cura) to have a similar solution?

     

    thanks

     

    I can't say for sure, but maybe? The issue is that most NFC stuff seems to only use the ID of the chip, and not the actual data storing capacity of the tag, so most of the NFC apps I found couldn't do anything with the data portion at all.  I could manually edit some of the data fields with NFC Tools on PC, but I feel like I read somewhere that IOS doesn't actually let you do what you need to do with the phone.  Also, you have to figure out which fields store the data you need to change and edit it in hex.  For example, the total material weight on the roll was in 2E when I looked at it with NFCTools (I don't think the apps all number the memory fields the same) and the remaining weight was in 2F.  I didn't track down where the material ID was, though I'm sure it wouldn't be too difficult.  In the end, I gave up on that approach, since even with the challenges in setting up Python, it was still easier to just use the tool in this thread.

  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    @rachael7 Sorry I didn't see your posts until now, i've been without a computer for 2 months. That's a great idea, once I fix my main PC I should probably compile and upload an exe version to make it easier.

     

    Seems you got it all working though, I did the same and used some NTAG216 tags from eBay. The only concern I had with the small tags was if the Ultimaker would be in range of the tag in all positions around the spool while spinning, as the Ultimaker tags have an antenna that spans around the spool holder 😕  I didn't do much testing here, as I had plenty of empty UM spools to use.

     

    To determine which memory location relates to which part of the record, you can look directly at the python class, specifically the decode functions which tell you which bytes belong to which value. However, I did find it difficult to match them up this way. I added a function back when I was testing it called load_bin in the Spool-Maker script. You can dump the contents of the tags to a bin file (I used the TagMo app on Android) and read the raw values if you are interested. The load_bin function can be used to then decode this bin file. Hope this helps!

    • Like 1
    Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    Thanks, Bunnyman!  I can't even imagine being without a computer for a week, let alone 2 months! Good to see you back. I think the tags are going to work fine, at least the ones I got from Amazon. The pickup in the machine is inside the plastic divider between the bays. It's just a flex circuit, like you'd find in a keyboard or something (accidentally took one of those dividers out, so I've seen it). The tags I bought seemed to pick up at least as well as the UM ones. My UM spools only actually read if I rotate them until the tag is in the bottom half of the machine - I think they kept the transmit power low on purpose, to prevent cross-talk between bays. The purchased tags seemed to have similar response, so I'm comfortable with them. My biggest worry is that on non-UM spools, you may not have a recessed area for the tag and the tag could get damaged as the spool turns. Might be best to put a mailing label or some other sort of sticker over the tag to make sure there is no abrasion. Otherwise, I think we can turn any spool that fits into an NFC spool.

     

    On another matter, have you had a chance to play with the new 6.1 firmware yet? The release notes made it sound like they changed something relative to custom materials, so I'm wondering if it has any effect on what we're doing here.

  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    Sounds like the custom tags will be no issue then which is great. At one stage, I was unwinding and transferring my spools onto empty Ultimaker ones which was a tad painful.

     

    I only have an Ultimaker 3, so I don't have access to the new firmware (at least as far as I can tell), but I would imagine that the format of the tags would remain the same for now, otherwise newer spools may not work with the older printers? I had a look at the firmware page, seems they are allowing specific colours to be manually selected and loaded into the printer. I don't think this would change the tag format though as each colour is just another unique material ID.

  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    Yeah, I don't think it was any change with the format of the tags.  I'm hoping that they fixed what I think was a bug regarding new materials. As it stands now, if your new material has a material type field that matches an existing material, like PLA, ABS, etc, your custom material will not download to the material handler.  In order to get it to go into the material handler you have to give it a unique material type, like PLA1 or whatever. I really don't think that was their intention and the release notes sound like they may have addressed it. I'll have to test it soon.

  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    For anyone wanting some instructions or a compiled version, I have uploaded these to the GitHub now (as well as a bunch of fixes to the code). Hope it helps! Please let me know if you run into any issues and I'll take a look. I've tested the script on Windows 10 and MacOS 11. The exe seems to work on my PC, not sure if there are hidden dependencies involved though.

    • Like 1
    Link to post
    Share on other sites

    Posted (edited) · Read/Write NFC Tags

    Thanks so much, Bunnyman! Couple issues to report, at least on my end. Compiling the exe seemed to work, but then it wouldn't actually run. It gave an error about module failed to start or something. So I tried to run the uncompiled script again. It had been working before, so I was surprised it errored out. It returned:

     

    Quote

    Traceback (most recent call last):
      File "C:\Users\rachael.katz\Downloads\Engineering\Spool-Maker-main\SpoolMaker.py", line 36, in <module>
        import CuraMaterial as c
      File "C:\Users\rachael.katz\Downloads\Engineering\Spool-Maker-main\CuraMaterial.py", line 49, in <module>
        curaSysDir = OpenKey(HKEY_LOCAL_MACHINE, 'SOFTWARE\\WOW6432Node\\Ultimaker B.V.\\Ultimaker Cura 4.7')
    FileNotFoundError: [WinError 2] The system cannot find the file specified

     

    I had originally set this up when I was running Cura 4.7. I've since upgrade to Cura 4.8.0. Oddly, the reference to Cura 4.7 seems to be hard-coded into CuraMaterial.py.  How did I get myself into this mess?! LOL

    Edited by rachael7
  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    All that said, the EXE that you included as release 1.0.0 works great! So much easier without having to install Python! Thank you!!!

  • Link to post
    Share on other sites

    Posted (edited) · Read/Write NFC Tags
    7 hours ago, rachael7 said:

    Thanks so much, Bunnyman! Couple issues to report, at least on my end. Compiling the exe seemed to work, but then it wouldn't actually run. It gave an error about module failed to start or something. So I tried to run the uncompiled script again. It had been working before, so I was surprised it errored out. It returned:

     

     

    I had originally set this up when I was running Cura 4.7. I've since upgrade to Cura 4.8.0. Oddly, the reference to Cura 4.7 seems to be hard-coded into CuraMaterial.py.  How did I get myself into this mess?! LOL

    Hmm, that's odd. The error indicates that the registry key HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Ultimaker B.V.\Ultimaker Cura 4.7" doesn't exist. It was hard coded in the previous version, but the new version should find the latest version automatically. Line 49 on my copy is blank, could you check the version of the CuraMaterial.py script you are using has the following on line 58:

    curaSysDir = OpenKey(HKEY_LOCAL_MACHINE, 'SOFTWARE\\WOW6432Node\\Ultimaker B.V.\\' + latestInstalled, 0, KEY_READ)

     

    There should be no hardcoded version numbers anymore for the Windows or Mac sections. The latestInstalled variable should be the latest version it finds in the registry key: HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Ultimaker B.V.

     

    Edit: Might also be worth checking you don't have any compiled .pyc files left from before you downloaded the new scripts. Just incase it is using those instead of the new code.

     

    I'm glad the exe version is working though 😄 
     

    Edited by Bunnyman21
  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    Ah, that's my problem. I didn't roll the rev to your new scripts at all, except for the exe. My bad. I'll download the new versions and give it another go. Thanks!

  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags

    Has anyone found a source for the NFC tags in a form factor like the ones used on the Ultimaker spools? i.e. a large ring with a hole in the center. I've been using the ones about the size of a quarter and I'm having trouble getting the printer's reader to pick up the tags reliably. I have to get the tag in just the right spot for material 1 to get recognized.

  • Link to post
    Share on other sites

    Posted · Read/Write NFC Tags
    3 hours ago, Monroe07 said:

    Has anyone found a source for the NFC tags in a form factor like the ones used on the Ultimaker spools? i.e. a large ring with a hole in the center. I've been using the ones about the size of a quarter and I'm having trouble getting the printer's reader to pick up the tags reliably. I have to get the tag in just the right spot for material 1 to get recognized.

     

    I have the same issue with positioning. The tags work, but they're super finicky. I don't think you're likely to find ones like Ultimaker uses. I surveyed the market pretty thoroughly when I was working on this and I'm pretty sure the UM ones are custom made. It's actually not that expensive to have them custom made, but you do need to get a bunch. Maybe if someone wanted to put together a group buy we could pull it off.

  • Link to post
    Share on other sites

    Posted (edited) · Read/Write NFC Tags
    On 6/4/2021 at 9:56 PM, rachael7 said:

     

    I have the same issue with positioning. The tags work, but they're super finicky. I don't think you're likely to find ones like Ultimaker uses. I surveyed the market pretty thoroughly when I was working on this and I'm pretty sure the UM ones are custom made. It's actually not that expensive to have them custom made, but you do need to get a bunch. Maybe if someone wanted to put together a group buy we could pull it off.

    I've got evidence that perhaps the size of the tag plays a role in its reliability to be read and in only certain positions. I tried several different sizes and brands of tags and have decided to use the ones sold on amazon at the following link because they work reliably.

     

    Larger NFC Tags

     

    Here is what I did to test the several brands/sizes of tags.

    - I created a material that made it clear that the printer was in fact detecting the test tag and not an Ultimaker tag from the adjacent spool(i.e. the brand was my name and the display name for the material was "Test Material" )

    - I wrote the test material info to a tag (Thank you so much everyone involved in the spool maker program and scripts, it really has been a great and convenient tool!)

    - Tested that the tag was in fact read at several orientations (used the diagnostics tool on the printer to see the tags detected by the printer. I placed it on the spool holder at an orientation and then once detected, removed it and waited for it to no longer be detected and cleared off the screen, rinse and repeat at 8 different orientations; 0 degree's, 45, 90, 135 ect.)

     

    What I found was the tags in the 25mm diameter range had to be placed at in a way that that the edge of the tag was nearly rubbing on the Ultimaker's spool holder as it rotated. I have had great success with eSun brand PLA+ and ABS on several different printers, and since, unlike Matter hackers spools, eSuns's spools tend to have a small hole in the center and a gap between the center hole and the actual surface that the filament is wrapped around (and wall of the spool), it was not at a position that was reliable.  I found tags in the 40mm range were reliable all the way out to the edge of a spool!

    Edited by Monroe07
    • Like 2
    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
        • 18 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...