Skip to content

Fix board compatibility for XIAO RP2040 and other MicroPython platforms#3

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/fix-import-error-xiao-rp2040
Draft

Fix board compatibility for XIAO RP2040 and other MicroPython platforms#3
Copilot wants to merge 4 commits intomainfrom
copilot/fix-import-error-xiao-rp2040

Conversation

Copy link
Copy Markdown

Copilot AI commented Jan 14, 2026

Users on XIAO RP2040 were encountering ImportError: no module named 'machine' because the codebase was written specifically for Pycom boards with non-standard I2C initialization syntax.

Changes

Library compatibility (lib/lidar.py)

  • Added fallback imports for utime/time and relative/absolute constants
  • Library core is now platform-agnostic

Board-specific examples

  • example_rp2040.py - XIAO RP2040, Raspberry Pi Pico with pin mappings
  • example_esp32.py - ESP32 with default GPIO21/22
  • example_pycom.py - Original Pycom code preserved

Updated main.py

  • Uses standard MicroPython I2C initialization instead of Pycom-specific syntax:
# Before (Pycom only)
i2c = I2C(0, mode=I2C.MASTER, baudrate=400000, pins=('P7', 'P8'))

# After (standard MicroPython)
i2c = I2C(0, scl=Pin(SCL_PIN), sda=Pin(SDA_PIN), freq=400000)

Documentation

  • Added MicroPython firmware installation instructions
  • Board-specific wiring diagrams and troubleshooting section
  • Clear guidance on choosing the appropriate example file
Original prompt

This section details on the original issue you should resolve

<issue_title>Issue regarding "import"</issue_title>
<issue_description>I am having an issue with a XIAO RP2040 I get an error which says ImportError: no module named 'machine', and if that is commented then another import error occurs. This is my first time working with this sensor and microcontroller and I will show screenshots of what I have. Thank you.
Error_Micropython
</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 14, 2026 18:06
Co-authored-by: davmoz <26165830+davmoz@users.noreply.github.com>
Co-authored-by: davmoz <26165830+davmoz@users.noreply.github.com>
Co-authored-by: davmoz <26165830+davmoz@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix ImportError related to machine module in XIAO RP2040 Fix board compatibility for XIAO RP2040 and other MicroPython platforms Jan 14, 2026
Copilot AI requested a review from davmoz January 14, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue regarding "import"

2 participants