我以较高的价格购买了一些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:
1 |
sudo apt-get update && sudo apt-get -y upgrade |
Next, install gcc, make, and a USB library:
1 2 3 |
sudo apt-get install gcc sudo apt-get install make sudo apt-get install libusb-1.0 |
To download the uhubctl command, we need to install git:
1 |
sudo apt-get install git |
At this point we should be able to download and compile uhubctl:
1 2 3 |
git clone git://github.com/mvp/uhubctl make |
uhubctl is now ready to use. Next we need to find which port the fan is plugged in to. To list the ports run:
1 |
sudo ./uhubctl |
You should see an output something like:
1 2 3 4 5 6 7 8 9 |
Current status for hub 1-1.1 [0424:2514, USB 2.00, 3 ports] Port 1: 0503 power highspeed enable connect [0424:7800] Port 2: 0100 power Port 3: 0100 power Current status for hub 1-1 [0424:2514, USB 2.00, 4 ports] Port 1: 0503 power highspeed enable connect [0424:2514, USB 2.00, 3 ports] Port 2: 0100 power Port 3: 0100 power Port 4: 0100 power |
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:
1 |
sudo ./uhubctl -l 1-1 -p 2 -a off |
To turn it back on:
1 |
sudo ./uhubctl -l 1-1 -p 2 -a on |
And to get the current status:
1 |
sudo ./uhubctl -l 1-1 -p 2 |
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口供电