RPi camera events

Hello!

I am a happy new user of OctoPrint (as well as 3D printing in general): about two weeks I bought and assembled Ender 3 Pro, successfully installed OctoPrint on RPi Zero W (and it works perfectly, right out of the box - even it's not officially supported), some other upgrades for printer, and I already printed bunch of funny or useful (for my DIY projects) stuff.

What I also want to do, it's add RPi controlled LED light. I already built one from unused small flashlight we've got for free on T-Mobile presentation at children museum ;), it's lightweight (I detached light head) and works really bright from my RPi Zero W GPIO port. The only thing left it's to make it turn on and off from OctoPrint.

Ideally (and logically), I want to turn it on (by executing command gpio 0 mode out) when someone (webpage or Android app or Cura) connected to videocast, and turn off (gpio 0 mode in) when all "watchers" are disconnected.

If this impossible (no events/states defined in OctoPrint - AFAIK, OctoPrint works with RPi cam directly?), I'd like to handle this by print start and end (probably, I already know how to do this - found on forums - but just wanna be sure).

Also will be nice to have controls (buttons?) on web UI to control my light.

Please don't send me to "RTFM" or lookup forums! It was too much 3D printing and OctoPrint related information I've read last two weeks :slight_smile: If you know how and can, please describe step by step instruction. Thank you!

P.S. I'm not a complete noob in Raspbian (and Linux at all), so you don't need to describe how to ssh to my RPi ZW, or edit config files etc.

You could do this with a variety of different GPIO based plugins. PSU Control is one that comes to mind that would allow you to configure what GPIO pin you connect to, then in your start/end gcode scripts of OctoPrint you add M80/M81 or whatever gcode command you configure to turn on/off. You could also use gcode system commands and then use scripts on the pi to turn on/off the GPIO.

Thanks, @jneilliii, but unfortunately "variety" doesn't work well for me :slight_smile: Could you please provide more detailed instruction for the better plugin (by your choice, i.e. you're using regularly)?

  • how to configure that plugin for the RPi camera events? Just make a screenshot if it's hard to describe. I don't need gcode scripts (not familiar with that), I just wanna run Raspbian program "gpio 0 mode out" and "gpio 0 mode in", what's all.
  • how to add controls for this plugin/these commands to OctoPrint web UI?

Let me back up, you could actually do this in OctoPrint 1.7.0 with Event Manger. You just add the event to run the system command. I don't know which command does what, but you could adjust as necessary.

1 Like

OK, thanks! Looks like built-in "Event Manager" is exactly what I'm looking for. BTW, I guess, ClientOpened and ClientClosed events means exactly what I'm thinking about? I already looked at Events β€” OctoPrint master documentation :slight_smile:

As for second part of my question: is it possible to add custom buttons to the web UI, to manually turn on and off flashlight?

Yes, custom controls allow for that. The Custom Control plugin will allow you to add them, but I recommend disabling the plugin once you get it configured the way you like it, because the plugin is known to wipe those settings in certain conditions. It basically gives a front end to this in the docs.

https://docs.octoprint.org/en/master/features/custom_controls.html#sec-features-custom-controls

This means you logged into the web interface, or a mobile application connected, etc.

So, I believe, I'm allset with that feature: installed it today and it works like a charm! Don't need web UI controls, actually; I'm open Android client, lights is on, close/switch to another app - lights turned off, pretty useful for controlling printing process in the dark basement. Here are the pics:

Ender 3 Pro with RPi Zero W + cam + flashlight head (will print a proper cam & light holder when I learn some CAD :slight_smile: )

Screenshot in full darkness (only RPi/OctoPrint flashlight is on). Should be more brighter (and probably will be :wink: ) but it's OK for now - model (and possible mess or issues) are visible.

1 Like