Adafruit PlatformDetect

3.88.0 · active · verified Thu Apr 16

Adafruit PlatformDetect is a Python library designed for best-guess platform detection across a wide range of single-board computers (SBCs) and other platforms. It primarily serves as a core dependency for Adafruit-Blinka, enabling CircuitPython API emulation on CPython. The library maintains an active development cycle with frequent releases to add support for new boards and chips.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart code demonstrates how to initialize the `Detector` and retrieve the detected chip and board IDs. It also includes examples of checking for specific popular board models.

import os
from adafruit_platformdetect import Detector

detector = Detector()

print(f"Chip ID: {detector.chip.id}")
print(f"Board ID: {detector.board.id}")

if detector.board.RASPBERRY_PI_3B_PLUS:
    print("This is a Raspberry Pi 3B+")
elif detector.board.BEAGLEBONE_BLACK:
    print("This is a BeagleBone Black")
elif detector.board.ORANGE_PI_PC:
    print("This is an Orange Pi PC")
elif detector.board.GENERIC_LINUX_PC:
    print("This is a generic Linux PC")
else:
    print("Platform not specifically identified by common board checks.")

# Example of checking if a specific chip is present
if detector.chip.ANY_BROADCOM_CHIP:
    print("Running on a Broadcom chip (like Raspberry Pi)")

# Example of forcing detection (for testing or specific setups)
# Uncomment and set an environment variable before running if needed
# os.environ['BLINKA_FORCEBOARD'] = 'GENERIC_LINUX_PC'
# os.environ['BLINKA_FORCECHIP'] = 'GENERIC_LINUX_CHIP'

view raw JSON →