← Back to Plugins
Integration

Meshcore

gunpowder100 By gunpowder100 👁 24 views ▲ 0 votes

MeshCore KI Integration β€” LoRa mesh + AI gateway. Dual AI: Claude Sonnet (remote) + Gemma 4 (local failover). Off-grid chat, IoT control, 133-char chunking. Standalone Python + OpenClaw plugin (planned).

Homepage GitHub

Configuration Example

meshcore:
  port: "auto"         # Serial port or "auto" for auto-detection
  baud: 115200

ai:
  ollama_url: "http://127.0.0.1:11434"
  ollama_model: "gemma3:4b"
  anthropic_model: "claude-sonnet-4-20250514"
  prefer_local: false   # Set true to prefer local Gemma over remote Claude
  timeout: 30
  enable_iot: true

iot:
  enabled: true
  dry_run: true         # Set false when GPIO hardware is connected

access:
  dm_policy: "open"     # "open" or "allowlist"
  require_prefix: ""    # e.g. "!ai " to only respond to prefixed messages

privacy:
  store_messages: false
  redact_logs: true
  disable_context: false
  context_timeout_minutes: 10

README

# MeshCore KI Integration

**AI-powered LoRa mesh gateway** β€” bridges [MeshCore](https://github.com/rpsreal/MeshCore) mesh networks with AI models for off-grid intelligent communication.

Send a text message from any MeshCore LoRa node β†’ the gateway processes it through AI β†’ you get an answer back over radio. No internet needed at the endpoint.

> **Two editions available:**
> - **Standalone** β€” slim Python scripts, direct Anthropic API, zero dependencies beyond an API key
> - **OpenClaw Edition** *(planned)* β€” MeshCore as a channel plugin for [OpenClaw](https://openclaw.ai), the open-source AI gateway

---

## Features

- **Dual AI Backend** β€” Claude Sonnet (remote, via Anthropic API) + Gemma 4 (local, via Ollama). Automatic failover between online and offline AI.
- **Off-Grid AI Chat** β€” Ask anything over LoRa radio. Hazmat identification, first aid protocols, weather, technical references β€” all without mobile coverage.
- **IoT Control** β€” Natural language commands like "turn on basecamp lights" get translated into GPIO actions on the gateway.
- **Message Chunking** β€” AI responses are automatically split into 133-character chunks (MeshCore limit) with `[n/N]` prefixes.
- **Privacy First** β€” No messages stored on disk. Log redaction enabled by default. Conversation context lives in RAM only, auto-purged after configurable timeout.
- **Access Control** β€” Open or allowlist-based DM policy, blocklist, optional message prefix gating.
- **Compact & Reliable** β€” Failover depends only on the API key. No cron jobs, no complex setup.

## Architecture

### Standalone Edition

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     LoRa 868 MHz     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  MeshCore Nodeβ”‚ ◄──────────────────► β”‚  WIO Pro P1 Tracker β”‚
β”‚ (Handheld/App)β”‚    MeshCore Protocol β”‚ (USB Gateway Radio) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                 β”‚
                                    USB Serial β”‚ 115200 Baud
                                                 β”‚
                                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                  β”‚      Server (Debian Linux)  β”‚
                                  β”‚                             β”‚
                                  β”‚  meshcore_client.py         β”‚
                                  β”‚  meshcore_service.py        β”‚
                                  β”‚  ai_backend.py              β”‚
                                  β”‚  iot_handler.py             β”‚
                                  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                         β”‚          β”‚
                                    β–Ό          β–Ό
                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                          β”‚ Claude Sonnet β”‚  β”‚    Gemma 4      β”‚
                          β”‚(Anthropic API)β”‚  β”‚   (Ollama)      β”‚
                          β”‚ Remote/Primaryβ”‚  β”‚ Local/Fallback  β”‚
                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

### OpenClaw Edition *(planned)*

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  LoRa Mesh    β”‚                    β”‚  Chat Apps         β”‚
β”‚  (MeshCore)   β”‚                    β”‚  (WhatsApp, TG...) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚                                     β”‚
        β–Ό                                     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    OpenClaw Gateway                       β”‚
β”‚                                                           β”‚
β”‚  MeshCore Channel Plugin  β”‚  Chat Plugins  β”‚  AI Router  β”‚
β”‚  Memory Manager           β”‚  Context Engine              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚                        β”‚
          β–Ό                        β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚ Claude Sonnet β”‚       β”‚    Gemma 4      β”‚
   β”‚   (Primary)   β”‚       β”‚  (Fallback)     β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

## Hardware

| Component | Details |
|-----------|---------|
| Gateway Radio | [Seeed WIO Pro P1 Tracker](https://www.seeedstudio.com/) |
| Interface | USB Serial, 115200 Baud, appears as `/dev/ttyACM0` |
| Server | Any Linux machine (Debian, Ubuntu, Raspberry Pi) |
| LoRa Nodes | Any MeshCore-compatible device |
| Cost | ~€50 per node |

## Quick Start

```bash
# Clone the repository
git clone https://github.com/gunpowder100/openclaw-meshcore.git
cd openclaw-meshcore

# Run setup script (creates venv, installs deps, detects hardware)
chmod +x setup.sh
./setup.sh

# Set your Anthropic API key (optional, for remote AI)
export ANTHROPIC_API_KEY="sk-ant-..."

# Run
source .venv/bin/activate
python openclaw_meshcore.py
```

## Configuration

Edit `config.yaml` to customize:

```yaml
meshcore:
  port: "auto"         # Serial port or "auto" for auto-detection
  baud: 115200

ai:
  ollama_url: "http://127.0.0.1:11434"
  ollama_model: "gemma3:4b"
  anthropic_model: "claude-sonnet-4-20250514"
  prefer_local: false   # Set true to prefer local Gemma over remote Claude
  timeout: 30
  enable_iot: true

iot:
  enabled: true
  dry_run: true         # Set false when GPIO hardware is connected

access:
  dm_policy: "open"     # "open" or "allowlist"
  require_prefix: ""    # e.g. "!ai " to only respond to prefixed messages

privacy:
  store_messages: false
  redact_logs: true
  disable_context: false
  context_timeout_minutes: 10
```

## Dual AI β€” Why Two Models?

| | Claude Sonnet (Primary) | Gemma 4 (Fallback) |
|---|---|---|
| **Location** | Remote (Anthropic API) | Local (Ollama) |
| **Internet** | Required | Not needed |
| **Knowledge** | Full reasoning, large context | Limited by storage & CPU |
| **Use case** | Complex queries, analysis | Basic Q&A, offline mode |
| **Trigger** | Default | Auto-failover when API unreachable |

> **Note:** Gemma 4 runs with limited knowledge scope due to server storage and CPU constraints β€” ideal for basic queries and predefined topics. The failover is fully automatic and depends only on the API key availability. No cron jobs or complex setup required.

## Mesh Commands

| Command | Description |
|---------|-------------|
| `!ai <text>` | Query the AI (if prefix is configured) |
| `!status` | Show system status |
| `!ping` | Test connectivity |

## Test Environment

| Component | Details |
|-----------|---------|
| Server | Hermes β€” Debian Linux, 192.168.178.73 |
| Gateway | WIO Pro P1 Tracker via USB (/dev/ttyACM0) |
| AI Primary | Claude Sonnet via Anthropic API (requires ANTHROPIC_API_KEY) |
| AI Fallback | Gemma 4 (gemma3:4b) via Ollama on localhost:11434 |
| LoRa Band | 868 MHz (EU) |
| Python | 3.13+ with asyncio |
| Packages | meshcore, httpx, pyyaml |

## Roadmap

- [x] Standalone Python integration
- [x] Dual AI failover (Claude + Gemma)
- [x] Channel message support
- [x] IoT/GPIO command parsing
- [ ] OpenClaw channel plugin integration
- [ ] Multi-channel bridging (LoRa ↔ WhatsApp/Telegram)
- [ ] Web dashboard

## License

MIT β€” see [LICENSE](LICENSE)

## Author

**Jonathan Salim** β€” Buergerfunkinitiative Essen-Kettwig
- GitHub: [gunpowder100](https://github.com/gunpowder100)
- Web: [jonathansalim.de](https://jonathansalim.de)
- Email: [email protected]

Copyright Β© 2026 Jonathan Salim. All rights reserved.
integration

Comments

Sign in to leave a comment

Loading comments...