Control USB-powered devices with a Raspberry Pi

Power Point

© Lead Image © Burmakin Andrey, 123RF.com

© Lead Image © Burmakin Andrey, 123RF.com

Author(s):

Command-line tools and Node-RED on a Raspberry Pi let you control projects that use the USB ports.

For home automation projects, a Raspberry Pi offers a simple, low-cost approach to managing and controlling a wide variety of devices. Typically these devices are either digitally wired 0-5V devices such as motion detectors, or wireless Ethernet devices such as smart plugs. It's important to note that a Raspberry Pi can also control USB-powered devices, such as USB fans, lights, and low-end controllers.

In this article, I look at how to monitor, control, and measure USB power in two Raspberry Pi projects. The first project uses Node-RED to create a web dashboard to monitor and control USB lights. The second project turns on USB cooling fans according to the Pi's CPU temperature.

Controlling USB Ports

A number of techniques allow you to control USB ports, and I found that one of easiest approaches is to use the uhubctl [1] utility, which lets you view and control local USB ports and ports on smart USB hubs. To load this utility, enter:

[...]