Turn on/off USB port when printing starts/stops

I have OctoPrint running on an Ubutnu machine. I am trying to turn on a USB port when printing starts and turn off that USB port when printing stops. I have a camera and light plugged into the machine and would like the light to turn off and on automatically. I have just been plugging it in, unplugging it so far.

Tricky as this involves digging around in the device drivers on the laptop, best avoided. I've seen an ESP8266 controller on another Octoprint community board. Use that and control it from the laptop to switch a 5V relay on and off - you really DON'T want to blow the USB port so get your power control managed externally - you could use an Arduino controller and some python code to 'talk' to each other over the USB port - that would be perfect, and cheap. An Arduino nano is about Β£3 / $3 over here, you only need one I/O, but I'm sure you'd find use for more :slight_smile:

Awesome! I tried digging into the device drivers, i'm comfortable with that. couldn't seem to find the one for this USB port, but i'm sure i could dig around some more.

As for an arduino, forget which one off the top of my head, i actually have one lying around! but have never used it and don't really know where to start. lol. maybe i'll check that out.

It's not a huge deal, since i don't print unless i'm home, but i just think it's silly to plug/unplug a light just for printing. Β―_(ツ)_/Β―

If you don't mind all of the USB Type-A connectors on the Pi being turned on/off together, you could try my USBControl plugin. Note that there is a REST API. You could combine this with, say, the Gcode Systems Command plugin to issue pseudo-gcode to perform these actions.

1 Like

Neat!. Might try that - the 3B's running off a PC PSU are whinging constantly about low voltage, might be the PSU not putting out 5.2V - infact I know it doesn't, there's a USB Doctor hanging off one of the 5V USB ports. Getting the LCD off when the printer is off is a good plan..

There's also a tiny shim you can print from thingiverse that blocks the 5V line, there are descriptions on here about how to put tape over the 5V pad inside the plug... and I have a hardware gadget design for programmatically toggling the line.

Hmm not running off a pi, says in the README it's not intended for other Linux workstations, like I have. Maybe I'll give it a shot, but just curious as to why this is the case?

I only intended for it to be used on a Pi computer. There are enough differences in other operating systems making it difficult to support.

Also, feel free to just roll your own solution with the underlying uhubctl code itself.

Because that level of control is possible on a Pi through the published interface and control documentation - the same cannot be generally said for an Intel or AMD chipset based system. Pi's documentation is open, for people to use/abuse :slight_smile: Caveat emptor or YMMV! You'll need to dive into the device drivers and be prepared to hack them. Doesn't sound like a whole bag of fun unless you write device drivers for a living.