VL53L0X I2C sensor not recognized after machine.reset()

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
User avatar
oserror
Posts: 43
Joined: Tue Feb 12, 2019 12:26 am

VL53L0X I2C sensor not recognized after machine.reset()

Post by oserror » Fri Mar 05, 2021 1:45 am

I have the ESP32 powered by a 12 Volt power supply -> buck converter -> 6 Volts to VIN and GND pins. The VL53L0X is powered by the 3V3 pin of the ESP32.

When connected via WiFi over WebREPL, if I stop main.main() with CTRL-C and call:

Code: Select all

import machine
machine.reset()
and reconnect, execution has halted. I find that the i2c instance has loaded but i2c.scan() produces an empty list.

Power cycling the device solves the problem. I hooked up a Tasmota power plug and just toggle it off and on to solve the issue for now to avoid running up and down the stairs.

Is there a problem with the i2c declaration? Mine looks like:

Code: Select all

i2c = I2C(
    0,
    scl=Pin(config.SCL_PIN),
    sda=Pin(config.SDA_PIN),
    freq=400000
)
Also, is there any interest in my port of the Adafruit VL53L0X driver to MicroPython? I haven't put it up on GitHub yet but it seems to be working fine so far.

Thanks for any help!

User avatar
oserror
Posts: 43
Joined: Tue Feb 12, 2019 12:26 am

Re: VL53L0X I2C sensor not recognized after machine.reset() - Now recognized

Post by oserror » Sat Mar 06, 2021 6:02 pm

Well, I cleaned up my networking code and now the sensor initializes as expected, most of the time.

Perhaps I was working the ESP32 too hard before? The "OSError: [Errno 19] ENODEV" error still occurs but not as often. I should have specified the error before. My apologies.

My real quibble now is that I think I chose the wrong sensor, as I need a smaller range than I initially thought. The sensor is detecting values from about 100mm to 130mm with about +/- 5mm resolution. I might try a VL6180X since that seems to be more in my range for this application.

This is for detecting water levels in a PVC pipe. The sensor is mounted to a test cap at the top of the vertical pipe.

User avatar
oserror
Posts: 43
Joined: Tue Feb 12, 2019 12:26 am

Re: VL53L0X I2C sensor not recognized after machine.reset()

Post by oserror » Sun May 09, 2021 11:40 am

I have been using this ported Adafruit driver for a while now, and it seems stable enough. I think it should be as I only changed the various CircuitPython calls to their MicroPython equivalents.

Here is the link to the ported driver:
https://github.com/truckershitch/micropython-vl53l0x

If anyone has an issue with it, please post an issue on GitHub as I don't always get an email from here (I probably have incorrect forum settings).

Thanks.

Post Reply