Send sensor data to Plexus in one line of code
Project description
Plexus Agent
Open-source Python SDK for hardware observability and telemetry. Stream sensor data, CAN bus, MAVLink, cameras, and MQTT from any device to Plexus — the HardwareOps platform for real-time monitoring and fleet management.
Quick Start
pip install plexus-python
plexus start
That's it. The CLI walks you through sign-up, detects your hardware, and starts streaming. If you already have an API key, pass it directly:
plexus start --key plx_xxxxx
Get an API key from app.plexus.company → Devices → Add Device.
What You Get
- Live terminal dashboard — real-time TUI enabled by default (like htop for your hardware)
- Auto-detect hardware — sensors, cameras, CAN interfaces found and configured automatically
- 12+ sensor drivers — IMU, environmental, current/power, ADC, magnetometer, GPS, and more
- Adapters — CAN bus (with DBC decoding), MAVLink (drones/UAVs), MQTT bridge, USB cameras
- Offline buffering — local buffer with automatic retry when network drops
Works on any Linux system — Raspberry Pi, edge compute nodes, test rigs, fleet vehicles, ground stations.
Install
macOS (recommended — avoids Python environment issues):
brew install pipx
pipx install plexus-python
plexus start
Linux / Raspberry Pi (one-line setup):
curl -sL https://app.plexus.company/setup | bash -s -- --key plx_xxxxx
Manual (any platform with Python 3.8+):
python3 -m venv ~/.plexus-env
source ~/.plexus-env/bin/activate
pip install plexus-python
Note: Modern macOS and Debian/Ubuntu block
pip installsystem-wide (PEP 668). Usepipx, the curl script, or a virtual environment instead of runningpip installdirectly.
| Extra | What it adds |
|---|---|
[sensors] |
I2C sensors (IMU, environmental) |
[can] |
CAN bus with DBC decoding |
[mavlink] |
MAVLink for drones/UAVs |
[mqtt] |
MQTT bridge |
[camera] |
USB cameras (OpenCV) |
[picamera] |
Raspberry Pi Camera Module |
[serial] |
Serial/UART (GPS, custom devices) |
[tui] |
Live terminal dashboard |
[system] |
System health (psutil) |
[all] |
Everything |
pip install plexus-python[all] # install everything at once
Usage
Authentication
| Method | How to get it | Used by |
|---|---|---|
API key (plx_*) |
Dashboard → Devices → Add Device, or Settings → Developer | plexus start and Plexus() client |
Two ways to authenticate:
- Interactive (default):
plexus start— sign up or sign in directly in the terminal - API key:
plexus start --key plx_xxxxx— skip the interactive prompt
Credentials are stored in ~/.plexus/config.json or can be set via environment variables:
export PLEXUS_API_KEY=plx_xxxxx
export PLEXUS_ENDPOINT=https://app.plexus.company # default
CLI Reference
plexus start [--key KEY] [--device-id ID] Set up and stream
plexus reset Clear config and start over
plexus start
Set up and start streaming. Handles auth, hardware detection, and sensor selection. The live terminal dashboard (TUI) is enabled by default. Automatically switches to headless mode when output is piped or in a non-TTY environment.
plexus start # Interactive setup with live TUI
plexus start --key plx_xxx # Use an API key directly
plexus start --device-id my-drone # Set device identifier
| Flag | Description |
|---|---|
-k, --key |
API key (skips interactive auth prompt) |
--device-id |
Device ID from dashboard |
plexus start handles auth, hardware detection, and sensor selection interactively:
Found 3 sensors on I2C bus 1:
[1] BME280 temperature, humidity, pressure
[2] MPU6050 accel_x, accel_y, accel_z, gyro_x, gyro_y, gyro_z
[3] INA219 bus_voltage, shunt_voltage, current_ma, power_mw
Stream all? [Y/n] or enter numbers to select (e.g., 1,3):
plexus reset
Clear all configuration — API key, device ID, and settings. Run plexus start again to set up from scratch.
plexus reset # Prompts for confirmation
Direct HTTP
Send data programmatically without the managed agent. Good for scripts, batch uploads, and custom integrations.
- Create an API key at app.plexus.company → Settings → Developer
- Send data:
from plexus import Plexus
px = Plexus(api_key="plx_xxxxx", source_id="test-rig-01")
# Numeric telemetry
px.send("engine.rpm", 3450, tags={"unit": "A"})
px.send("coolant.temperature", 82.3)
# State and configuration
px.send("vehicle.state", "RUNNING")
px.send("motor.enabled", True)
px.send("position", {"x": 1.5, "y": 2.3, "z": 0.8})
# Batch send
px.send_batch([
("temperature", 72.5),
("pressure", 1013.25),
("vibration.rms", 0.42),
])
See API.md for curl, JavaScript, Go, and Bash examples.
Sessions
Group related data for analysis and playback:
with px.session("thermal-cycle-001"):
while running:
px.send("temperature", read_temp())
px.send("vibration.rms", read_accel())
time.sleep(0.01)
Sensors
Auto-detect all connected I2C sensors:
from plexus import Plexus
from plexus.sensors import auto_sensors
hub = auto_sensors() # finds IMU, environmental, etc.
hub.run(Plexus()) # streams forever
Or configure manually:
from plexus.sensors import SensorHub, MPU6050, BME280
hub = SensorHub()
hub.add(MPU6050(sample_rate=100))
hub.add(BME280(sample_rate=1))
hub.run(Plexus())
Built-in sensor drivers:
| Sensor | Type | Metrics | Interface |
|---|---|---|---|
| MPU6050 | 6-axis IMU | accel_x/y/z, gyro_x/y/z | I2C (0x68) |
| MPU9250 | 6-axis IMU | accel_x/y/z, gyro_x/y/z | I2C (0x68) |
| BME280 | Environmental | temperature, humidity, pressure | I2C (0x76) |
| INA219 | Current/Power | bus_voltage, shunt_voltage, current_ma, power_mw | I2C (0x40) |
| SHT3x | Temp/Humidity | temperature, humidity | I2C (0x44) |
| BH1750 | Ambient Light | illuminance | I2C (0x23) |
| VL53L0X | Time-of-Flight | distance_mm | I2C (0x29) |
| ADS1115 | 16-bit ADC | channel_0, channel_1, channel_2, channel_3 | I2C (0x48) |
| QMC5883L | Magnetometer | mag_x, mag_y, mag_z, heading | I2C (0x0D) |
| HMC5883L | Magnetometer | mag_x, mag_y, mag_z, heading | I2C (0x1E) |
| GPS | GPS Receiver | lat, lon, altitude, speed | Serial |
| System | System health | cpu.temperature, memory.used_pct, disk.used_pct, cpu.load | None |
Custom Sensors
Write a driver for any hardware by extending BaseSensor:
from plexus.sensors import BaseSensor, SensorReading
class StrainGauge(BaseSensor):
name = "StrainGauge"
description = "Load cell strain gauge via ADC"
metrics = ["strain", "force_n"]
def read(self):
raw = self.adc.read_channel(0)
strain = (raw / 4096.0) * self.calibration_factor
return [
SensorReading("strain", round(strain, 6)),
SensorReading("force_n", round(strain * self.k_factor, 2)),
]
CAN Bus
Read CAN bus data with optional DBC signal decoding:
from plexus import Plexus
from plexus.adapters import CANAdapter
px = Plexus(api_key="plx_xxx", source_id="vehicle-001")
adapter = CANAdapter(
interface="socketcan",
channel="can0",
dbc_path="vehicle.dbc", # optional: decode signals
)
with adapter:
while True:
for metric in adapter.poll():
px.send(metric.name, metric.value, tags=metric.tags)
Supports socketcan, pcan, vector, kvaser, and slcan interfaces. See examples/can_basic.py for more.
MAVLink (Drones / UAVs)
Stream telemetry from MAVLink-speaking vehicles — ArduPilot, PX4, and other autopilots:
from plexus import Plexus
from plexus.adapters import MAVLinkAdapter
px = Plexus(api_key="plx_xxx", source_id="drone-001")
adapter = MAVLinkAdapter(
connection_string="udpin:0.0.0.0:14550", # SITL or GCS
)
with adapter:
while True:
for metric in adapter.poll():
px.send(metric.name, metric.value, tags=metric.tags)
Decoded metrics include attitude (roll/pitch/yaw), GPS, battery, airspeed, RC channels, and more. Supports UDP, TCP, and serial connections. See examples/mavlink_basic.py for more.
MQTT Bridge
Forward MQTT messages to Plexus:
from plexus.adapters import MQTTAdapter
adapter = MQTTAdapter(broker="localhost", topic="sensors/#")
adapter.connect()
adapter.run(on_data=my_callback)
Buffering and Reliability
The client buffers data locally when the network is unavailable:
- In-memory buffer (default, up to 10,000 points)
- Persistent SQLite buffer for surviving restarts
- Automatic retry with exponential backoff
- Buffered points are sent with the next successful request
# Enable persistent buffering
px = Plexus(persistent_buffer=True)
# Check buffer state
print(px.buffer_size())
px.flush_buffer()
Live Terminal Dashboard
The TUI launches by default when you run plexus start — no flags needed. It gives you a real-time view of everything streaming from your device, like htop for your hardware. Headless mode is used automatically when output is piped or in a non-TTY environment.
Keyboard shortcuts: q quit | p pause | s scroll metrics | ? help
+--------------------------------------------------------------+
| Plexus Live Dashboard * online ^ 4m 32s |
+--------------------------------------------------------------+
| Metric | Value | Rate | Buffer | Status |
+--------------+----------+--------+--------+------------------+
| cpu.temp | 62.3 | 1.0 Hz | 0 | * streaming |
| engine.rpm | 3,450 | 10 Hz | 0 | * streaming |
| pressure | 1013.2 | 1.0 Hz | 0 | * streaming |
+--------------+----------+--------+--------+------------------+
| Throughput: 12 pts/min Total: 847 Errors: 0 |
+--------------------------------------------------------------+
Requires the tui extra: pip install plexus-python[tui]
Troubleshooting
Permission denied on I2C
sudo usermod -aG i2c $USER && reboot
API key invalid
Verify your key at app.plexus.company/devices. Keys start with plx_.
No sensors detected
Check wiring, pull-up resistors, and that sensors are on I2C bus 1 (default). Set PLEXUS_I2C_BUS environment variable to use a different bus.
TUI not showing
Install the TUI extra: pip install plexus-python[tui]. The TUI also requires a real terminal — it will not render when output is piped or in a non-TTY environment.
Behind a proxy or firewall
Set PLEXUS_ENDPOINT to your proxy URL. Ensure outbound access on ports 443 and 80.
Something else?
Try plexus reset to clear config and start fresh, or check the API docs for protocol details.
Architecture
Device (plexus start)
+-- WebSocket -> PartyKit Server -> Dashboard (real-time)
+-- HTTP POST -> /api/ingest -> ClickHouse (storage)
- WebSocket path: Used by
plexus startfor real-time streaming controlled from the dashboard. Data flows through the PartyKit relay to connected browsers. - HTTP path: Used by the
Plexus()client for direct data ingestion. Data is stored in ClickHouse for historical queries.
When recording a session, both paths are used — WebSocket for live view, HTTP for persistence.
API Reference
See API.md for the full HTTP and WebSocket protocol specification, including:
- Request/response formats
- All message types
- Code examples in Python, JavaScript, Go, and Bash
- Error codes
- Best practices
License
Apache 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file plexus_python-0.1.0.tar.gz.
File metadata
- Download URL: plexus_python-0.1.0.tar.gz
- Upload date:
- Size: 152.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf04d7a39eddd537a8d424c3b0f5b70c8918decb9a3ee180455fd5fb6155f871
|
|
| MD5 |
59b2c22d09dcc6fa2ed5f9dcdafc7a87
|
|
| BLAKE2b-256 |
affb2233c22d73b74da3b4e13db283b269fccbda5e9cd53ea11f2e89e982b2a9
|
Provenance
The following attestation bundles were made for plexus_python-0.1.0.tar.gz:
Publisher:
publish.yml on plexus-oss/plexus-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
plexus_python-0.1.0.tar.gz -
Subject digest:
bf04d7a39eddd537a8d424c3b0f5b70c8918decb9a3ee180455fd5fb6155f871 - Sigstore transparency entry: 1280966093
- Sigstore integration time:
-
Permalink:
plexus-oss/plexus-python@ab8f15c2edb852527d0787172d1a035183c6a2ef -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/plexus-oss
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ab8f15c2edb852527d0787172d1a035183c6a2ef -
Trigger Event:
release
-
Statement type:
File details
Details for the file plexus_python-0.1.0-py3-none-any.whl.
File metadata
- Download URL: plexus_python-0.1.0-py3-none-any.whl
- Upload date:
- Size: 147.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2c573e1f28b18a328976d657dc05a6c6f0120a075f4da81471bb36fd129f49e
|
|
| MD5 |
9fe21842cc5284c95ac2c501ac6f43a8
|
|
| BLAKE2b-256 |
c1dea93966a72d1e8294551df7c887ebd7bfc5bb528e917e7b9a53f584d92b03
|
Provenance
The following attestation bundles were made for plexus_python-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on plexus-oss/plexus-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
plexus_python-0.1.0-py3-none-any.whl -
Subject digest:
f2c573e1f28b18a328976d657dc05a6c6f0120a075f4da81471bb36fd129f49e - Sigstore transparency entry: 1280966094
- Sigstore integration time:
-
Permalink:
plexus-oss/plexus-python@ab8f15c2edb852527d0787172d1a035183c6a2ef -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/plexus-oss
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ab8f15c2edb852527d0787172d1a035183c6a2ef -
Trigger Event:
release
-
Statement type: