Artificial Intelligence Embedded Systems Jun 10, 2026 1 min de lecture

Stop Building Dumb IoT Devices! zbot Adds Real AI Brains

B
Bright Coding
Auteur
Stop Building Dumb IoT Devices! zbot Adds Real AI Brains
Advertisement

Stop Building Dumb IoT Devices! zbot Adds Real AI Brains

What if your microcontroller could actually think? Not just execute pre-programmed if-then logic, but reason through problems, remember conversations, and decide which hardware to control—all without a cloud connection holding its hand?

Here's the painful truth: most "smart" devices are embarrassingly stupid. They slavishly phone home to AWS↗ Bright Coding Blog, execute rigid command chains, and collapse the moment the internet hiccups. Developers pour weeks into brittle firmware only to watch users abandon devices that can't adapt. The gap between "connected" and "intelligent" has never felt wider.

But what if you could embed a genuine AI agent directly onto a $50 development board? One that runs a ReAct↗ Bright Coding Blog reasoning loop, talks to any OpenAI-compatible LLM, and controls GPIO, system monitoring, and custom hardware through natural language?

Meet zbot 🦞—the open-source embedded AI agent that's making traditional IoT firmware look like a relic from 2010. Built on Zephyr RTOS, zbot transforms Nordic's nRF7002-DK and even Linux simulation targets into autonomous, conversationally intelligent devices. No cloud dependency for decision-making. No rigid command parsing. Just pure, embedded AI power.

This isn't a prototype. This isn't vaporware. This is production-ready code you can flash today. And it's about to change how you think about embedded development forever.


What is zbot?

zbot is an open-source embedded AI agent created by developer LingaoM and released under the Apache-2.0 license. It runs on Zephyr RTOS—the Linux Foundation's scalable real-time operating system—and implements a complete ReAct (Reason + Act) loop that connects to any OpenAI-compatible LLM API.

The project's mascot, a lobster (🦞), hints at something unusual: this isn't your typical embedded stack. zbot occupies a unique position at the intersection of three explosive technology trends: edge AI, real-time operating systems, and large language models. While competitors chase cloud-heavy architectures or resource-hungry Linux boards, zbot squeezes genuine intelligence onto resource-constrained microcontrollers.

Why it's trending now: The embedded world is experiencing an identity crisis. MCUs have grown powerful enough (dual-core Cortex-M33 with WiFi, in the nRF5340's case) to run sophisticated networking stacks, yet most firmware remains stubbornly procedural. zbot answers the question nobody was asking loudly enough: "What if the LLM revolution came to microcontrollers?"

The project supports nRF7002-DK (nRF5340 + nRF7002 WiFi) for physical hardware deployment and native_sim for Linux-hosted simulation. This dual-target approach means you can develop and test AI behaviors on your laptop before touching hardware—a game-changer for iterative AI agent development.

Zephyr RTOS provides the foundation: a safety-certified, vendor-neutral RTOS with robust networking, TLS support, and a growing ecosystem. By building on Zephyr rather than vendor-specific SDKs, zbot achieves genuine hardware portability and access to enterprise-grade features like memory protection and secure boot.


Key Features That Make zbot Insane

ReAct Loop on Bare Metal

The crown jewel. zbot implements a full Reason + Act loop with 10 iterations maximum per turn—the same architecture powering advanced AI agents in cloud environments, now running in kilobytes of RAM. The agent receives user input, constructs a messages JSON payload, queries the LLM, and executes returned tool calls. When the LLM returns finish_reason: tool_call, zbot dispatches to tools_execute() which routes through skill_run(). When finish_reason: stop fires, the answer returns to the user. Simple, elegant, devastatingly effective.

Dual-Tool Architecture

zbot exposes exactly two LLM-visible tools: tool_exec (dispatches to any registered skill) and read_skill (fetches full Markdown↗ Smart Converter documentation on demand). This minimal surface area is deliberate—it's the secret to fitting complex agent behavior into tight memory budgets. Skills self-register at boot via SYS_INIT, making the system dynamically extensible without modifying core agent code.

Persistent Conversation Memory

A 10-node static pool using k_mem_slab backed by sys_slist_t maintains conversation history. When full, zbot compresses oldest nodes via LLM summarization, freeing slabs back to the pool. The rolling summary persists to NVS (Non-Volatile Storage) and reinjects on next boot. This isn't just chat history—it's compressed, persistent context across power cycles on a microcontroller.

Multi-Platform LLM Support

Out-of-box compatibility with OpenRouter (free tier available), OpenAI, DeepSeek, and local models via Ollama. The HTTPS client handles TLS with embedded CA certificates. Switch providers through shell commands without reflashing—configuration persists in NVS.

Telegram Bot Integration

A dedicated long-poll thread turns your device into a Telegram bot. Users chat naturally; zbot reasons, acts, and responds. This isn't a webhook-requiring cloud function—it's direct, embedded bot hosting with persistent connection management.

Self-Documenting Skills

Skills include optional Markdown documentation embedded at build time via Zephyr's generate_inc_file_for_target. The LLM fetches full docs on demand through read_skill, enabling zero-shot skill discovery without bloating every request context.


Use Cases: Where zbot Absolutely Dominates

1. Intelligent Industrial Sensor Nodes

Traditional SCADA-adjacent devices report raw data and wait for cloud analytics. zbot-equipped sensors reason about anomalies locally: "Temperature spike detected. Checking adjacent sensors... Ventilation fan 3 appears stuck. Shall I trigger maintenance alert and log diagnostic data?" The ReAct loop enables multi-step diagnostic workflows without cloud round-trips.

2. Adaptive Home Automation Controllers

Forget rigid "if motion then light" rules. A zbot-powered switch understands: "It's 11 PM, you've been reading. I'll dim the lights gradually over 20 minutes and ensure the door lock engages when you head upstairs." Contextual reasoning, memory of preferences, and natural language interaction—on a sub-$50 board.

3. Field Service Diagnostic Tools

Technicians carry zbot-enabled tablets or handhelds. "This motor's drawing 15% over nominal with vibration pattern matching bearing failure in my training. Recommended action: schedule replacement within 48 hours. Shall I order part #MTR-2847-B from inventory?" Skills interface with I2C/SPI sensors; the LLM interprets patterns.

4. Educational Robotics Platforms

Students program robots through conversation: "Teach me PID control by having the robot follow this line, explaining each parameter adjustment." The robot executes system skill queries for telemetry, gpio skills for motor control, and the LLM provides contextual pedagogy—no IDE required for initial exploration.

5. Remote Environmental Monitoring Stations

Solar-powered stations in cellular/WiFi range maintain persistent operational awareness. "Rainfall exceeded threshold; I'm extending soil moisture sampling interval to preserve battery and will report trend analysis at 18:00 UTC." Memory survives deep-sleep cycles via NVS summary restoration.


Step-by-Step Installation & Setup Guide

Prerequisites

Install Zephyr's development environment per the official guide: https://docs.zephyrproject.org/latest/develop/getting_started/index.html

Ensure west, cmake, and your board's toolchain (ARM GCC for nRF5340, host compiler for native_sim) are functional.

Building for Physical Hardware (nRF7002-DK)

# Clone and enter the repository
git clone https://github.com/LingaoM/zbot.git
cd zbot

# Build for nRF7002-DK (nRF5340 application core with nRF7002 WiFi)
west build -b nrf7002dk/nrf5340/cpuapp zbot

# Flash to connected board
west flash

The sysbuild/ configuration handles multi-image builds for the nRF5340's network core automatically.

Building for Simulation (native_sim)

# Build for Linux host simulation—no hardware required
west build -b native_sim zbot

# Run the simulated firmware; shell appears in this terminal
./build/zephyr/zephyr.exe

Critical: native_sim uses the host Linux network stack. No WiFi configuration needed—your existing internet connection serves the LLM client.

Serial Connection

Physical board:

minicom -D /dev/ttyACM0 -b 115200
# Adjust /dev/ttyACM* based on your system's enumeration

native_sim: Shell is inline with the zephyr.exe terminal.

WiFi Configuration (nRF7002-DK only)

uart:~$ zbot wifi connect MyNetwork MyPassword

Credentials persist to flash via Zephyr's wifi_credentials subsystem and auto-connect on reboot.

API Key Setup

Default: OpenRouter (recommended free tier)

uart:~$ zbot key sk-or-v1-...

Get your key at: https://openrouter.ai/settings/keys

Provider Configuration Examples

OpenAI:

Advertisement
uart:~$ zbot host api.openai.com
uart:~$ zbot path /v1/chat/completions
uart:~$ zbot model gpt-4o-mini
uart:~$ zbot key sk-...

DeepSeek:

uart:~$ zbot host api.deepseek.com
uart:~$ zbot path /chat/completions
uart:~$ zbot model deepseek-chat
uart:~$ zbot key sk-...

Local Ollama (no TLS):

uart:~$ zbot host 192.168.1.100
uart:~$ zbot tls off 11434

Telegram Bot Setup (Optional)

  1. Message @BotFather on Telegram to create a bot
  2. Copy the provided token
  3. Configure zbot:
uart:~$ zbot telegram token 1234567890:AAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
uart:~$ zbot telegram start

Token persists to NVS. Auto-starts on reboot if configured.


REAL Code Examples from zbot

Example 1: The Core ReAct Loop Architecture

This ASCII architecture from zbot's README reveals the agent's decision flow. Study it carefully—this is how embedded AI reasoning actually works:

user input
    │
    ▼
build messages JSON  ←────────────────────────────────────────────────┐
    │                                                                 │
    ▼                                                                 │
LLM API call (tool_exec + read_skill exposed)                         │
    │                                                                 │
    ├── finish_reason: tool_call ──► tools_execute(name, args)        │
    │                                    └─ skill_run(name, args) ───►│
    │
    └── finish_reason: stop ──► return answer to user
                                        │
                                        ▼
                                request summary ──► NVS

What's happening here: The loop starts with user input, constructs a JSON messages array (including system prompt, conversation history, and available tools), then fires an HTTPS POST to the LLM endpoint. The LLM returns either a tool_call—triggering hardware action through skill_run()—or a stop signal, yielding the final response. After stopping, zbot requests conversation compression and writes the summary to NVS. Max 10 iterations prevents runaway loops. This is genuine agentic behavior, not simple command parsing.

Example 2: Adding a Custom Skill

This is the complete boilerplate for extending zbot with new capabilities. The SYS_INIT macro auto-registers at boot; generate_inc_file_for_target embeds documentation:

#include "skill.h"

// Embedded Markdown documentation, converted to C array at build time
static const char my_skill_md[] = {
#include "skills/<name>/SKILL.md.inc"
    0x00  // Null terminator for safe string operations
};

// Handler called when LLM dispatches to this skill via tool_exec
static int handler(const char *arg, char *result, size_t res_len)
{
    // arg: JSON string with arguments from LLM
    // result: output buffer for JSON response
    // res_len: maximum response length
    snprintf(result, res_len, "{\"status\":\"ok\"}");
    return 0;  // Return 0 for success, non-zero for errors
}

// Self-registration macro: name, ID, description, docs, handler
SKILL_DEFINE(my_skill, "my_skill", "One-line description",
             my_skill_md, sizeof(my_skill_md) - 1, handler);

Critical insight: The SKILL_DEFINE macro handles registration automatically through Zephyr's SYS_INIT infrastructure. No manual registration in main.c. The generate_inc_file_for_target CMake function converts SKILL.md to a C header inclusion at build time, making documentation available to the read_skill tool without filesystem access at runtime.

Example 3: GPIO Skill in Action

Here's how zbot's built-in GPIO skill responds to natural language, with the actual LLM tool calls shown:

zbot:~$ Turn on LED0
# LLM reasons: user wants GPIO output, LED0, high state
# LLM calls: tool_exec({"tool":"gpio","args":{"action":"write","pin":"led0","value":1}})
# skill_run() dispatches to gpio handler → executes GPIO write
# Response: "Done — LED0 is now on."

zbot:~$ Blink 5 times
# LLM reasons: user wants visual indication, repeated pattern
# LLM calls: tool_exec({"tool":"gpio","args":{"action":"blink","count":5}})
# gpio handler: blinks LED0 at 300ms intervals, 5 times

Shell direct execution (bypassing LLM for testing):

uart:~$ zbot skill run gpio '{"action":"blink","count":3}'
uart:~$ zbot skill run system '{"action":"status"}'

Example 4: Conversation Memory Implementation

This reveals how zbot solves the "amnesia problem" on memory-constrained devices:

History: 10-node static pool (k_mem_slab) + sys_slist_t

On memory_add_turn() when pool full:
  1. COMPRESS: oldest nodes → LLM summary → free slabs
  2. EVICT (fallback): oldest node recycled directly

After compression:
  → rolling summary written to NVS (key: "zbot/summary")
  → injected as prior context on next boot

The genius: Static pool eliminates malloc fragmentation risks in long-running devices. Linked list ordering (oldest→newest) enables efficient eviction. LLM-powered compression preserves semantic content while freeing physical storage. NVS persistence means your device "remembers" across weeks of deep-sleep operation.


Advanced Usage & Best Practices

Prompt Engineering via AGENT.md.in

Edit src/AGENT.md.in to customize system behavior without code changes. This file embeds at build time via generate_inc_file_for_target. Craft prompts that constrain the LLM to safe hardware operations: specify valid pin ranges, prohibit certain actions, or inject personality. Rebuild and reflash to deploy.

Memory Pool Tuning

The default 10-node pool balances history depth against RAM usage. For complex multi-turn reasoning, increase CONFIG_ZBOT_MEMORY_POOL_SIZE in prj.conf. For severely constrained deployments, reduce nodes and rely more heavily on NVS summary reinjection.

TLS Certificate Management

Production deployments must replace the bundled OpenRouter CA certificate in src/certs/openrouter/ with your provider's chain. For internal Ollama instances, zbot tls off disables TLS entirely—acceptable only on trusted networks.

Skill Documentation Strategy

Write SKILL.md files as if instructing a junior developer: explicit parameter types, valid ranges, error conditions. The LLM reads these on demand via read_skill; better docs mean more reliable tool use. Include example JSON arguments in Markdown code blocks.

Conversation Privacy

The zbot wipe command clears all RAM history and NVS summary. For GDPR-sensitive applications, implement automatic wipe triggers (idle timeout, explicit user command) and warn users that NVS summary stores conversation content as plaintext.


Comparison with Alternatives

Feature zbot MicroPython + urequests AWS IoT + Lambda Edge Impulse
LLM Reasoning ✅ Native ReAct loop ❌ Manual HTTP only ❌ Cloud-dependent ❌ Not supported
RTOS Foundation ✅ Zephyr (safety-certifiable) ❌ Bare-metal or limited N/A Varies
Persistent Memory ✅ NVS compression ❌ Manual file/flash ✅ Cloud persistence ❌ Limited
Natural Language HW Control ✅ Built-in ❌ Requires custom parser ❌ Requires Alexa integration ❌ Not applicable
Offline Capability ⚠️ LLM needs network ❌ LLM needs network ❌ Fully cloud-dependent ✅ Fully offline
Skill Extensibility ✅ SYS_INIT auto-register ⚠️ Manual module import ❌ Lambda redeployment ✅ Model retraining
Target Cost ~$50 (nRF7002-DK) ~$5 (ESP32) $5+ plus cloud fees $5-50 varies
Open Source ✅ Apache-2.0 ✅ MIT ❌ Proprietary service ✅ Partial

Verdict: zbot uniquely combines genuine AI agent architecture with embedded-grade resource management. Choose it when you need local reasoning, persistent operational context, and natural language hardware control—not just cloud connectivity or static ML inference.


FAQ

Q: Can zbot run completely offline without any internet connection? A: The LLM client requires network access to an OpenAI-compatible API endpoint. However, you can run Ollama locally on your network and point zbot to it with zbot tls off. Full offline operation requires local LLM hosting infrastructure.

Q: How much RAM does zbot require? A: The conversation memory uses a configurable static pool (default 10 nodes). The nRF7002-DK's 512KB SRAM is sufficient for comfortable operation. For tighter targets, reduce pool size and rely on NVS summary compression.

Q: Is my API key secure in NVS flash? A: NVS stores keys as plaintext. This is acceptable for development but production deployments should implement Zephyr's Trusted Firmware-M integration or external secure elements. Use zbot key_delete to remove keys when not needed.

Q: Can I use zbot with custom hardware beyond the nRF7002-DK? A: Yes—any Zephyr-supported board with networking (WiFi, Ethernet, or cellular) can run zbot. You'll need to create a boards/<your_board>.conf configuration and potentially adapt skill implementations for your specific GPIO/peripheral layout.

Q: How do I debug the ReAct loop when the LLM makes wrong tool calls? A: Use zbot history to inspect the full messages JSON sent to the LLM. Verify your SKILL.md documentation clearly describes parameters. Enable Zephyr's CONFIG_NET_LOG and CONFIG_HTTP_CLIENT_LOG for HTTPS-level debugging.

Q: What's the latency for a typical interaction? A: Network-dependent. With OpenRouter, expect 2-5 seconds for simple queries including tool execution. Local Ollama on LAN hardware can achieve sub-second responses. The ReAct loop's 10-iteration limit prevents excessive delays from runaway reasoning.

Q: Can multiple users interact with one zbot device simultaneously? A: The current Telegram integration supports multiple chat participants, but conversation memory is device-global. For multi-tenant deployments, consider running separate zbot instances or implementing user-specific memory partitioning in custom builds.


Conclusion

zbot isn't just another IoT demo—it's a fundamental reimagining of what embedded devices can be. By marrying Zephyr RTOS's industrial-grade reliability with genuine LLM-powered reasoning, LingaoM has created something unprecedented: a microcontroller that converses, remembers, and autonomously controls hardware through natural language.

The ReAct loop architecture, persistent NVS memory compression, and self-registering skill system solve problems that have plagued embedded AI attempts for years. Whether you're building industrial diagnostics, adaptive home automation, or educational robotics, zbot provides a foundation that actually thinks rather than merely responds.

My take? This is the most significant open-source embedded AI project of 2024. The combination of Zephyr portability, minimal tool surface area, and production-ready persistence puts it years ahead of cobbled-together MicroPython scripts or cloud-dependent alternatives.

Ready to build devices with actual brains?

Star the repository, flash your first build, and join the embedded AI revolution:

https://github.com/LingaoM/zbot

The future of intelligent hardware isn't coming. It's already here, running on Zephyr, waiting for your next command.

Advertisement
Advertisement

Commentaires 0

Aucun commentaire pour l'instant. Soyez le premier à réagir !

Laisser un commentaire

Advertisement