Under the Hood

How a $5 chip becomes an autonomous AI agent.

The Agentic Architecture

From user message to real-world action — every step on a single chip.

Input Channels

Telegram bot, USB serial console, or NATS messaging — all three feed into the same processing pipeline. The agent doesn't care how you talk to it.

The Agentic Loop

Up to 5 iterations per request. WireClaw reasons about the task, selects tools, executes them, observes results, and decides whether to continue or respond. True agent behavior, not scripted logic.

LLM Integration

Direct HTTPS calls to OpenRouter (or any OpenAI-compatible endpoint). Model is runtime-configurable via flash config. No proxy, no middleware — the ESP32 talks to the API directly.

Tool Execution

Seven built-in tools give the agent direct hardware control — LEDs, GPIO, sensors, filesystem, and device-to-device messaging via NATS.

The 7 Tools

Each tool maps to a real hardware or system capability.

led_set
LED

Control the onboard RGB LED — set any color, brightness, or turn it off. Visual feedback for every action.

gpio_write
GPIO

Drive output pins to control relays, motors, actuators, or any digital output.

gpio_read
GPIO

Read digital and analog values from sensors, switches, or voltage dividers.

device_info
System

Query free heap, uptime, WiFi signal strength, chip temperature, and more.

file_read
Flash FS

Read files from the onboard flash filesystem — configs, logs, persisted data.

file_write
Flash FS

Write data to flash — persist sensor readings, update configuration, save notes.

nats_publish
Messaging

Publish messages to NATS subjects for device-to-device communication and IoT mesh coordination.

LED Feedback System

The onboard LED tells you what the agent is doing at a glance.

Connecting
Thinking
Tool Loop
Success
Error

Memory That Survives Reboots

A 6-turn circular buffer stored on flash. Context persists across power cycles.

U:1
A:1
U:2
A:2
U:3
A:3

← oldest ··· newest → (write head)

Technical Specs

MCUESP32-C6 (RISC-V, 160 MHz, 512 KB SRAM)
FrameworkArduino + PlatformIO
LanguageC++ (Arduino-flavored)
RAM Usage~280 KB with active conversation
JSON ParsingStreaming token-by-token (ArduinoJson)
Buffer StrategyChunked HTTP reads, reused scratch buffers
Flash StorageLittleFS partition for config + conversation history
API ProtocolHTTPS with TLS 1.2, OpenAI-compatible chat completions
NATS SupportLightweight publish over TCP
ConfigurationJSON config on flash — WiFi, API key, model, system prompt
History Buffer6-turn circular buffer persisted to flash

Getting Started

Three steps from zero to a working AI agent.

1

Flash the Firmware

Clone the repo and upload with PlatformIO: pio run -t upload

2

Configure on Flash

Edit the JSON config with your WiFi credentials, API key, and preferred model.

3

Talk to It

Send natural language via Telegram, serial console, or NATS — the agent handles the rest.

Ready to Put AI on the Wire?

View on GitHub
← Back to Home