cancel
Showing results for 
Search instead for 
Did you mean: 

VL53L8 unresponsive when used with nRF52840

joebreda
Associate

The SATEL-VL53L8CX dev boards were all out of stock, so I picked up the LS53LX-SlL8 Light Saber Sensor VL53L8CX by Gilisymo for debugging before I build my own PCB. I am interfacing with the sensor via the Adafruit itsy bitsy nRF52840 (but have also used the xiao nRF52840 Sense and the ESP32-S3 QtPy for debugging purposes).

I had previously been able to work with the VL53L5CX easily using the Sparkfun library with a very similar set up. However, using the STM32duino library I can't communicate with the sensor via my nRF52840. The 

vl53l8cx_set_i2c_address() function fails some of the time, and other times it will succeed but the following vl53l8cx_is_alive() function will fail. My physical set up (with this devboard) is connecting ground to ground, 3v to Vin, SDA to SDA, SCL to SCL, and the A3 GPIO pin of my MCU to the LPn pin. I have validated that the A3 pin is responsive when I digitalWrite high and low, so it should function as a LPn control pin. I am also certain that the pins are connected correctly. I tried using an I2C scanner to make sure the default address in the library is correct (the macro for default address is set to 0x52) and I found that the I2C scanner sometimes finds 0x14 and other times it finds 0x29, but never 0x52. I am not sure if this is an artifact of the I2C address missing the read/write bit in the scanner, but this is interesting because 0x52 is 0b1010010, 0x29 is 0b101001, and 0x14 is 0b10100, so it is as if the I2C address keeps getting shifted. 
Interestingly, the ESP32-S3 with the exact same physical set up and code will allow the sensor to initialize but then never receives data. But I was hoping to use the nRF52840 specifically because I can power it at 1.8v to get 1.8v logic level for IOVDD on this sensor. 
Is this an issue with interfacing with the nRF52 specifically? I am confused because I am using the devboard as intended and the API out of the box with no modifications. 
 
Here is my code, and it never makes it passed is_alive() but often gets stuck at setting the I2C address:
#include <Arduino.h>
#include <Wire.h>
#include <vl53l8cx_class.h>
 
#define LPN_PIN A3
VL53L8CX sensor_vl53l8cx_top(&Wire, LPN_PIN);
 
void setup() {
// Initialize serial for output.
Serial.begin(115200);
pinMode(LPN_PIN, OUTPUT);
// Initialize I2C bus.
Wire.begin(); 
sensor_vl53l8cx_top.begin();

uint8_t status = VL53L8CX_STATUS_OK;
uint8_t isAlive = 0;

// Reset the sensor by toggling the LPN pin
sensor_vl53l8cx_top.vl53l8cx_off();
sensor_vl53l8cx_top.vl53l8cx_on();

status = sensor_vl53l8cx_top.vl53l8cx_set_i2c_address(0x29);
while(!status) {
Serial.println("address not set");
delay(1000);
}

status = sensor_vl53l8cx_top.vl53l8cx_is_alive(&isAlive);
while(!status) {
Serial.println("Not Alive");
delay(1000);
}
 
status = sensor_vl53l8cx_top.vl53l8cx_init();
while(!status) {
Serial.println("Not init");
delay(1000);
}
}
1 ACCEPTED SOLUTION

Accepted Solutions
joebreda
Associate

Hello everyone who may be viewing this:

 

The issue ended up being that the vl53l8cx_class library uses 0 for success and 1 for failure for many of the status checks. This is inverted from other libraries so I naively assumed this library would function just like other libraries for other ST sensors. But the code snippet I included does work as long as you invert all the status checks. 

View solution in original post

2 REPLIES 2
Zhiyuan.Han
ST Employee

Hi 

From your issue description,  issue seems more link to HW connection, can you share your connection detail and 54-ls53lx-s-l8cx schematic? make sure the AVDD, IOVDD and Core_1V8 are connected correctly. 

LPn pin was pull up and SPI_I2C_N was pull down. 

Reference schematic as below 

ZhiyuanHan_0-1703557848924.png

 

 

Br

Zhiyuan.Han


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
joebreda
Associate

Hello everyone who may be viewing this:

 

The issue ended up being that the vl53l8cx_class library uses 0 for success and 1 for failure for many of the status checks. This is inverted from other libraries so I naively assumed this library would function just like other libraries for other ST sensors. But the code snippet I included does work as long as you invert all the status checks.