Pexla Integration

Integration

Pexla sensors stream live distance data the moment power is applied — no setup required. The command API unlocks advanced optimization for filtering, power management, multi-target tracking, and threshold logic.

Zero-config by design

For most applications, simply connect power and read the UART output — distance in millimeters arrives automatically at 9600 bps, at 1-60 Hz, with no configuration whatsoever. The API is there when you need it.

Pexla sensors are designed so you can be measuring in seconds. Besides power (3.6v-6.0V), only TX pin is required. To allow your host to configure your sensor, RX should also be connected.

The default output is a compact ASCII frame: distance in millimeters, updated up to 50 Hz.

Default COM settings are 9600 bps, 8-N-1

All API commands share a single consistent frame format over UART. The sensor accepts both string key names and numeric key IDs. Commands take effect immediately and the sensor echoes a confirmation. There is no mode-switching — commands and data coexist on the same wire.

Examples of API Commands:

  • Write to Flash: <<<*EnZoomIn=1>>>
  • Read RAM value: <<<EnZoomIn?>>>
  • Write to RAM: <<<EnZoomIn=1>>>
  • Read Flash value: <<<*EnZoomIn?>>>
  • Burst read all: <<<configurations?>>>
  • Factory reset: <<<ResetConfigs=1>>>
/*
 * pexla_basic.ino
 * Minimal Pexla distance read — no API needed.
 * Tested: Arduino Uno, Nano, Mega
 *
 * Wiring:
 *   Pexla TX  →  Arduino RX (pin 0, or SoftwareSerial)
 *   Pexla RX  →  Arduino TX (pin 1)
 *   Pexla VCC →  3.3V or 5V (check sensor spec)
 *   Pexla GND →  GND
 */

#define PEXLA_BAUD  9600
#define BUF_SIZE    16

char    buf[BUF_SIZE];
uint8_t buf_idx = 0;

void setup() {
    Serial.begin(115200);       /* Debug output to PC */
    Serial1.begin(PEXLA_BAUD); /* Pexla on hardware UART1 */
    Serial.println("Pexla Basic Reader — waiting for data...");
}

void loop() {
    while (Serial1.available()) {
        char c = Serial1.read();
        if (c == '\n' || c == '\r') {
            if (buf_idx > 0) {
                buf[buf_idx] = '\0';
                parse_frame(buf);
                buf_idx = 0;
            }
        } else if (buf_idx < BUF_SIZE - 1) {
            buf[buf_idx++] = c;
        }
    }
}

void parse_frame(const char *line) {
    /* Default output: "R12345" → distance 12345 mm */
    if (line[0] == 'R') {
        long dist_mm = atol(&line[1]);
        Serial.print("Distance: ");
        Serial.print(dist_mm);
        Serial.println(" mm");
    }
}
"""
pexla_basic.py
Minimal Pexla read loop — no API configuration needed.
Requires: pip install pyserial
"""
import serial

PORT     = '/dev/ttyUSB0'   # Windows: 'COM3', macOS: '/dev/cu.usbserial-...'
BAUDRATE = 9600             # Pexla default baud rate

def main():
    with serial.Serial(PORT, BAUDRATE, timeout=2) as sensor:
        print(f"Connected to {PORT} @ {BAUDRATE} bps")
        print("Reading distance (mm). Press Ctrl-C to stop.\n")

        while True:
            line = sensor.readline().decode('ascii', errors='ignore').strip()

            # Default output frame: "R1234" where 1234 is mm distance
            if line.startswith('R') and line[1:].isdigit():
                distance_mm = int(line[1:])
                print(f"Distance: {distance_mm:5d} mm  ({distance_mm / 1000:.3f} m)")

if __name__ == '__main__':
    main()

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

Selected parameters for the four optimization areas. Prefix with * to persist to Flash. Full parameter list available in the Pexla API documentation.

ParameterType / RangeDefaultDescription
Filtering & Accuracy
SendIterationCntint / 1–641Radar bursts averaged per output frame. Higher = smoother but slower update rate.
EnZoomInbool / 0,10Enable zoom-in window around detected peak. Reduces false returns from foam and walls.
ZoomInThreshint / mm1800Half-width of zoom-in window in mm. Lock-on range around primary target.
RadSortMethodint / 0–300=nearest, 1=strongest, 2=zone priority, 3=custom weight.
Multiple Target Tracking
RadNumTargetsint / 1–101Number of simultaneous targets reported per frame.
EnMultiTargetbool / 0,10Enable multi-target output format. Required for RadNumTargets > 1.
TargetZoneMinint / mm0Minimum range for zone-priority target selection.
TargetZoneMaxint / mm23000Maximum range for zone-priority target selection.
Power Management
EnSleepbool / 0,10Enable STOP2 sleep mode between measurements. 3–8.5µA sleep current.
SleepDelayint / ms1000Duration of sleep period between measurement cycles in milliseconds.
BurstCountint / 1–321Number of measurements taken per wake cycle before returning to sleep.
WakePinbool / 0,10Enable external GPIO wake from STOP2 sleep on rising edge.
Threshold Offloading
ThreshHighint / mm0High watermark. Assert threshold pin if distance < this value.
ThreshLowint / mm23000Low watermark. Assert threshold pin if distance > this value.
ThreshModeint / 0–200=disabled, 1=active-high, 2=active-low output on threshold pin.
ThreshHysteresisint / mm0Dead-band around threshold to prevent chatter on noisy surfaces.
Output & Format
BaudRateint9600UART baud rate. Supported: 9600, 19200, 38400, 115200, 230400, 500000.
OutputRateint / Hz1Output frame rate in Hz, independent of measurement rate.
EnTempbool / 0,10Append internal temperature (°C × 10) to each output frame.
configurationsread-onlyBurst-read: returns all current RAM settings in one response.
ResetConfigswrite / 1Factory reset all parameters to firmware defaults.

Scroll to Top