Skip to content

eoinjordan/arduino-edgeai-opencode-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arduino & Edge AI — Offline Coding Starter

An offline-first agentic coding environment for students building Arduino and Edge AI projects. No API keys. No internet. Everything runs locally on your machine.

Powered by OpenCode, llama.cpp, and two fine-tuned Qwen2.5-Coder-0.5B models:

Model What it knows
EdgeAI Edge Impulse docs, Edge AI workflow, run_classifier() deployment
Arduino Arduino C/C++, sketches, libraries, UNO R4 WiFi, Nano 33 BLE Sense

Runs on the same hardware as pi-openclaw-mcp-stack — Pi UNO Q (CPU) and Jetson 6490 (CUDA). scripts/quickstart.sh and scripts/start-server.sh handle platform detection automatically.


opencode

Quickstart

git clone https://github.com/eoinjordan/arduino-edgeai-opencode-starter.git
cd arduino-edgeai-opencode-starter
chmod +x scripts/*.sh
bash scripts/quickstart.sh          # auto-detects Pi / Jetson / CPU
# or force: bash scripts/quickstart.sh jetson|pi|cpu

Then:

./scripts/start-server.sh edgeai    # Terminal 1 — or: arduino
cd opencode && opencode             # Terminal 2

For detailed Pi UNO Q and Jetson, QC 6490 setup see docs/pi-unoq-setup.md and docs/jetson-setup.md (gitignored — see pi-openclaw-mcp-stack for the full hardware stack).


Prerequisites

  • Pi / Jetson: bash scripts/quickstart.sh installs everything
  • macOS: brew install llama.cpp + npm install -g opencode-ai
  • Windows: WSL2 then follow the Linux path

Quick Start (manual)

1. Download the models

chmod +x scripts/*.sh
./scripts/download-models.sh

Both GGUFs (~398 MB each) are saved to ~/.

2. Start the model server

Pick the model for your task — only one runs at a time:

# For Edge Impulse / Edge AI questions:
./scripts/start-server.sh edgeai

# For Arduino code generation:
./scripts/start-server.sh arduino

The server starts at http://127.0.0.1:8081/v1. Leave this terminal open.

Platform detection is automatic (Jetson uses GPU, Pi caps threads). Override: LLAMA_N_GPU_LAYERS=32 or LLAMA_THREADS=6.

3. Open OpenCode

In a new terminal, from the opencode/ directory:

cd opencode && opencode

OpenCode reads opencode.json from the current directory and routes all AI calls to your local server.

4. Pick your agent

Inside OpenCode, press / and type agent to switch agents:

  • arduino — Arduino code generation, UNO R4 WiFi, Arduino App Studio / Arduino IDE
  • edgeai — Edge Impulse workflow, on-device ML, Jetson TensorRT, Pi Linux SDK

Tip: Switch the server and the agent together. Run start-server.sh arduino then use the arduino agent in OpenCode, or start-server.sh edgeai with the edgeai agent.


Arduino IDE integration — arduino-mcp

arduino-mcp runs alongside this repo and gives OpenCode (and any MCP client) tools to validate, read, write, and build sketches directly in Arduino IDE 2.0 format.

1. Start arduino-mcp

# Global install
npm install -g arduino-claude-mcp
arduino-claude-mcp          # REST server on port 3080

# or Docker (Pi/UNO Q)
docker run --rm --network host \
  -e ARDUINO_FQBN=arduino:renesas_uno:unor4wifi \
  -v ~/Arduino:/workspace \
  eoinedge/arduino-mcp:latest

2. Add to OpenCode MCP config

Create or edit opencode/mcp.json:

{
  "mcpServers": {
    "arduino-mcp": {
      "command": "node",
      "args": ["/absolute/path/to/arduino-mcp/build/mcp.js"]
    }
  }
}

3. Use in the arduino agent

With arduino-mcp connected, the arduino agent can call tools directly:

What to ask Tool used
"Validate my sketch" POST /validate
"Read the current sketch" POST /read_source
"Update the sketch with this code" POST /write_source
"Build for UNO R4 WiFi" POST /build (needs arduino-cli + ARDUINO_FQBN)

Example prompts inside OpenCode with the arduino agent:

  • "Read my sketch and add a blinking LED on pin 13"
  • "Validate the project then build it for arduino:renesas_uno:unor4wifi"
  • "Append a Serial debug line and recompile"

Switching models in OpenCode

Type /models inside OpenCode to see the available models:

edgeai/qwen-edgeai   — Qwen EdgeAI (local)
arduino/qwen-arduino — Qwen Arduino (local)

Select whichever matches the model you started with start-server.sh.


Build llama.cpp

bash scripts/quickstart.sh handles this for Pi and Jetson. Manual:

# macOS
brew install llama.cpp

# Linux CPU
git clone https://github.com/ggml-org/llama.cpp ~/llama.cpp
cmake -S ~/llama.cpp -B ~/llama.cpp/build -DLLAMA_BUILD_SERVER=ON
cmake --build ~/llama.cpp/build --config Release -j$(nproc)

For CUDA (Jetson) see docs/jetson-setup.md locally or pi-openclaw-mcp-stack/docs/hardware-acceleration-host-setup.md.


Project structure

arduino-edgeai-opencode-starter/
├── opencode/
│   └── opencode.json          # OpenCode provider config (both models)
├── scripts/
│   ├── quickstart.sh          # One-shot setup: Pi, Jetson, or CPU
│   ├── download-models.sh     # Download both GGUFs to ~/
│   └── start-server.sh        # Start llama-server (auto platform detect)
├── docs/                      # gitignored — platform setup notes for pi-openclaw-mcp-stack
│   ├── pi-unoq-setup.md
│   └── jetson-setup.md
└── .opencode/
    └── agents/
        ├── arduino.md         # Arduino agent (UNO R4, App Studio, Edge AI)
        └── edgeai.md          # Edge AI agent (EI, Pi SDK, Jetson TensorRT)

How it works

Student prompt
    │
    ▼
OpenCode (TUI)
    │  reads opencode/opencode.json
    ▼
llama-server (localhost:8081)
    │  CPU (Pi) or GPU (Jetson) — fine-tuned Qwen model
    ▼
Response streamed back to OpenCode

No data ever leaves your machine.


Models

Both models are fine-tuned from Qwen/Qwen2.5-Coder-0.5B-Instruct using LoRA adapters and quantized to Q4_K_M.

HuggingFace repo Training data
eoinedge/edgeai-docs-qwen2.5-coder-0.5b-lora 1,794 Edge Impulse documentation files
eoinedge/arduino-qwen0.5-lora Arduino reference and sketch examples

Note: The 0.5B models are fast on CPU and great for focused questions. For complex multi-step tasks, consider a larger model (3B+).


Related repos

Repo What it adds
pi-openclaw-mcp-stack Full Pi stack with Arduino MCP, Edge Impulse MCP, Telegram bot, gateway
arduino-mcp Arduino MCP server — validate / read / write / build sketches from OpenCode or any MCP client
mindstorms-robot-creator LEGO MINDSTORMS code generator and MCP server

Troubleshooting

llama-server not found — Run bash scripts/quickstart.sh or brew install llama.cpp (macOS).

model not found at ~/qwen-*.gguf — Run ./scripts/download-models.sh first.

OpenCode shows no models — Run opencode from the opencode/ directory, not the repo root.

Slow / GPU issues on Pi or Jetson — See docs/pi-unoq-setup.md or docs/jetson-setup.md (local, gitignored), or pi-openclaw-mcp-stack for hardware-specific guidance.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages