LMS Line Sensor
lms-line-sensor is a MicroPython and MicroBlocks driver for the LMS Line Sensor board. It communicates with the sensor over I2C and exposes a small API for reading raw or calibrated data, calibration management, and LED control.
Features
- Reads 8 light sensor channels in a single transfer.
- Exposes position, derivative, and line shape.
- Supports raw and calibrated sensor modes.
- Starts calibration and stores calibration values in EEPROM.
- Controls the IR emitter and RGB LED display modes.
- Aimed at ESP23 (LMS-ESP32)
Installation
Micropython Using ViperIDE Package Manager (Recommended)
- Open ViperIDE on your device
- Go to Tools → Package Manager
- Select Install Package via Link
- Enter the package link:
https://github.com/antonsmindstorms/lms-line-sensor.git - Follow the on-screen prompts to complete installation
MicroBlocks
Open a microblocks editor and drag LMS Line Sensor into the browser window.
On regular Python
This package targets MicroPython devices. For packaging and distribution it is published on PyPI, but it must run on hardware that provides the machine module.
Install from PyPI:
pip install lms-line-sensor
Copy the installed line_sensor.py module to your MicroPython device if your deployment flow does not install packages directly on the board.
Quick Start
Micropython
from time import sleep
from line_sensor import LineSensor
sensor = LineSensor(scl_pin=4, sda_pin=5, device_addr=51)
sensor.ir_led_on()
sensor.load_calibration_from_rom()
sensor.mode_calibrated()
while True:
position = sensor.position()
derivative = sensor.position_derivative()
print(position, derivative)
sleep(0.1)
Microblocks
Here's a simple program that reads the line shape and distance from center. Shape is an ASCII character in the shape of the line:
SHAPE_NONE = ' ',
SHAPE_STRAIGHT = '|',
SHAPE_T = 'T',
SHAPE_L_LEFT = '<',
SHAPE_L_RIGHT = '>',
SHAPE_Y = 'Y'
API Overview
LineSensor
The LineSensor class provides the public API.
light_values()returns the 8 raw light sensor values.data(*indices)returns the full 13-byte response or selected entries.position()returns the current line position.position_derivative()returns the derivative of the line position.shape()returns the sensor-reported shape metric.mode_raw()switches to raw reading mode.mode_calibrated()switches to calibrated reading mode.start_calibration()starts sensor calibration.ir_led_on()andir_led_off()control the IR emitter.rgb_led_mode(mode)changes the RGB LED display mode.save_calibration_in_rom()stores calibration data in EEPROM.load_calibration_from_rom()loads calibration data from EEPROM.
Documentation
Sphinx documentation sources live in docs. Build them with:
pip install .[docs]
sphinx-build -b html docs docs/_build/html
Development Notes
- Source module:
micropython/line_sensor.py - API docs entry point:
docs/index.rst - The Sphinx configuration mocks the MicroPython
machinemodule so docs can be built on desktop Python. - Submit update to Pypi:
- Update version in line sensor.py
- Update version in package.json
- Activate venv
rm -rf ./dist && python -m build && twine upload dist/*
Metadata
Release files for lms-line-sensor 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lms_line_sensor-0.1.0.tar.gz | 4.6 kB | Without provenance | Details for lms_line_sensor-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lms_line_sensor-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for lms_line_sensor-0.1.0-py3-none-any.whl |
Total release size: 9.2 kB
Release files / lms_line_sensor-0.1.0.tar.gz
| Download URL | lms_line_sensor-0.1.0.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a5f57fb47f44bdc303817284558ba8521cf1a5b777b988e2841c0413c6841edd
|
|
BLAKE2b-256 checksum How to use checksums |
e332d46353b77d6b4c23d4bd288da90f4dd431b8891d8a91908e9243f3826e29
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Release files / lms_line_sensor-0.1.0-py3-none-any.whl
| Download URL | lms_line_sensor-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d1fbab2bdc3b51d360c1a010de6e2b6b398c54f57ce6c26fa5f4f272122e61b6
|
|
BLAKE2b-256 checksum How to use checksums |
29d2549899cc49fcf6c43cd17d590688d22034be70d3b36ebafa71909cb9f48a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Security for lms-line-sensor 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.