Problem with gcode_button

Basic Information:

Printer Model: Ender 5 Plus

Hi, I have the following problem, I am trying to add linked buttons to raspberry pi 3B. The problem is that after adding them in the config, some of them are high logic by default, which is why they are unable to detect when the button is pressed. The wire connection is correct, is there any option to change the default state to low? I will also add that I once used the same configuration on another printer (also Ender 5 Plus), with the difference that that one is based on fluid, and the one I am currently having a problem with is based on moonraker.
Gpio with logical level 0 (gpio 10, gpio 17, gpio 27) work properly. After checking in the console, the pins were configured for use.

[mcu host]
serial: /tmp/klipper_host_mcu

[gcode_macro variables]
variable_is_print_paused: 0     #1 for paused print; 0 for print in progress
gcode:
    M115 ; must provide something

[gcode_button PREHEAT_button]
pin: host:gpio2 
press_gcode:
    POWER_ON_PRINTER
    {action_respond_info("Preheating PLA...")}
    SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET=60
    SET_HEATER_TEMPERATURE HEATER=extruder TARGET=220

[gcode_button STOP_button]
pin: host:gpio3 
press_gcode:
    {action_respond_info("Emergency stop!")}
    FIRMWARE_RESTART

[gcode_button UNLOAD_button]
pin: host:gpio4 
press_gcode:
    {action_respond_info("Preparing to unload filament...")}
    UNLOAD_FILAMENT

[gcode_button MOTOFF_button]
pin: host:gpio17 
press_gcode:
    M84
    {action_respond_info("Motors disabled!")}

[gcode_button PLAYPAUSE_button]
pin: host:gpio22 
press_gcode:
    {% if printer["gcode_macro variables"].is_print_paused == 0 %}
        PAUSE
        SET_GCODE_VARIABLE MACRO=variables VARIABLE=is_print_paused VALUE=1
        {action_respond_info("Print paused via button!")}
    {% endif %}
    {% if printer["gcode_macro variables"].is_print_paused == 1 %}
        RESUME
        SET_GCODE_VARIABLE MACRO=variables VARIABLE=is_print_paused VALUE=0
        {action_respond_info("Print resumed via button!")}
    {% endif %}

[gcode_button SERVICE_button]
pin: host:gpio10 
press_gcode:
    POWER_ON_PRINTER
    {action_respond_info("Moving the bed down...")}
    G28
    G1 z300 F1800


Also there are screens from that another printer where all works properly:



I don’t really understand how a gpio set to detect high logic can function when it is in default high state. Any ideas?

Try initializing your pins to low. Something like

[output_pin preheat]
pin: host:gpio2
value: 0

As per the RPi datasheet the default state of GPIO 0 to 8 is high. See https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf#page=102

Alternatively, you can determine the default pull via config.txt

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.