Webcam activates LEDs?

That´s great! Maybe if I have enough spare time I consider adding RGB lights to my printer.

Hey there Guys,

you inspired me to take a look into this topic and found a solution by utilizing the way octoprint detects if the mjpg_stream is viewed.

Check out this thread if someone is still interested: https://discourse.octoprint.org/t/detect-if-webcamstream-is-running-js-help-needed/4974/6

Hey, just a complete noob here, but I am having trouble following how this was solved. I just want to hook up a couple of LEDs. Could someone give me clear instructions as to which files need to be edited to make the gpio pins activate?

Thanks!!

Hey @Tiefling! What type of LEDs do you have?

If you are using WS281x/SK6812 type LEDs and my plugin OctoPrint-WS281x_LED_Status, you can take a look at the wiki in the repo (linked), which has some guides for LED setup.

I have a few cree 5mm LEDs that I was going to connect via the pins and mount to a camera holder. Can this be done with your plugin?

Thanks

If my googling is correct, no unfortunately.

They seem to be standard single-colour LEDs, which would not be controllable - my plugin targets the WS281x space, which has individually controllable LEDs, also known as NeoPixels. This thread was also talking about RGB Leds too.

You may be able to get LEDStripControl to work, but to my knowledge there is no plugin for just turning on/off standard LEDs - your best bet would be a custom script accessed from the system command menu if that's what you're aiming for.

Yeah I am upgrading to a ring of 12 NeoPixels, this should work well with your plugin I think. I will be using a separate power source then running the NeoPixels from GPIO 18.

If you want to use OctoPrint, run them from Pin 10. Described in the plugins' docs, as you can't use PWM on pin 18 without running as root.

Hey @Charlie_Powell, I have installed your plugin, thanks for that. I have run into some issues though. The LED closest to the Vin port is always on, and I am unsure how to solve this. Also once this is fixed will I be able to turn the light on and off on command, while viewing through a camera? Just for clarification this is the neopixel model I am using: https://core-electronics.com.au/neopixel-ring-12-x-ws2812-5050-rgb-led-with-integrated-drivers.html?utm_source=google_shopping&gclid=Cj0KCQjw-uH6BRDQARIsAI3I-UdifHQfIp0-VPOq4HPBnH0Z89uNsxZrdQ_PjFCoyt0qN8UFm27WHiIaAsbCEALw_wcB

Thanks!

:wave: @Tiefling!

Someone else reported an issue with the first LED, and it turned out to be their level shifter.

You could give that a go, or if not maybe it is an issue with that individual LED.

The on and off command is not implemented automatically when switching to the camera tab, but there are buttons in the navbar that you can use to turn them on and off.

Automatically turning it on is something on my list but it's not going to get looked at all that soon.

This drifted off from the origial question "How to switch on when stream/shot is watched?" to how to control raspi GPIOs. Sadly.

The original question is way more unique and also unsolved.
@supertaz came up with good ideas, but well, still no solution.

I myself tried to modufy ustreamer for this purpose.
While it works, the author of ustreamer pointed out that the http-forward solution is the cleaner solution.

If anyone has the skills, please help me:

I've made a little script based on a tutorial I found:
Sennevds/flask-video-streaming: Supporting code for my article on video streaming with Flask. (github.com)
This triggers a GPIO pin when someone access the stream and when there's no activity anymore and deactivate the pin.

This is first time I used flask so I don't know if this code is good but it works for me

Great work!
I like how it turns the whole streaming off when no one is watching!
It is pretty delayed though. I will try the other cameras (only tried CAMERA=pi)

PS: Len on snapshot is not implemented. You need to add:

PPS: Way better with v4l2. But heavy load on pi4.
image
I think it octopi will manage though:
FYI: I needed to build https://github.com/jnohlgard/python-v4l2capture from source, could not install the packages.

PPPS: Reducing resolution to 640x480 drops load to ~50%. You can also reduce fps for more performance. It also seems more responsive than octopi default mjpg-streamer. Great!

Yeah I disabled it on snapshot because I use the snapshot url in Home Assistant and the light would constantly turn on.
I've fixed this by disabling this in the script and in Octolapse I added 2 scripts to turn on the light just before taking a snapshot.

Is there an easy way to turn on the led while watching from the camera with Octoprint? I read it, but I didn't understand it.

@mryusufcan I improved this project a little bit:

It now has some documentation.
(Also renamed for this specific purpose)
If you have any questions or issues, please file a github issue.

1 Like

thank you, but I don't understand the codes.I can't.

Turn on and off via calling commands using Putty work
Soon as I add below bold code below; OctoPrint will no longer start :-:
server:
firstRun: false
onlineCheck:
enabled: true
pluginBlacklist:
enabled: true
secretKey: XYX
seenWizards:
backup: null
corewizard: 4
tracking: null

system:
actions:

action: lon
command: /usr/local/bin/scripts/light_on.sh
name: Turn Light On
action: loff
command: /usr/local/bin/scripts/light_off.sh
name: Turn Light Off
temperature:
profiles:

  • bed: 100
    ....

Any help?

It is probably an issue with the indentation, which we can't work out posted here. If you use the preformatted text option with three backticks like:

```
Your content
```

It will preserve the indentation correctly.

Thanking You:
back ticks result in

The OctoPrint server is currently not running

If you just started up your Raspberry Pi, please wait a couple of seconds, then try to refresh this page.

If the issue persists, please log into your Raspberry Pi via SSH and check the following:

  • Verify that the process is running: ps -ef | grep -i octoprint | grep -i python should show a python process:

pi@octopi:~ $ ps -ef | grep -i octoprint | grep -i python
pi 1441 1 6 11:12 ? 00:00:15 /home/pi/oprint/bin/python
/home/pi/oprint/bin/octoprint --host=127.0.0.1 --port=5000

  • If it isn't, the question is why. Take a look into ~/.octoprint/logs/octoprint.log , there might be an error logged in there that helps to determine what's wrong.
  • You might also want to try if you can restart the server (if no obvious error is visible): sudo service octoprint restart .

If all that doesn't help to trouble shoot the issue, you can seek support on the OctoPrint Community Forum. Please provide your OctoPi and OctoPrint versions as well as your octoprint.log and explain what you already tried and observed as detailed as possible.

Code in config.yaml (Back ticks don't show here for me)
backup: null
corewizard: 4
tracking: null

system:
actions:

action: lon
command: /usr/local/bin/scripts/light_on.sh
name: Turn Light On
action: loff
command: /usr/local/bin/scripts/light_off.sh
name: Turn Light Off


> Blockquote

temperature:
  profiles:
  seenWizards:
  seenWizards:
    backup: null