Connected Phone
ConnectivityRemoteSensor 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.
Inputs & Outputs
| Direction | ID | Label | Type | Status |
|---|---|---|---|---|
| ← Out | accelX |
Accel X | number | Output |
| ← Out | accelY |
Accel Y | number | Output |
| ← Out | accelZ |
Accel Z | number | Output |
| ← Out | gyroAlpha |
Rotation Alpha | number | Output |
| ← Out | gyroBeta |
Tilt Beta | number | Output |
| ← Out | gyroGamma |
Tilt Gamma | number | Output |
| ← Out | bufferLevel |
Buffer (ms) | number | Output |
Parameters
| Parameters | Label | Type | Default | Description |
|---|---|---|---|---|
playoutDelay |
Playout Delay (ms) | number | 250 |
|
interpolation |
Interpolation | select | linear |
How to reconstruct signal values between received sensor packets. Linear is the best default. PCHIP is smoother but heavier. |
outputLabels |
Output Labels | vector | accelX,accelY,accelZ,gyroAlpha,gyroBeta,gyroGamma,bufferLevel |
Usage 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 & Best Practices
- 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.
Related Components
- PhoneController: Same QR-pairing flow, but with an on-screen touch joystick (or tilt mode) streaming X/Y control values — the intuitive choice for the "Fly the Quadcopter (Live)" demo and other interactive control experiments.
- MQTTSubscriber: Alternative source for network sensor data via an MQTT broker.
- ExternalInput: Lightweight source for manually injected or scripted numeric values.