Simple Klipper G-code Button - no wiring - using SD-card detect pin
We calculate the final price from your selected file. You review and accept it before payment.
Saved on this device.
A simple way to add a Klipper button (latching) to a printer with a full-size SD-card slot, in my case an Ender3 S1.
- Rating
- 0 / 5
- Likes
- 25
- Downloads
- 51
- Makes
- 1
- Views
- 1,240
- Reviews
- 0
Updated at source:
Model information
- Source
- Printables
- Category
- Creality Parts & Upgrades
- License
- Creative Commons — Attribution — Share Alike
Introduction:
This is a simple way to add a Klipper button to a printer with a full-size SD-card slot, in my case an Ender3 S1.
The print snaps to the back of an SD card, the SD-detect pin of the printer board is then configured to act as a gcode_button allowing you to execute G-code (see below) or query its state in macros.
I included a few variants of the buttons (STOP, LED, HEAT, blank) and the freeCAD file for remixing.
If you don't want to use a real SD card, print a dummy model, e.g: https://www.printables.com/model/264020-sd-card-model
I did not merge the button with a dummy SD because this might break easily if printed upright
Print settings:
- Print face down (with text on the print plate)
- 0.2mm layer height
- 10% infill
- I used petg but pla should also work.
Klipper config:
Add a section like this to your printer.cfg:
# this just prints SD inserted/ejected to the console for testing
[gcode_button sd_switch]
# pin for creality v4 boards
pin: !PC7
# gcode triggered on inserting SD card
press_gcode: RESPOND TYPE=command MSG='SD inserted'
# gcode triggered on ejecting SD card
release_gcode: RESPOND TYPE=command MSG='SD ejected'On creality v4 boards, the SD-detect pin is PC7 (the exclamation mark ‘!’ just inverts press_gcode and release_gcode).
If you run a different board, search for "#define SD_DETECT_PIN" in the marlin source code for your printer and replace, e.g. for the skr mini v3, in:
/Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h
it says PC3 for the onboard sd card (not tested).
#define SD_DETECT_PIN PC3
Some other example configs:
- STOP printer (M112 - Shutdown)
[gcode_button sd_switch]
pin: !PC7
# gcode triggered on inserting SD card
press_gcode: RESPOND TYPE=command MSG='STOP reset'
# gcode triggered on ejecting SD card, here: M112 shutdown
release_gcode: M112- Switch neopixel LEDs on/off
[gcode_button sd_switch]
pin: !PC7
# gcode triggered on inserting SD card
press_gcode: SET_LED LED=bedled RED=1 BLUE=1 GREEN=1
# gcode triggered on ejecting SD card, here: switch neopixels to
release_gcode: SET_LED LED=bedled RED=0 BLUE=0 GREEN=0- Switch neopixel LEDs between print_percent and speed display using macro from https://github.com/digitalninja-ro/klipper-neopixel/blob/master/led_progress.cfg
[gcode_button sd_switch]
pin: !PC7
# gcode triggered on inserting SD card
press_gcode: NEOPIXEL_DISPLAY LED="bedled" TYPE=print_percent MODE=glow
# gcode triggered on ejecting SD card, here: switch neopixels to
release_gcode: NEOPIXEL_DISPLAY LED="bedled" TYPE=printer_speed MODE=glow