Friday, June 5, 2020

OctoPrint: Turning on an LED during printhead heating

I do this so I can more easily inspect the printhead for ooze, etc.

Install OctoPrint plugin "GCODE System Commands"

Configure Plugin

OCTO 21 /home/pi/scripts/led-on
OCTO 22 /home/pi/scripts/led-off

Use This Code

$ cd /home/pi/scripts
$ cat led-on.c
void main()
  system("echo 23 >/sys/class/gpio/export");
  system("echo out >/sys/class/gpio/gpio23/direction");
  system("echo 1 >/sys/class/gpio/gpio23/value");
$ cat led-off.c
void main()
  system("echo 0 >/sys/class/gpio/gpio23/value");
  system("echo 23 >/sys/class/gpio/unexport");

$ make led-on led-off
(ignore warnings)

$ sudo chown pi.gpio led-off led-on
$ls -l led-on led-off
-rwxr-xr-x 1 pi gpio 7984 Jun  5 20:33 led-off
-rwxr-xr-x 1 pi gpio 7984 Jun  5 20:33 led-on

Add OCTO commands to to your slicer gcode template

(for Prusa-Slicer, in Printer Settings/Custom Gcode/Start GCode).
Mine looks like this:

G28 W ; home all without mesh bed level
OCTO21 ; turn on external light
G1 Z30 ; raise printhead for visual inspection
M109 S[first_layer_temperature] ; wait for extruder temp
M190 S[first_layer_bed_temperature] ; wait for bed temp
OCTO22 ; turn off external light

No comments:

Post a Comment