Package: vl53_400_lib
vl53-400 Laser RangeFinder LibraryPython Library and CLI for the VL53-400 laser rangefinder with Serial interfaceNOTE: This is still a bit underconstruction. The Functions here do seem to work, but not all capabilities of the chipset is handled yet. You should be able to do measurements though.This is for theMJ-VL53-400 unit Sold by MengJie.Its basically aSTMicroelectronics VL53L0Xwith a UART so you can use it via a USB -> TTL Serial adapter and not deal with IIC or Modbus.It seems to actually be aWitMotion Laser Distance Sensor WT-VL53L0 Distance Module UART Outputrepackaged by MengJieMenjie MJ-VL53-400 User ManualST API InfoLibrary FunctionsClassdevice_access.SerialAccesscontains all the methods for using itInstantiate the RangeFinder ClassRangeFinder(serial_port:str,baud_rate:int,timeout:int,debug:bool)ArgumentsNeed to supply all of these for nowserial_port: str- The serial port the RangeFinder is connected too such as/dev/tty.usbserial-910baud_rate: int- Baud Rate. Should be115200timeout: int- Timeout. Should use1return_rate: float- Should be one of"0.1", "0.2", "0.5", "1", "2", "5", "10", "20", "50", "100"debug: bool- SetTrueto enable debugging, otherwiseFalseExample:fromvl53_400_libimportRangeFinderrange_finder=RangeFinder("/dev/tty.usbserial-910",115200,1,10,False)ResetThis method resets the Rangefinder.range_finder.reset()Set Sensor modeThis method sets the sensor mode between serial (default), modbus and iic.Argumentsmode: str- The mode to set. (serial,modbus,iic)
Probably only want to use serial or modbus.
modbus will stop the  serial updatesExample:range_finder.set_sensor_mode("modbus")Get Return RateGets the return rate settingReturnsstr: The return rate in HzExamplerate=range_finder.get_return_rate()Set Return RateArgumentsrate: str- One of"0.1", "0.2", "0.5", "1", "2", "5", "10", "20", "50", "100"Examplerange_finder.set_return_rate("0.5")Stream DataOnly prints the data to stdoutThis method streams data from the serial port to stdout. It does not return
anything and will block until interrupted if loop is True.Argumentloop: bool- Whether or not to loop forever.
Defaults to True.
Set to false to exit after one loop (for testing)range_finder.stream_data(True)Get DistanceThis is the main workhorse function to use. It will fetch the distance data from the Rangefinder
Reads data from the serial port and returns a dictionary.Returnsdata: dict-  A dictionary containing thedistanceandunits,
as well as thestateandstate_code.data=range_finder.get_distance()Main.py has a CLI for exercising all functionsInstall and run cligitclonecdvl53_400_lib
poetryinstallTo run the cli:> poetry run vl53 --help

Usage: vl53 [OPTIONS]

Options:
  --serial-port TEXT              The serial port to connect to.
  --baud-rate INTEGER             The baud rate to use.
  --timeout INTEGER               The timeout to use.
  --return-rate [0.1|0.2|0.5|1|2|5|10|20|50|100]
                                  Set Return Rate in Hz
  --mode [serial|modbus|iic]      Comm mode (modbus stops serial spew)
  --op [stream|get_return_rate|lstream|reset]
                                  The operation to perform.
  --debug                         Enable debug logging.
  --help                          Show this message and exit.TODO:Make initialization key/values with defaultsCalibration