Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions tests/scenarios/board_i2c_scan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
type: board
name: "board_i2c_scan"

tests:
- name: "I2C bus scan finds expected devices"
action: hardware_script
script: |
from machine import I2C, Pin
# Release MCP23009E from reset so it responds to scan
rst = Pin("RST_EXPANDER", Pin.OUT)
rst.on()
from time import sleep_ms
sleep_ms(10)
i2c = I2C(1)
found = i2c.scan()
# Expected I2C addresses on STeaMi board (7-bit):
# 0x1E=LIS2MDL, 0x20=MCP23009E, 0x29=VL53L1X, 0x39=APDS9960
# 0x3B=STM32F103CB, 0x55=BQ27441, 0x5D=WSEN-PADS
# 0x5F=HTS221/WSEN-HIDS, 0x6B=ISM330DL
expected = [0x1E, 0x20, 0x29, 0x39, 0x3B, 0x55, 0x5D, 0x5F, 0x6B]
missing = sorted([hex(a) for a in expected if a not in found])
Comment thread
nedseb marked this conversation as resolved.
result = missing
expect: []
mode: [hardware]

- name: "No unexpected I2C devices"
action: hardware_script
script: |
from machine import I2C, Pin
rst = Pin("RST_EXPANDER", Pin.OUT)
rst.on()
from time import sleep_ms
sleep_ms(10)
i2c = I2C(1)
found = i2c.scan()
known = [0x1E, 0x20, 0x29, 0x39, 0x3B, 0x55, 0x5D, 0x5F, 0x6B]
unexpected = sorted([hex(a) for a in found if a not in known])
result = unexpected
expect: []
mode: [hardware]

# --- WHO_AM_I / Device ID checks ---
# Each test reads the identification register of one component.

Comment thread
nedseb marked this conversation as resolved.
- name: "LIS2MDL WHO_AM_I (0x1E)"
action: hardware_script
script: |
from machine import I2C
i2c = I2C(1)
result = i2c.readfrom_mem(0x1E, 0x4F, 1)[0]
expect: 0x40
mode: [hardware]

- name: "MCP23009E IODIR default (0x20)"
action: hardware_script
script: |
from machine import I2C, Pin
rst = Pin("RST_EXPANDER", Pin.OUT)
rst.on()
from time import sleep_ms
sleep_ms(10)
i2c = I2C(1)
# IODIR register default value after reset = 0xFF (all inputs)
result = i2c.readfrom_mem(0x20, 0x00, 1)[0]
expect: 0xFF
mode: [hardware]

- name: "VL53L1X model ID (0x29)"
action: hardware_script
script: |
from machine import I2C
i2c = I2C(1)
data = i2c.readfrom_mem(0x29, 0x010F, 2, addrsize=16)
result = (data[0] << 8) | data[1]
expect: 0xEACC
mode: [hardware]

- name: "APDS9960 device ID (0x39)"
action: hardware_script
script: |
from machine import I2C
i2c = I2C(1)
result = i2c.readfrom_mem(0x39, 0x92, 1)[0]
expect: 0xAB
mode: [hardware]

- name: "WSEN-PADS device ID (0x5D)"
action: hardware_script
script: |
from machine import I2C
i2c = I2C(1)
result = i2c.readfrom_mem(0x5D, 0x0F, 1)[0]
expect: 0xB3
mode: [hardware]

- name: "HTS221/WSEN-HIDS device ID (0x5F)"
action: hardware_script
script: |
from machine import I2C
i2c = I2C(1)
result = i2c.readfrom_mem(0x5F, 0x0F, 1)[0]
expect: 0xBC
mode: [hardware]

- name: "ISM330DL WHO_AM_I (0x6B)"
action: hardware_script
script: |
from machine import I2C
i2c = I2C(1)
result = i2c.readfrom_mem(0x6B, 0x0F, 1)[0]
expect: 0x6A
mode: [hardware]