I was hoping that someone has figured a way to make a filament runout detector using a usb optical mouse. I was looking at an old Mac usb mouse, and it has everything needed for the job. The “click” switch can sense the filament and the optics will make sure it is moving. Just plug it in to the PI usb socket and (just!) modify the Octoprint software. No need to modify the printer’s pcb.