控制树莓派的usb口供电

树莓派 徐 自远 3315℃

Cool Music

 

我以较高的价格购买了一些Klipsch AW-400户外扬声器,并将它们安装在我的车库(这是一栋单独的建筑物)中。为了驱动它们,我购买了HifiBerry AMP +和Raspberry Pi 3B +。我一直在使用Max2Play进行音乐流传输,但是遇到了Volumio,所以我更喜欢它。Web界面要好得多。另外,它使共享另一台Raspberry Pi上用作媒体服务器的USB硬盘变得非常容易。

Volumio开箱即用,工作正常,非常容易遵循其网站上的设置说明。我遇到的问题是,由于我生活在沙漠中并将Raspberry Pi放在车库的高架子上,因此有时会过热。我为此买了散热器,但是并不能解决散热问题。

我的解决方案是我在鹅颈上买了一个USB供电的风扇。我得到了这个,但是任何USB供电的风扇都可以使用,而不是通过USB为电池充电的风扇。我想我可以让风扇不断吹拂Raspberry Pi,但是这样做的乐趣何在?我认为如果可以读取温度,则可以根据需要打开和关闭风扇。我可以。是的,我做到了,这就是方法。

我发现CPU温度以摄氏度为单位存储在/ sys / class / thermal / thermal_zone0 / temp中,这表示45000为45°C。

在GitHub上找到了uhubctl,它允许某些应用程序中的Linux 控制一些智能USB集线器。幸运的是,RPi 3B +是正确的应用程序,其USB端口是正确的智能USB集线器。要使其正常工作,必须先下载并编译它。

Volumio是Debian精简版。要添加缺少的标准软件,请运行:

接下来,安装gcc,make和USB库:

Volumio ships as a fairly stripped down version of Debian. To add the missing standard software, run:

Next, install gcc, make, and a USB library:

To download the uhubctl command, we need to install git:

At this point we should be able to download and compile uhubctl:

uhubctl is now ready to use. Next we need to find which port the fan is plugged in to. To list the ports run:

You should see an output something like:

In this case, my fan is plugged into hub 1-1 port 2 but it doesn’t show up.

To turn the right port off, you need to be specific about which hub and which port. Plug in the fan, and hunt for it by turning ports off one at a time till the fan stops.

The command to turn off my fan is:

To turn it back on:

And to get the current status:

Experiment with it and make sure you can control your fan. Next, we’ll create a script to switch the port on or off depending on the temperature of the CPU:

 

 

https://github.com/mvp/uhubctl#raspberry-pi-3b

转载请注明:徐自远的乱七八糟小站 » 控制树莓派的usb口供电

喜欢 (7)

苏ICP备18041234号-1 bei_an 苏公网安备 32021402001397号