查看树莓派温度
一个命令搞定:
cat /sys/class/thermal/thermal_zone0/temp
输出的结果除以1000即为当前环境温度(单位为摄氏度)。
另附一个检测CPU温度,过高自动关机的C++程序:
#include <iostream>
#include <fstream>
using namespace std;
int main(void)
{
ifstream file("/sys/class/thermal/thermal_zone0/temp", ios::in);
int temp = 0;
file >> temp;
file.close();
if (temp > 65000)
{
system("`date` > /root/shutdown_time.log");
system("shutdown now");
}
else
{
cout << temp << endl;
}
return 0;
}
本文版权,除注明引用的部分外,归作者所有。本文严禁商业用途的转载。非商业用途的转载需在网页明显处署上作者名称及原文链接。