No description
Find a file
2026-03-26 12:56:54 +01:00
lib release: 0.2.0 2026-03-26 12:56:54 +01:00
src Use software serial in peripheral 2026-03-20 15:29:17 +01:00
.clang-format Initial commit (hw uart) 2026-03-20 14:55:41 +01:00
.gitignore Initial commit (hw uart) 2026-03-20 14:55:41 +01:00
.gitmodules feat: move library to submodule 2026-03-26 12:48:55 +01:00
avrsim.py Initial commit (hw uart) 2026-03-20 14:55:41 +01:00
avrsim_i2c.py feat: Allow tracing from nets 2026-03-20 16:21:58 +01:00
CLAUDE.md feat: move library to submodule 2026-03-26 12:48:55 +01:00
GEMINI.md Initial commit (hw uart) 2026-03-20 14:55:41 +01:00
platformio.ini Use software serial in peripheral 2026-03-20 15:29:17 +01:00
README.md Add README 2026-03-26 12:53:20 +01:00

SoftI2CPeripheral — Arduino Playground

Simulation test environment for the SoftI2CPeripheral library.

Two ATmega2560 firmware images (I2C controller + peripheral) run simultaneously inside pysimulavr, connected by simulated I2C and UART wires. This validates the library against a real software I2C master (SoftWire) without any hardware.

Prerequisites

  • PlatformIO (to build the firmware)
  • pysimulavr (pip install pysimulavr or build from source)

Build & run

pio run                    # build both environments
python avrsim_i2c.py       # run simulation (Ctrl+C to stop)

Common options:

python avrsim_i2c.py -n 5          # stop after 5 real-time seconds
python avrsim_i2c.py -i            # log every I2C SCL/SDA transition to stderr
python avrsim_i2c.py -i -n 0.3 2>&1 | head -80   # quick debug snapshot

Controller UART → stdout prefixed [CTRL] Peripheral UART → stderr prefixed [PERI]

Simulation wiring

Both devices are ATmega2560 running at 16 MHz. The simulated pins are connected via pysimulavr Net objects with explicit weak pull-ups.

Signal Arduino pin AVR port simulavr key
SCL 21 PD0 "D0"
SDA 20 PD1 "D1"
UART TX 1 PE1 "E1"

Project layout

src/controller/main.cpp   — I2C master using SoftWire
src/peripheral/main.cpp   — I2C peripheral using SoftI2CPeripheral
lib/SoftI2CPeripheral/    — library submodule
avrsim_i2c.py             — dual-device simulation harness
platformio.ini            — two PlatformIO environments