Python Bluetooth interface for Bosch PLR devices

Python interface to remote control BOSCH PLM 40 C (might also work with other devices).

It implements the exchange data container where measurements are triggered by the device ("Event by LRF" similar to the MeasureOn App).

Features

  • measure distance
  • turn laser on and off
  • turn display backlight on and off
  • get device name and device info (serial number, HW/SW version...)
  • recive data from device via exchange data container ("Event by LRF")

Dependencies

The interface uses the Bluetooth module from PyQt5. It uses crc to compute checksums. qasync allows the usage of asyncio with PyQt. Poetry is used as build system.

Examples

Trigger measurement from device

The interface taskes advantage of async/await.

from bosch_plr import Device

@Device.run('<mac-address of the device>')
async def main(device: Device):
  for i in range(4):
    data = await device.user_measure()  # waits for the user to measure a distance with the device
    print(data.result)

if __name__ ==  '__main__':
  main()

>>> 4.001649856567383
>>> 3.888049840927124
>>> ...

Trigger measurement from PC

from bosch_plr.device import Device
from PyQt6.QtWidgets import QApplication
from qasync import QEventLoop
import asyncio

app = QApplication([])

loop = QEventLoop(app)
asyncio.set_event_loop(loop)

async def main():
  device = Device()

  await device.connect('<mac-address of the device>')

  info = await device.info()
  
  print(info)

  distance = await device.measure()  # trigger measurement from computer

  print(distance)

  await device.disconnect()

if __name__ ==  '__main__':
    loop.run_until_complete(main())

>>> info = {'date_code': '131', 'serial_number': ..., 'sw_revision': 2263, 'sw_version': '1.3.3', 'hw_version': '6.0.0', 'part_number': '...'}
>>> distance = 47.318

Run sandbox

poetry run sandbox

Reference