{"id":8806,"library":"adafruit-platformdetect","title":"Adafruit PlatformDetect","description":"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.","status":"active","version":"3.88.0","language":"en","source_language":"en","source_url":"https://github.com/adafruit/Adafruit_Python_PlatformDetect","tags":["hardware","platform","embedded","raspberrypi","circuitpython","adafruit"],"install":[{"cmd":"pip install adafruit-platformdetect","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Requires Python 3.7 or higher.","package":"Python","optional":false}],"imports":[{"symbol":"Detector","correct":"from adafruit_platformdetect import Detector"}],"quickstart":{"code":"import os\nfrom adafruit_platformdetect import Detector\n\ndetector = Detector()\n\nprint(f\"Chip ID: {detector.chip.id}\")\nprint(f\"Board ID: {detector.board.id}\")\n\nif detector.board.RASPBERRY_PI_3B_PLUS:\n    print(\"This is a Raspberry Pi 3B+\")\nelif detector.board.BEAGLEBONE_BLACK:\n    print(\"This is a BeagleBone Black\")\nelif detector.board.ORANGE_PI_PC:\n    print(\"This is an Orange Pi PC\")\nelif detector.board.GENERIC_LINUX_PC:\n    print(\"This is a generic Linux PC\")\nelse:\n    print(\"Platform not specifically identified by common board checks.\")\n\n# Example of checking if a specific chip is present\nif detector.chip.ANY_BROADCOM_CHIP:\n    print(\"Running on a Broadcom chip (like Raspberry Pi)\")\n\n# Example of forcing detection (for testing or specific setups)\n# Uncomment and set an environment variable before running if needed\n# os.environ['BLINKA_FORCEBOARD'] = 'GENERIC_LINUX_PC'\n# os.environ['BLINKA_FORCECHIP'] = 'GENERIC_LINUX_CHIP'\n","lang":"python","description":"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."},"warnings":[{"fix":"Be aware of these environment variables if detection results are unexpected. Unset them if not intentionally used, or consult `adafruit_platformdetect/chip.py` and `adafruit_platformdetect/board.py` for their effects.","message":"Platform detection can be overridden by environment variables like `BLINKA_FORCEBOARD` and `BLINKA_FORCECHIP`. This is primarily for testing or specific hardware setups (e.g., FT232H, SPIDriver). If these are set, they will bypass standard hardware detection.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always ensure you have the latest version installed: `pip install --upgrade adafruit-platformdetect adafruit-blinka`.","message":"Running on new, unsupported hardware with an older version of adafruit-platformdetect can lead to `NotImplementedError` or 'Board not supported' messages.","severity":"gotcha","affected_versions":"All versions prior to current board support"},{"fix":"Always install either for the current user (`pip install adafruit-platformdetect`) or within an activated virtual environment. Avoid `sudo pip install` unless absolutely necessary for system-wide installations and understand the implications.","message":"Incorrect installation methods (e.g., using `sudo pip install` then running as a normal user, or installing in a virtual environment and not activating it) can lead to `ModuleNotFoundError`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Upgrade to the latest version of adafruit-platformdetect and adafruit-blinka: `pip install --upgrade adafruit-platformdetect adafruit-blinka`. If the problem persists, open a 'New Board Request' issue on the Adafruit Blinka GitHub repository.","cause":"The Adafruit-PlatformDetect library is an older version that does not include detection logic for your specific board or microcontroller, or the platform is genuinely unsupported.","error":"NotImplementedError: Adafruit-PlatformDetect version X.Y.Z was unable to identify the board and/or microcontroller running the [PLATFORM] platform."},{"fix":"Ensure the library is installed in your active Python environment: `pip install adafruit-platformdetect`. If using a virtual environment, make sure it is activated before installation and execution. If installed system-wide with `sudo`, ensure you run your script with `sudo` as well (though generally discouraged).","cause":"The `adafruit-platformdetect` package is not installed in the Python environment where the script is being executed, or it was installed incorrectly (e.g., using `sudo pip` and running as a different user).","error":"ModuleNotFoundError: No module named 'adafruit_platformdetect'"},{"fix":"If you are not using an FT232H, unset the `BLINKA_FT232H` environment variable. If you intend to use an FT232H, ensure it is properly connected and that `pyftdi` is installed (`pip install pyftdi`).","cause":"The `BLINKA_FT232H` environment variable is set, forcing Adafruit-PlatformDetect to look for an FT232H device, but no such device is connected or detected by `pyftdi`.","error":"RuntimeError: BLINKA_FT232H environment variable set, but no FT232H device found"}]}