Coder Social home page Coder Social logo

nfc2klipper's Introduction

REUSE status GitHub Workflow Status

nfc2klipper

Set loaded spool & filament in klipper from NFC/RFID tags.

Prepare for running nfc2klipper

In the cloned repository's dir run:

virtualenv venv
venv/bin/pip3 install -r requirements.txt

Preparing an NFC reader

I use a PN532 based reader (Elechouse PN532 NFC RFID Module V3, if you want to use the same) connected via UART to the raspberry pi where this program is running.

Many pages suggest connecting its VCC pin to 5V on the RPi. Don't! It can run from 3.3V and then it won't risk slowly destroying the RPi's GPIO pins.

See here for how to configure a raspberry pi for it (but change VCC pin...).

There is a model for attaching it to the printer here.

PN532 bug in the nfcpy module

When running it on a raspberry pi's mini-uart (ttyS0 as device), it works fine. When using the other UART (ttyAMA0), I can only run the programs once. I have to power cycle the PN532 to get them to run again. Just rebooting the pi doesn't help.

This seems to be due to a bug in nfcpy (version 1.0.4), see (nfcpy/nfcpy#186).

A workaround that works for me is to change venv/lib/python3.7/site-packages/nfc/clf/pn532.py around line 390, from:

        change_baudrate = True  # try higher speeds

to:

        change_baudrate = False  # try higher speeds

Preparing klipper

When a tag has been read, it will send these gcodes to Klipper:

  • SET_ACTIVE_FILAMENT ID=n1
  • SET_ACTIVE_SPOOL ID=n2

See klipper-spoolman.cfg for the klipper config for them. Klipper must also have a [save-variables] section in its config, see Klipper's documentation.

Preparing the slicer

For every filament, add a custom start gcode that calls:

ASSERT_ACTIVE_FILAMENT ID=<id>

where <id> is its filament id in Spoolman.

This can be done automatically by using sm2ss.

Preparing tags

The tags should contain an NDEF record with a text block like this:

SPOOL:3
FILAMENT:2

The numbers are the id numbers that will be sent to the macros in klipper via the Moonraker API.

This can be written via NXP's TagWriter on a phone, or better yet, use the write_tags.py program. The later fetches Spoolman's filaments, shows a simple text interface where the spool can be chosen, and when pressing return, writes to the tag.

Use the write_tag script to stop the nfc2klipper service before and start it again after.

Run automaticly with systemd

Copy nfc2klippper.service to /etc/systemd/system, then run:

sudo systemctl start nfc2klipper
sudo systemctl enable nfc2klipper

To see its status, run:

sudo systemctl status nfc2klipper

nfc2klipper's People

Contributors

bofh69 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.