Skip to content

Repository files navigation

K2-RFID

Web app controlled and esp32-powered K2/CFS RFID programming thingy based on DnG-Crafts/K2-RFID.

Why do I need it?

Creality's K2 Plus printer supports 1k MIFARE tags to identify the spool's material and color. As the tagged spools from Creality come with an additional price and also to retrofit older Creality or non-Creality spools, you could use this tool to simply write your own tags, add two of them per spool and enjoy the magic of automatically identified materials.

What do I need to make one?

Essential components:

  • esp32 microcontroller board (tested with a Wemos S2 mini board)
  • PN532 NFC/RFID board
  • MIFARE classic 1k tags

Optionally:

  • housing (available on Printables or CrealityCloud)
  • WS2812b RGB LED (and ~1µF capacitor)
  • piezo disk (and ~100 Ohm resistor)

Very optionally:

  • battery
  • charger
  • switch
  • ...

How to use it?

Once you have programmed your esp32, connected it to the PN532 NFC/RFID board, and supplied it with power, a new access point (with SSID: K2RFID) will appear on your computer or phone. Set the WiFi credentials for your home network (or set it to AP-mode). After a restart of the device, just visit K2RFID.local. Here you can read and write the tags. Afterwards just put two of them (obviously with identical content) to a spool and load it into your printer's CFS.

Select Material Settings via UI

Just select the color by hitting the large color circle to select the color of choice (or select one the the known - at least known to me - standard colors), the type of material and the amount of material on the spool. After hitting the Apply button, the programmer is armed and will wait for tags to write the content. A serial number is auto-generated and will be used for all subsequent writes. A new serial number is genereted whenever you hit the Apply button again.

screenshot UI

Copy/Clone Tag

Once a tag is read, just click the toast notification and it will make the content (color, material, weight, and serial number - in case clone serial number is active in the settings) of the tag available for writing. Just hit the Apply button to arm the programmer.

Safeguarding existing Tags

By default, only empty tags are written. When you want to re-program tags, disable the Write only empty tags checkbox in the settings.

Future Materials

As of now, a fixed set of materials (defined by the K2Plus's firmware) is known to the programmer. You can update the list by hitting the Update Database button in the setting. It will try to identify a K2Plus or Hi on your local network, download the material database and saves it onto the programmer. No warranty that future firmware updates might break this behaviour...

screenshot settings

Device Feedback

I've added a most annyoing beeper to the programmer. You can switch it off in the settings.

LED

On boards with an onboard LED the current state and events are shown via the LED.

RGB_BUILTIN

On boards with an onboard RGB-LED or with an external WS2812b, different colors are used:

  • Serving captive portal (connect to enter credentials):

    • rapidly blinking white
  • Waiting for network connection:

    • blinking white
  • Connected to WiFi (or in AP-mode) and waiting to read tags:

    • dim solid blue
  • Tag read:

    • flashing blue
  • Armed to write tags:

    • breathing green
  • Armed to write and re-write tags:

    • breathing red
  • Tag written:

    • flashing red/green

Note: just make sure that the RGB_BUILTIN_LED_COLOR_ORDER is set matching your board. Otherwise the colours will look strange.

LED_BUILTIN

On boards with an onboard mono-color LED:

  • Serving captive portal (connect to enter credentials):

    • blinking rapidly
  • Waiting for network connection:

    • blinking
  • Connected to WiFi (or in AP-mode) and waiting to read tags:

    • dim solid
  • Tag read:

    • flashing
  • Armed to write tags:
    • breathing
  • Armed to write and re-write tags:

    • breathing quickly
  • Tag written:

    • flashing

Web logging

Even though there is no button for it, if you open k2rfid.local/weblog, you'll see a logging window. For every tag being read it will show a hex and ascii dump of the data on the tag.

screenshot weblog

Build instructions

Assembly

Essentially required are only the ES32 and a PN532 board. For some audible feedback, I've added a 27 mm pizo disc and a 100 Ohm resistor (on pin 16).

Connect the PN532 board pins to:

PN532 ESP
SCK 12
MOSI 11
SS 7
MISO 9

Don't forget the ground line and connect PN532's VCC to the 3.3 V regulator output of the ESP board.

Note: The PN532 needs to be set to SPI-mode. On my board, there is a DIP switch that needed ajustment as it came in UART-mode. Look for the print on the PCB and adjust the switches accordingly (I needed to toggle SW2 to 1).

beeper circuit

Adding an external RGB-LED

I found an old RGB LED-strip in my pile of junk. cutting one of the LEDs from the strip, it could just be added to the board (at pin 18, an additional buffer capacitor stabilizes the output of the 3.3V regulator on the S2 mini board).

led circuit

Flashing Firmware

The easiest way to get the firmware on the board is using esptool.py. After installing esptool.py and downloading the factory firmware image matching your setup from the releases-section, upload it to the board (using the usb port of your board) with: esptool.py write_flash 0x0 ADJUST_TO_YOUR_PATH/firmware.factory.bin.

Note: When uploading to a factory fresh board, you might need to enable uploads by pressing both buttons, release the "0"-button first, then the "RST"-button (this sequence will enable the USB-CDC).

Rebuilding the Firmware before Upload

If you want to rebuild the firmware yourself before uploading, you'll need to have PlatformIO (and esptool.py).

For minifying the html parts, you also need to have Node.js. Install development dependencies:

Then clone the repository, open it in Visual Studio Code, possibly adjust the platformio.ini to your likings and build it for your board. After a (successful) build, you can flash it using esptool (a hint on the command line is given after building).

Acknowledgements

  • This project is based the project DnG-Crafts/K2-RFID. I redesigned the website to my likings, and completely re-wrote the esp32 code.

  • The app icon is modified from Solar Icons in CC Attribution License via SVG Repo.

  • The favicon was prepared according (loosely) the guide How to Favicon in 2025.

  • Creating svgs with Inkscape leaves a lot of clutter in the file, svgo helps.

  • The Toast notifications are made with Toastify.

  • Splashcreens for iOS are auto-generated with iosPWASplash.

  • The formula for generating the breathing LED was found in a post at ThingPulse.

About

Web app controlled and esp32 powered K2/CFS RFID programming thingy.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages