RemoteSensor Block
Stream live sensors from your mobile device via WebRTC. Features 3-axis acceleration and 3-axis rotation.
Open RemoteSensor in BlockWerk →# RemoteSensor Block
Description
RemoteSensor is a source block that streams live inertial and optional sensor data from a paired mobile device into the simulation over a WebRTC peer-to-peer connection. When the block is placed on the canvas it generates a pairing QR code; scanning it from the phone's browser establishes the link. Once connected, the block exposes accelerometer (3-axis), gyroscope (3-axis), and a buffer health signal as output ports, with additional ports added automatically when the phone reports magnetometer, barometer, or GPS capability.
Use this block for motion-based control experiments, gesture input, or hardware-in-the-loop tests where a mobile device acts as a wireless inertial measurement unit. A configurable playout buffer and interpolation filter smooth the variable-rate network stream before it enters simulation blocks.
Parameters
playoutDelay
Buffering latency in milliseconds (0–500 ms, UI only). Adds a fixed lookahead window to absorb network jitter. Default: 250.
interpolation
Reconstruction filter applied between received sensor packets (UI only). Options: none (zero-order hold), linear, or pchip (smooth monotone cubic). PCHIP produces smoother signals but is more CPU-intensive. Default: linear.
outputLabels
Comma-separated list of output port labels (one per port in declaration order). Used internally; edit via the block properties panel rather than directly.
Examples
Use phone tilt as a reference input to a PID loop
RemoteSensor ──► [Tilt Beta] ──► Gain ──► PIDController → [in]
Log all 6 DOF inertial signals to a scope
RemoteSensor ──► [Accel X] ┐
──► [Accel Y] ├──► Scope
──► [Accel Z] │
──► [Rotation Alpha]│
──► [Tilt Beta] │
──► [Tilt Gamma] ┘
Remarks
- Source block: All sensor channels are output ports (right side). The block has no signal inputs in its base configuration.
- Dynamic ports: Ports are added or removed automatically after pairing, based on the connected device's reported sensor capabilities (accel, gyro, mag, baro, gps). Actuator input ports (Vibrate, Beep) appear on the left side when the phone supports them.
- WebRTC required: The phone and the desktop browser must both have internet access for the PEERJS signalling handshake. Local-only setups require a self-hosted PeerJS server (configurable via
localStoragekeysblockwerk_peer_host/blockwerk_peer_port). - Buffer level port: The
bufferLeveloutput reports the current playout lookahead in milliseconds. Wire it to a display or assertion to monitor stream health. - Raw data export: While a simulation is running, click the record button on the block to capture raw packet telemetry (timestamps, jitter, all axis values) and export it as CSV.
- Output values when disconnected: All ports hold
0until the phone connects and begins transmitting.
See Also
- MQTTSubscriber: Alternative source for network sensor data via an MQTT broker.
- ExternalInput: Lightweight source for manually injected or scripted numeric values.