Skip to main content

Emulate LEGO Powered Up sensors from MicroPython boards with RPC-style API

Project description

PUPRemote logo

PUPRemote

License: GPLv3 MicroPython Compatible Platforms: Pybricks | SPIKE2 | Robot Inventor

PUPRemote lets microcontrollers present themselves as LEGO Powered Up sensors. It includes a low-level LPF2 emulator and a higher-level remote-procedure-style API for quick sensor prototypes.

Table of Contents

Features

  • Emulate LEGO LPF2 sensors from MicroPython boards
  • Higher-level RPC-style API (PUPRemoteSensor, PUPRemoteHub)
  • Supports both synchronous (process()) and asynchronous (process_async()) modes
  • Works with Pybricks, SPIKE 2, and Robot Inventor hubs
  • Example scripts for LMS-ESP32, OpenMV, and Pybricks
  • Optional lightweight pupremote_hub.py for Pybricks-only deployments

Supported Platforms

  • LMS-ESP32 firmware (bundles pupremote.py and lpf2.py)
  • OpenMV (copy pupremote.py and lpf2.py onto the board)
  • Pybricks hubs (use the smaller pupremote_hub.py when space matters)
  • Other MicroPython-capable boards with LPF2 physical connection

Installation

LMS-ESP32 firmware

  1. The firmware already contains pupremote.py and lpf2.py.
  2. Copy an example (for instance examples/esp32_dummy_data/pup_demo_esp32.py) to the board as main.py.
  3. Connect the LMS-ESP32 to your hub (e.g., SPIKE Prime port A) and reboot.

OpenMV

  1. Copy src/pupremote.py and src/lpf2.py to the OpenMV board.
  2. Deploy an example such as examples/openmv_simple/main.py.
  3. Run from the OpenMV IDE or reboot to start.

Pybricks hubs

  1. Copy src/pupremote_hub.py to the hub (use this smaller file instead of the full pupremote.py).
  2. Upload an example such as examples/openmv_simple/pybricks_spike.py and adjust imports to from pupremote_hub import PUPRemoteHub if needed.
  3. Run the program from the Pybricks app.

Quick Start

LMS-ESP32 demo

Copy to the LMS-ESP32 as main.py and reboot:

# examples/esp32_dummy_data/pup_demo_esp32.py
from pupremote import PUPRemoteSensor, SPIKE_ULTRASONIC

def msg(*argv):
    return "demo"

p = PUPRemoteSensor(sensor_id=SPIKE_ULTRASONIC, power=True)
p.add_command('msg', "repr", "repr")

while True:
    p.process()

OpenMV demo

Copy src/pupremote.py and src/lpf2.py to the board, then run:

# examples/openmv_simple/main.py
from pupremote import PUPRemoteSensor, ESP32, SPIKE_ULTRASONIC
from time import sleep_ms

p = PUPRemoteSensor(sensor_id=SPIKE_ULTRASONIC, platform=ESP32)
p.add_channel('cntr', to_hub_fmt="b")

while True:
    p.process()
    p.update_channel('cntr', 1)
    sleep_ms(20)

Pybricks demo

Place src/pupremote_hub.py on the hub and reference it:

# examples/openmv_simple/pybricks_spike.py
from pupremote_hub import PUPRemoteHub

hub = PUPRemoteHub()
hub.add_channel('demo', to_hub_fmt="b")

while True:
    hub.process()
    hub.update_channel('demo', 1)

Compatibility Notes

  • Async/Sync modes: Use process() for synchronous polling in loops, or process_async() + call_multitask() for concurrent async operations with callback queues.
  • Pybricks has a known 32-byte packet limitation. Pass max_packet_size=16 when constructing PUPRemoteHub or PUPRemoteSensor to avoid checksum errors.
  • For Pybricks, prefer pupremote_hub.py to save space (it only contains PUPRemoteHub).
  • LMS-ESP32 firmware already includes dependencies; do not re-upload pupremote.py or lpf2.py there.

Project Structure

  • src/ core implementation (pupremote.py, pupremote_hub.py, lpf2.py)
  • examples/ runnable demos for LMS-ESP32, OpenMV, and Pybricks
  • docs/ Sphinx docs with API references
  • img/ project assets (logo)

Development Notes (MicroPython first)

  • Target runtime is MicroPython; verify every proposed import exists there (e.g., inspect is unavailable—avoid it).
  • Prefer ustruct, uasyncio, and micropython.const; gate CPython-only helpers behind try/except ImportError.
  • Keep memory and dependency footprint small; avoid modules that pull in large transitive imports.

Contributing

Contributions and protocol refinements are welcome. Please open an issue or PR with your ideas or projects built on PUPRemote.

License

GPL-3.0. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pupremote-2.1.1.tar.gz (135.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pupremote-2.1.1-py3-none-any.whl (26.9 kB view details)

Uploaded Python 3

File details

Details for the file pupremote-2.1.1.tar.gz.

File metadata

  • Download URL: pupremote-2.1.1.tar.gz
  • Upload date:
  • Size: 135.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for pupremote-2.1.1.tar.gz
Algorithm Hash digest
SHA256 95aba261dcb67c93d9db77eb766b64fbfddce7b56c24019a7579d7ea7bb4cf4e
MD5 e47e44bc10ceecb9ca657aeef5254f53
BLAKE2b-256 b06f47e66cff46c3be4fbe1c3267693568667641f787c6ae948248e811172bb0

See more details on using hashes here.

File details

Details for the file pupremote-2.1.1-py3-none-any.whl.

File metadata

  • Download URL: pupremote-2.1.1-py3-none-any.whl
  • Upload date:
  • Size: 26.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for pupremote-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b6e6687b633dd38349258f90cb3343191e1456d93a35efaa6a2226b9ee6f6ac0
MD5 f8321fc0963528bf862aeab8144f3d3f
BLAKE2b-256 2d6ad3dfc6fc92db8f3b57b172bb180d5691477a026c6228270b77cf8334cd09

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page