Trigger a GPIO pin based on print progress

Hi!

I´ve searched the web for an answer but can´t find anything really relevant.

I have connected a fan to a relay which is controlled by a GPIO pin on my raspberry. With the enclosure plugin I can turn on and turn off this fan with a button in the webinterface.

However I would like to start the fan based on print progress, i.e. at ~2% print. And turn it off when cancelled or finished print.

Is there any simple way to achieve this functionality. I know that the progress can be reached through event hooks and REST API, but is this the correct way to go? And what is the best way to do this then?

Kind Regards
Carl

I can't tell you the best way.. I would use the mqtt plugin, a mqtt server and node-red with the node-red-node-pi-gpio module.

So install mqtt plugin, start mqtt server on same Pi as octoprint and run node red on the same Pi also? Do you know if there are any examples out there? :thinking:

yes :slight_smile:

not that I'm aware of

Ok, I will start to check out some mqtt/gpio guides and see if I get anywhere :slight_smile: thanks for the tips!

If you know Python, this could be done really easily from a plugin.

Silly question, can't you do that in the slicer with a height modifier?

Not when the pi is controlling the fan :slight_smile:

You can use the plugin OctoPrint-FanSpeedMirror to send the M106 S parameter value to a script on the RPi.

1 Like