【树莓派】读取树莓派温度信息

在树莓派系统中,使用vcgencmd 命令,可以查看系统的一些信息

pi@raspberrypi:~ $ vcgencmd commands
commands="vcos, ap_output_control, ap_output_post_processing, vchi_test_init, 
vchi_test_exit, pm_set_policy, pm_get_status, pm_show_stats, pm_start_logging, 
pm_stop_logging, version, commands, set_vll_dir, set_backlight, set_logging, 
get_lcd_info, arbiter, cache_flush, otp_dump, test_result, codec_enabled, get_camera, 
get_mem, measure_clock, measure_volts, enable_clock, scaling_kernel, scaling_sharpness,
 get_hvs_asserts, get_throttled, measure_temp, get_config, hdmi_ntsc_freqs, 
 hdmi_adjust_clock, hdmi_status_show, hvs_update_fields, pwm_speedup, force_audio,
  hdmi_stream_channels, hdmi_channel_map, display_power, read_ring_osc, memtest, 
  dispmanx_list, get_rsts, schmoo, render_bar, disk_notify, inuse_notify, sus_suspend,
   sus_status, sus_is_enabled, sus_stop_test_thread, egl_platform_switch, mem_validate, mem_oom, mem_reloc_stats, hdmi_cvt, hdmi_timings, readmr, pmicrd, pmicwr, 
   bootloader_version, bootloader_config, file, vctest_memmap, vctest_start, vctest_stop,
    vctest_set, vctest_get"
pi@raspberrypi:~ $ 

在python中,使用如下命令,可以读取树莓派当前的CPU温度

import os
def getCPUtemperature():
    res = os.popen('vcgencmd measure_temp').readline()
    return(float(res.replace("temp=","").replace("'C\n","")))

参考资料:https://shumeipai.nxez.com/2014/10/04/get-raspberry-the-current-status-and-data.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值