Use beeper from MKS SBC - which PIN?

I got it to work from within klipper, without using gcode_shell_command.
/sys/class/gpio/gpio82 inside klipper is rpi:gpiochip2/gpio18. But to make the pin available in klipper, we have to take it away from sysfs

These are the steps to get there:

1. take the pin away from sysfs, so it is available in klipper
To free the pin each time before klipper starts, add a service override file:
$ sudo systemctl edit klipper.service

There are just two lines of content, which go into the file that opens after running the command above:

[Service]
ExecStartPre=/bin/sh -c 'echo 82 > /sys/class/gpio/unexport'

 

2. set up the pin in klipper

In printer.cfg, configure the pin:

[output_pin beeper_pin]
pin: rpi:gpiochip2/gpio18

Add a macro that uses this pin to emit a beep, e.g.:

[gcode_macro BEEP]
gcode:  
  SET_PIN PIN=beeper_pin VALUE=1
  G4 P500
  SET_PIN PIN=beeper_pin VALUE=0

3. reboot the printer

 
 

If you want to reverse the canges to the service, you have to remove the override file - you can remove the whole directory, that contains the file:
$ sudo rm -r /etc/systemd/system/klipper.service.d/
and don’t forget to reboot.

1 Like