@@ -11,7 +11,20 @@ SPDX-License-Identifier: GPL-3.0-or-later
1111# nfc2klipper
1212
1313<p >
14- Automatically sets the loaded spool & ; filament in klipper by using NFC/RFID tags.
14+
15+ nfc2klipper is a tiny part of a spool/filament management system.
16+ It makes sure Klipper knows which spool, and filament, that is loaded
17+ so the usage can be tracked in Spoolman.
18+
19+ New spools with OpenTag3D or OpenPrintTag NFC tags are automatically
20+ added to Spoolmans database. You can also add your own tag to a new
21+ spool, connect it to the spool in Spoolman and then the printer will
22+ track its usage without any further change.
23+
24+ [ spoolman2slicer] ( https://github.com/bofh69/spoolman2slicer ) is another
25+ (optional) part of the system. It generates slicer configuration files,
26+ making it easy to make the printer pause the print if the wrong filament
27+ is loaded.
1528
1629<img align =" right " src =" images/nfc_reader_on_voron.jpg " width =" 200 " height =" 158 " alt =" NFC Reader on Voron " />
1730</p >
@@ -41,7 +54,7 @@ Automatically sets the loaded spool & filament in klipper by using NFC/RFID
4154
4255## Prepare for running nfc2klipper
4356
44- Install python >= 3.9 .
57+ Install python >= 3.10 .
4558On some distributions you may need to install "python3-venv" or
4659something similar.
4760
@@ -62,11 +75,13 @@ venv/bin/python3 nfc2klipper_backend.py -c /path/to/config/directory
6275
6376nfc2klipper can use RFID/NFC tags containing its own format, but
6477it can also use tags in other formats, like tags for
65- Filaman, OpenTag3D and probably many others.
78+ Filaman, OpenTag3D, OpenPrintTag and probably many others.
6679
6780For it to be able to use other tag formats, the spool needs to have
68- an extra ` nfc_id ` field (just like FilaMan). Add it in Spoolman under
69- settings -> extra fields -> spool.
81+ an extra ` nfc_id ` field.
82+ Add it in Spoolman under settings -> extra fields -> spool.
83+ Set the "key" to ` nfc_id ` , the "type" should be ` text ` and the "name"
84+ can be anything you want.
7085
7186
7287## Preparing an NFC reader
@@ -86,33 +101,31 @@ used by OpenPrintTag. If you want to use those,
86101use a PN5180 reader instead.
87102
88103I use a "Elechouse PN532 NFC RFID Module V3" board connected via UART
89- to the raspberry pi where this program is running. The program uses
90- nfcpy which supports many other readers too, it might work with them
91- too, but I've not tested them.
104+ to the Raspberry Pi where nfc2klipper is running.
92105
93106Many pages suggest connecting its VCC pin to 5V on the RPi. Don't!
94107It can run from 3.3V and then it won't risk slowly destroying the RPi's
95108GPIO pins.
96109
97110
98111See [ here] ( https://learn.adafruit.com/adafruit-nfc-rfid-on-raspberry-pi/pi-serial-port )
99- for how to configure a raspberry pi for it (but change VCC pin...).
112+ for how to configure a Raspberry Pi for it (but change VCC pin...).
100113
101- Run ` sudo rpi-update ` to avoid problems with older firmware on the pi .
114+ Run ` sudo rpi-update ` to avoid problems with older firmware on the RPi .
102115
103116There is a model for attaching it to the printer
104117[ here] ( https://www.printables.com/model/798929-elechouse-pn532-v3-nfc-holder-for-voron-for-spoolm ) .
105118
106119
107120#### PN532 bug in the nfcpy module
108121
109- When running it on a raspberry pi 's mini-uart (ttyS0 as device), it works fine.
122+ When running it on a Raspberry Pi 's mini-uart (ttyS0 as device), it works fine.
110123When using the other UART (ttyAMA0), I can only run the programs once.
111- I have to power cycle the PN532 to get them to run again. Just rebooting
112- the pi doesn't help.
124+ I have to power cycle the PN532 to get it to work again. Just rebooting
125+ the RPi doesn't help.
113126
114- This seems to be due to a bug in nfcpy (version 1.0.4),
115- see (https://github.com/nfcpy/nfcpy/issues/186 ).
127+ This is due to a bug in nfcpy (version 1.0.4), see
128+ [ issue # 186 ] ( https://github.com/nfcpy/nfcpy/issues/186 ) .
116129
117130A workaround that works for me is to change
118131` venv/lib/python3.*/site-packages/nfc/clf/pn532.py `
@@ -136,24 +149,25 @@ patch -p6 venv/lib/python3.*/site-packages/nfc/clf/pn532.py < pn532.py.patch
136149### Using PN5180
137150
138151The PN5180 reader chip is much better than PN532, it can communicate
139- with a lot more chips . The driver however is limited right now and
140- not as well tested as nfcpy.
152+ via more protocols . The driver however is limited right now and not as
153+ well tested as nfcpy.
141154
142- The driver can only read NFC type 2 and V tags. That should be enough
143- for the tags I use, including OpenTag3D and OpenPrintTag tags.
155+ The driver can only read NFC type 2 (NTAG 21x, Mifare Classic) and
156+ NFC Type V tags (used by OpenPrintTag). That is enough for the tags I've used .
144157
145- The PN5180 is connected to a Raspberry Pi Pico Zero card and it is
146- connected via USB to the computer . See the link above for how to
147- put it together .
158+ The PN5180 is connected to a Raspberry Pi Pico Zero card and from there to
159+ the computer via USB. See the link above for how to put it together, including
160+ a 3D printed case for it .
148161
149162In the nfc2klipper.cfg file's "nfc" section, use "pn5180" as
150163"nfc-reader" and set "nfc-device" to
151164"/dev/serial/by-id/usb-Arduino_RaspberryPi_Pico_053444501C6F7A80-if00",
152165(but obviously change the serial number part to yours).
153166
154- One thing that isn't supported, is writing to tags. That was the
155- first method used by nfc2klipper, but the newer method of storing
156- the tags' ID number in Spoolman is a better method.
167+ One thing that isn't supported, is writing to tags. The driver supports it,
168+ but not nfc2klipper. That was the first method used by nfc2klipper,
169+ but the newer method of storing the tags' ID number in Spoolman almost
170+ always a better method.
157171
158172
159173## Preparing klipper
@@ -163,11 +177,14 @@ When a tag has been read, it will send these gcodes to Klipper:
163177* ` SET_ACTIVE_FILAMENT ID=n1 `
164178* ` SET_ACTIVE_SPOOL ID=n2 `
165179
180+ This can be be changed in nfc2klipper's configuration,
181+ see the ` macros ` section in the config file.
166182
167183See [ klipper-spoolman.cfg] ( klipper-spoolman.cfg ) for the klipper
168184config for them. Klipper must also have a ` [save-variables] ` section
169185in its config, see
170- [ Klipper's documentation] ( https://www.klipper3d.org/Config_Reference.html#save_variables ) .
186+ [ Klipper's documentation] ( https://www.klipper3d.org/Config_Reference.html#save_variables )
187+ for those macros to work properly.
171188
172189
173190## Preparing the slicer
@@ -183,17 +200,16 @@ This can be done automatically by using [spoolman2slicer](https://github.com/bof
183200
184201## Preparing tags
185202
186- If nfc2klipper reads a new [ OpenTag3D] ( #use-with-opentag3d-tags )
187- tag, it will automatically create a new spool in Spoolman and connect
188- it with the tag.
203+ If nfc2klipper reads a new OpenTag3D or OpenPrintTag tag, it will
204+ automatically create a new spool in Spoolman and connect it with the tag.
189205
190- If you have your own tags, you can either
206+ If you have your own tags (or the spool comes with another) , you can either
191207[ write custom data] ( #spool--filament-in-tags ) to them, or
192208[ connect their ID] ( #using-tags-id ) to the Spool in Spoolman.
193209
194210The second method allows nfc2klipper to be used with
195- [ FilaMan ] ( https://github.com/ManuelW77/Filaman ) and with manufacturers'
196- tags of different formats without changing them . It is now the recommended way of using nfc2klipper.
211+ tags without changing their content, making interop with other
212+ systems easier . It is now the recommended way of using nfc2klipper.
197213
198214## Runing the backend
199215
@@ -210,7 +226,6 @@ The latest read tags' identifier can be set in the Spool record in Spoolman via
210226server's page, click on the "Set in Spoolman" button for the spool that's loaded.
211227
212228That way the tag will be connected to that spool without having to change its data.
213- It will also make the spool connected in FilaMan.
214229
215230
216231### SPOOL & FILAMENT in tags
@@ -235,7 +250,7 @@ only run this on secure networks, or add reverse proxy (like nginx)
235250with some authentication. Follow the link above for Gunicorn's
236251documentation.
237252
238- To run it with ** little security** ;
253+ To run it with ** low security** ;
239254``` sh
240255gunicorn --bind localhost:5001 nfc2klipper_api:app
241256```
@@ -254,26 +269,13 @@ The web page lists the current spools in Spoolman.
254269By pressing the "Write" button, its info is written to the nfc/rfid tag.
255270
256271By pressing the "Set in Spoolman" button, the tag's id is stored in
257- an extra field for the spool in Spoolman.
272+ an extra field for the spool in Spoolman. This is the recommended method.
258273
259274
260275#### Write with an app
261276
262- There is an Android app, [ Spoolman Companion] ( https://github.com/V-aruu/SpoolCompanion ) , for writing
263- to the tags.
264-
265-
266- #### Write with console application
267-
268- This is no longer recommended and the program will be
269- removed in the future.
270-
271- The ` write_tags.py ` program fetches Spoolman's spools, shows a simple
272- text interface where the spool can be chosen, and when pressing return,
273- writes to the tag.
274-
275- Use the ` write_tag ` script to stop the nfc2klipper service, run the
276- ` write_tags.py ` program and then start the service again after.
277+ There is an Android app, [ Spoolman Companion] ( https://github.com/V-aruu/SpoolCompanion ) ,
278+ for writing to the tags.
277279
278280
279281## Run automatically with systemd
0 commit comments