Skip to content

ValueError from vl53.distance #9

Closed
@Idirianuk

Description

@Idirianuk
Adafruit CircuitPython 7.3.0 on 2022-05-23; FeatherS3 with ESP32S3
Board ID:unexpectedmaker_feathers3

I can't ascertain the previous version (at previous code update, 2022-05-30, so before then, whichever bundle that was, worked perfectly, bundle dated 2022-06-11 is not working). I've currently reverted to the older version.

Code Snippet (generating a string because I want to send it to an oled):

if vl53.data_ready:
        text = "Distance: {:.1f}cm".format(vl53.distance)
        print(text)
        oled.fill(0)
        oled.text(text, 0, 0, 1)

In this context (in my main code loop) it quits to the REPL on the second line above.
Error Generated:

Traceback (most recent call last):
  File "code.py", line 129, in <module>
ValueError: unknown format code 'f' for object of type 'NoneType'

The error is not always generated, but after a few iterations, it does fail, giving a distance reading of "None"

This is the code and sample output from the example code given on learn.adafruit.com


vl53.start_ranging()

while True:
    if vl53.data_ready:
        print("Distance: {} cm".format(vl53.distance))
        vl53.clear_interrupt()
        time.sleep(1.0)


VL53L1X Simple Test.
--------------------
Model ID: 0xEA
Module Type: 0xCC
Mask Revision: 0x10
Distance Mode: LONG
Timing Budget: 50
--------------------
Distance: 195.7 cm
Distance: 188.7 cm
Distance: 191.4 cm
Distance: 188.0 cm
Distance: None cm
Distance: None cm
Distance: 193.9 cm
Distance: 186.8 cm
Distance: None cm
Distance: 188.2 cm

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions