Skip to main content

Rangefinders-i2c Platforms Language IDE adam package

License PyPI version License PyPI version Wheel Version Format Status Activity LastStatus CodeSize CodeSize

What the library can do?

  1. Change TOF10120 address device by usb.
  2. Get data from TOF10120 device by i2c

How install

pip install rangefinders-i2c

Change address

To change the address, a usb programmer is needed. After connecting the programmer, you can find out the address using the following code

if your programmer is the only device (connect to /dev/ttyUSB0)

from rangefinders_i2c.SensorManagment import SensorManagment

managment = SensorManagment()

if there is more than one device, then you can find it using the following code

print(SensorManagment.GetUsbDeviceList())

and by selecting a device, you can specify it when initializing an instance of the class

managment = SensorManagment('/dev/ttyUSB1')

the second parameter is the port speed, by default it is 9600. To change the speed, use the second parameter when initializing the class instance

managment = SensorManagment('/dev/ttyUSB1', 4800).

After that, you should call the function setAddress

managment = SensorManagment()
managment.setAddress(48)

for all rangefinders, we use constant values: 48, 50, 52, 54, 56, 58.

Calling the set Address() function with a value other than the specified constants will result in an error: ValueError('Address must be 48, 50, 52, 54, 56, 58')

Get Data from TOF10120

In order to get the values, you should initialize an instance of the class

from rangefinders_i2c.ReadSensor import ReadSensor

sensor = ReadSensor(1)

where 1 is the smbus bus number.

You can also enable verbose mode (log error to console) using the following code

sensor = ReadSensor(1, True)

After that, you can get the value from the device by passing it the address as a parameter

address = 0x18
distance = sensor.GetDistance(address)
print("address:", address, "distance:", distance)

or

address = 24
distance = sensor.GetDistance(address)
print("address:", address, "distance:", distance)

Metadata

Release files for rangefinders-i2c 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rangefinders-i2c 0.0.4
File Size Uploaded Provenance
rangefinders-i2c-0.0.4.tar.gz 4.2 kB Without provenance Details

Release files / rangefinders-i2c-0.0.4.tar.gz

Download URL rangefinders-i2c-0.0.4.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
14c26954a273b53d631d892662e4e7f640cc7f67d6acf0f656ef1b4a536d2c7a
BLAKE2b-256 checksum
How to use checksums
a8165a6b33c358e7d7c6b7fd0fb64d55d30afc8604aa98fd30921cdb5c592218
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Security for rangefinders-i2c 0.0.4

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page