How can I programmatically enable and disable the power to a particular USB port on Linux? Is such a thing even possible? Mac answers appreciated as well!
I was tryi
Don't buy an expensive smart hub just for turning USB gadgets on and off.
All you need is a microcontroller.
Arduino Nano™ ATmega328 *
The Nano is a 16MHz 8-bit computer with 2K RAM and 32K of flash storage.
It has 22 programmable pins (8 analog and 14 digital).
It can read/write USB, and is powered by its 5.0V microUSB port (up to 12.0V external).
// USB Blinker
// Blink LED while receiving USB stream
//
// For Arduino Nano™
int LED = 13;
// setup() is run once at powerup or when reset button is pressed
//
void setup() {
pinMode(LED, OUTPUT); // Configure pin D13 as output
Serial.begin(9600); // Open 9600bps USB stream
}
// loop() runs forever at 16Mhz, blinking the LED at 1Hz when receiving USB data.
//
void loop() {
if (Serial.available() > 0) { // When stream is buffering
digitalWrite(LED, HIGH); // turn on LED
delay(500); // wait half second
digitalWrite(LED, LOW); // turn off LED
delay(500); // wait half second
while (Serial.available() > 0) // drain the buffer
Serial.read();
}
}
Exquisite tiny cases are available (also free 3d printables).
C4Labs Zebra Black Ice Case
* Use Genuine Arduino Nano™ only. Beware of counterfeits.
UPDATE: Miniaturised ATtiny and wireless microcontollers are also available.