【问题标题】:How to detect Raspberry Pi board model?如何检测树莓派板子型号?
【发布时间】:2021-04-22 00:28:08
【问题描述】:

我现在正在使用几个 Raspberry Pi 板。 我有 Pi Zero W、3B+ 和 4B。

我将在所有这些模型上运行相同的程序。 为此,我需要从 Python 代码中检测 Raspberry 板模型。 像这样,

def detect_board():
    '''
    return string representing board type, one of the following
        4B
        3B+
        3B
        ...
        Zero W
        Zero
    '''

如何获得板子型号名称?

【问题讨论】:

标签: python raspberry-pi


【解决方案1】:

感谢@Ani的评论,我创建了这样的检测功能,

def detect_model() -> str:
    with open('/proc/device-tree/model') as f:
        model = f.read()
    return model

【讨论】:

    猜你喜欢
    • 2015-08-05
    • 1970-01-01
    • 1970-01-01
    • 2015-08-05
    • 1970-01-01
    • 1970-01-01
    • 2020-01-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多