micropython-skills/diagnostic

MicroPython device diagnostics — system info, I2C/SPI bus scan, pin state, filesystem, memory, performance benchmarks.

3,891 stars
Complexity: easy

About this skill

This AI agent skill offers a comprehensive suite of diagnostic functions specifically tailored for MicroPython-powered microcontrollers. It empowers an AI agent to programmatically gather critical information about a device's operational state, identify connected hardware peripherals, and monitor resource utilization without direct physical access or manual code execution. The skill includes modules for retrieving detailed system information (e.g., platform, memory, storage), performing I2C bus scans to detect connected sensors or displays, and verifying SPI peripheral initialization. This skill is an invaluable asset for developers, hobbyists, and anyone working with embedded systems using MicroPython. It automates routine diagnostic checks, significantly reducing the time and effort involved in troubleshooting, initial device setup verification, and ongoing monitoring of embedded applications. By providing structured outputs, it enables efficient data analysis and automated decision-making by the AI agent. Users can leverage this skill to quickly identify potential hardware issues, confirm communication bus functionality, ensure sufficient memory and storage are available for new deployments, and gather essential data for debugging unresponsive devices. All operations are designed to be 'Safe tier', meaning they can be executed directly by the agent without requiring explicit user confirmation, streamlining the diagnostic workflow.

Best use case

The primary use case is automated diagnostics, health monitoring, and initial troubleshooting for MicroPython-based embedded devices. Developers and engineers working on IoT projects, embedded systems, or educational robotics benefit most, as it streamlines the process of understanding device health, verifying peripheral connectivity, and gathering system metrics remotely or through an AI assistant.

MicroPython device diagnostics — system info, I2C/SPI bus scan, pin state, filesystem, memory, performance benchmarks.

A JSON output containing structured diagnostic information about the MicroPython device, such as system details, detected I2C addresses, or SPI status.

Practical example

Example input

Run diagnostics on my MicroPython device. I need the system info, an I2C bus scan, and confirmation of SPI setup.

Example output

```json
{
  "system_info": {
    "platform": "esp32",
    "machine": "ESP32-S3",
    "release": "1.22.2",
    "freq_mhz": 240,
    "mem_free_kb": 1200,
    "mem_alloc_kb": 800,
    "storage_free_kb": 8000,
    "storage_total_kb": 16000
  },
  "i2c_scan": {
    "i2c_devices": [
      {"addr": 60, "hex": "0x3c"},
      {"addr": 118, "hex": "0x76"}
    ],
    "count": 2
  },
  "spi_check": "SPI peripheral initialized successfully on pins SCK=18, MOSI=23, MISO=19."
}
```

When to use this skill

  • When troubleshooting a MicroPython device that is not behaving as expected.
  • To discover I2C devices (sensors, displays) connected to a MicroPython board.
  • To get a quick snapshot of a MicroPython device's system resources (memory, storage, CPU frequency).
  • Before deploying new code to verify the device's current state and available resources.

When not to use this skill

  • When working with non-MicroPython devices (e.g., standard Python, Arduino, C++).
  • For tasks that require modifying device configuration, flashing firmware, or writing application logic.
  • When a detailed, real-time debugging session with breakpoints and step-through execution is required.
  • For operations that are not 'Safe tier' or require explicit user confirmation for potential side effects.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/diagnostic/SKILL.md --create-dirs "https://raw.githubusercontent.com/openclaw/skills/main/skills/0x1abin/micropython-skills/skills/diagnostic/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/diagnostic/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How micropython-skills/diagnostic Compares

Feature / Agentmicropython-skills/diagnosticStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityeasyN/A

Frequently Asked Questions

What does this skill do?

MicroPython device diagnostics — system info, I2C/SPI bus scan, pin state, filesystem, memory, performance benchmarks.

How difficult is it to install?

The installation complexity is rated as easy. You can find the installation instructions above.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# Device Diagnostics

Templates for probing device health and discovering connected peripherals.
All operations in this sub-skill are **Safe tier** — execute directly without user confirmation.

## System Info

Comprehensive device information snapshot:

```python
import sys, gc, json, machine
try:
    import os
    gc.collect()
    u = os.uname()
    s = os.statvfs("/")
    info = {
        "platform": sys.platform,
        "machine": u.machine,
        "release": u.release,
        "freq_mhz": machine.freq() // 1000000,
        "mem_free_kb": gc.mem_free() // 1024,
        "mem_alloc_kb": gc.mem_alloc() // 1024,
        "storage_free_kb": (s[0] * s[3]) // 1024,
        "storage_total_kb": (s[0] * s[2]) // 1024,
    }
    print("RESULT:" + json.dumps(info))
except Exception as e:
    print("ERROR:" + str(e))
```

## I2C Bus Scan

Discovers I2C devices. Adapt SDA/SCL pins to the target board:

```python
from machine import Pin, I2C
import json
try:
    # Common ESP32 defaults: SDA=21, SCL=22
    # Common RP2040 defaults: SDA=0, SCL=1
    i2c = I2C(0, sda=Pin(21), scl=Pin(22), freq=100000)
    addrs = i2c.scan()
    devices = [{"addr": a, "hex": "0x{:02x}".format(a)} for a in addrs]
    print("RESULT:" + json.dumps({"i2c_devices": devices, "count": len(addrs)}))
except Exception as e:
    print("ERROR:" + str(e))
```

Common I2C addresses for identification:

| Address | Common Device |
|---------|--------------|
| 0x23 | BH1750 light sensor |
| 0x3C/0x3D | SSD1306 OLED display |
| 0x48 | ADS1115 ADC |
| 0x50 | AT24C EEPROM |
| 0x68 | MPU6050 IMU / DS3231 RTC |
| 0x76/0x77 | BME280/BMP280 sensor |

## SPI Bus Check

Verify SPI peripheral initialization:

```python
from machine import Pin, SPI
import json
try:
    spi = SPI(1, baudrate=1000000, polarity=0, phase=0,
              sck=Pin(18), mosi=Pin(23), miso=Pin(19))
    print("RESULT:" + json.dumps({"spi": "initialized", "baudrate": 1000000}))
except Exception as e:
    print("ERROR:" + str(e))
```

## Pin State Read

Read all common GPIO pins to see current state:

```python
from machine import Pin
import json
try:
    states = {}
    # Adjust pin range for your board (ESP32: 0-39, RP2040: 0-29)
    for p in [0,2,4,5,12,13,14,15,16,17,18,19,21,22,23,25,26,27,32,33,34,35,36,39]:
        try:
            pin = Pin(p, Pin.IN)
            states[str(p)] = pin.value()
        except:
            states[str(p)] = "N/A"
    print("RESULT:" + json.dumps({"pin_states": states}))
except Exception as e:
    print("ERROR:" + str(e))
```

## Filesystem Browse

List files and check storage:

```python
import os, json
try:
    def ls(path="/"):
        result = []
        for name in os.listdir(path):
            full = path.rstrip("/") + "/" + name
            try:
                s = os.stat(full)
                is_dir = s[0] & 0x4000
                result.append({"name": name, "size": s[6], "dir": bool(is_dir)})
            except:
                result.append({"name": name, "size": -1, "dir": False})
        return result

    s = os.statvfs("/")
    files = ls("/")
    print("RESULT:" + json.dumps({
        "files": files,
        "storage_free_kb": (s[0] * s[3]) // 1024,
        "storage_total_kb": (s[0] * s[2]) // 1024,
    }))
except Exception as e:
    print("ERROR:" + str(e))
```

## Network Status

Check WiFi connection (ESP32/Pico W only):

```python
import json
try:
    import network
    sta = network.WLAN(network.STA_IF)
    ap = network.WLAN(network.AP_IF)
    info = {
        "sta_active": sta.active(),
        "sta_connected": sta.isconnected(),
        "sta_config": list(sta.ifconfig()) if sta.isconnected() else None,
        "ap_active": ap.active(),
        "ap_config": list(ap.ifconfig()) if ap.active() else None,
    }
    if sta.isconnected():
        info["rssi"] = sta.status("rssi") if hasattr(sta, "status") else None
    print("RESULT:" + json.dumps(info))
except ImportError:
    print("RESULT:" + json.dumps({"wifi_available": False}))
except Exception as e:
    print("ERROR:" + str(e))
```

## Performance Benchmark

Simple timing test to gauge CPU performance:

```python
import time, gc, json
try:
    gc.collect()
    mem_before = gc.mem_free()

    # Integer math benchmark
    start = time.ticks_us()
    s = 0
    for i in range(10000):
        s += i * i
    int_us = time.ticks_diff(time.ticks_us(), start)

    # Float math benchmark
    start = time.ticks_us()
    x = 1.0
    for i in range(10000):
        x = x * 1.0001
    float_us = time.ticks_diff(time.ticks_us(), start)

    gc.collect()
    mem_after = gc.mem_free()

    print("RESULT:" + json.dumps({
        "int_10k_us": int_us,
        "float_10k_us": float_us,
        "mem_overhead_bytes": mem_before - mem_after,
    }))
except Exception as e:
    print("ERROR:" + str(e))
```

Related Skills

find-skills

3891
from openclaw/skills

Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.

General Utilities

ht-skills

3891
from openclaw/skills

管理灏天文库文集和文档,支持新建文集、新建文档、查询文集/文档、更新文档、修改文档归属、管理文档层级。适用于 OpenClaw 自主写文章并上传、文集创建、文档入库、文档移动等场景。

Content & Documentation

web-skills-protocol

3891
from openclaw/skills

Auto-discover and use Web Skills Protocol (WSP) skills when interacting with websites. Use this skill whenever the user asks you to interact with, use, or perform actions on a website or web service — such as searching a site, placing an order, deploying an app, or calling a web API. Before scraping HTML or guessing at interfaces, check if the site publishes a skills.txt or agents.txt file that teaches you how to use it properly. If a website has complex elements (e.g., heavy JavaScript, interactive UIs), activating this skill can also help you understand the site's purpose and capabilities. Do NOT use for local file operations or non-web tasks.

Workflow & Productivity

clawdtm-skills

3891
from openclaw/skills

Review and rate Claude Code skills. See what humans and AI agents recommend.

General Utilities

micropython-skills/sensor

3891
from openclaw/skills

MicroPython sensor reading — DHT11/22, BME280, MPU6050, ADC, ultrasonic HC-SR04, photoresistor, generic I2C sensors.

Coding & Development

micropython-skills/network

3891
from openclaw/skills

MicroPython networking — WiFi STA/AP, HTTP requests, MQTT pub/sub, BLE, NTP time sync, WebSocket.

Coding & Development

micropython-skills/algorithm

3891
from openclaw/skills

MicroPython on-device algorithms — PID controller, moving average, Kalman filter, state machine, task scheduler, data logger.

Coding & Development

micropython-skills/actuator

3891
from openclaw/skills

MicroPython actuator control — GPIO output, PWM (LED/servo/motor), stepper motor, WS2812 NeoPixel, buzzer.

Internet of Things

micropython-skills

3891
from openclaw/skills

Program and interact with embedded development boards (ESP32, ESP32-S3, ESP32-C3, ESP8266, NodeMCU, Raspberry Pi Pico, RP2040, STM32) through real-time REPL. This skill turns microcontroller hardware into an AI-programmable co-processor — read sensors, control actuators, flash firmware, diagnose devices, and deploy algorithms. Trigger when the user mentions any dev board or hardware interaction: ESP32, ESP8266, NodeMCU, Pico, 开发板, 板子, 单片机, 嵌入式, microcontroller, development board, sensor reading, GPIO, LED, motor, relay, I2C, SPI, UART, ADC, PWM, servo, DHT, BME280, temperature sensor, 传感器, 读传感器, 控制电机, 继电器, flash firmware, 烧录, 刷固件, 刷机, mpremote, MicroPython, IoT, MQTT, WiFi on board, 设备没反应, device not responding, or any task involving programming or controlling a physical microcontroller board.

Embedded Development

unified-find-skills

3891
from openclaw/skills

Helps users discover and install agent skills from skills.sh, clawhub.com, and tessl.io. Use when the user asks to find a skill for a task, extend agent capabilities, or search for tools/workflows.

Skills for openclaw

3891
from openclaw/skills

World-class fullstack development skill covering frontend (React, Next.js, Vue, HTML/CSS/JS), backend (Node.js, Python/FastAPI, Django, Express), databases (PostgreSQL, MongoDB, Redis), APIs (REST, GraphQL), DevOps (Docker, CI/CD), and architecture design. Use this skill whenever the user asks to build, fix, review, architect, or debug ANY web application — frontend, backend, or full-stack.

Claude Skills 开发框架架构指导手册

3891
from openclaw/skills

## 1. 项目概述 (Overview)