cancel
Showing results for 
Search instead for 
Did you mean: 

VL53L1X I2C no signal

TVoge
Associate II

@John E KVAM

Hi,

I want to use the VL53L1X in combination with a Murata CMWX1ZZABZ lora module on the B-L072Z-lrwan1 discoboard.

When i try to transmit data using:

HAL_I2C_IsDeviceReady(&hi2c1, 0x52, 100, 5);

I can see the SCL and SDA signals on my scope.

But when i try to use the API of the VL53L1X nothing happens on the lines. They stay at 3.24mV.

What do i forget?

my code:

int main( void )
{
 
	
	VL53L1_Dev_t                   dev;
  VL53L1_DEV                     Dev = &dev;
	
  /* STM32 HAL library initialization*/
  HAL_Init();
  
  /* Configure the system clock*/
  SystemClock_Config();
  
  /* Configure the debug mode*/
  DBG_Init();
  
  /* Configure the hardware*/
  HW_Init();
	
	
  /* USER CODE BEGIN 1 */
 	
	MX_I2C1_Init();
	
	dev.I2cHandle = &hi2c1;
  dev.I2cDevAddr = 0x52;
	
 
 
  
	/*** VL53L1X Initialization ***/
  VL53L1_WaitDeviceBooted(Dev);
  VL53L1_DataInit(Dev);
  VL53L1_StaticInit(Dev);
	PRINTF("Data init sensor DONE\n");
	
	VL53L1_SetDistanceMode(Dev, VL53L1_DISTANCEMODE_LONG);
  VL53L1_SetMeasurementTimingBudgetMicroSeconds(Dev, 50000);
  VL53L1_SetInterMeasurementPeriodMilliSeconds(Dev, 500);
  VL53L1_StartMeasurement(Dev);
	PRINTF("StartMeasuerment TRUE\n");
	
	
	
  /* USER CODE END 1 */
  
  /*Disbale Stand-by mode*/
  LPM_SetOffMode(LPM_APPLI_Id , LPM_Disable );
  
  PRINTF("VERSION: %X\n\r", VERSION);
 
  
  /* Configure the Lora Stack*/
  LORA_Init( &LoRaMainCallbacks, &LoRaParamInit);
  
  LORA_Join();
 
  LoraStartTx( TX_ON_TIMER);
 
  while( 1 )
  {
  if (AppProcessRequest==LORA_SET)
   {
      /*reset notification flag*/
      AppProcessRequest=LORA_RESET;
	  /*Send*/
      Send( NULL );
    }
	if (LoraMacProcessRequest==LORA_SET)
    {
     /*reset notification flag*/
    LoraMacProcessRequest=LORA_RESET;
      LoRaMacProcess( );
    }
    /*If a flag is set at this point, mcu must not enter low power and must loop*/
    DISABLE_IRQ( );
    
    /* if an interrupt has occurred after DISABLE_IRQ, it is kept pending 
     * and cortex will not enter low power anyway  */
    if ((LoraMacProcessRequest!=LORA_SET) && (AppProcessRequest!=LORA_SET))
    {
#ifndef LOW_POWER_DISABLE
      LPM_EnterLowPower( );
#endif
    }
		
    ENABLE_IRQ();
 
	//HAL_I2C_IsDeviceReady(&hi2c1, 0x52, 100, 5);
	  VL53L1_WaitMeasurementDataReady( Dev );
	  VL53L1_GetRangingMeasurementData(Dev, &RangingData);
		
		PRINTF("Distance is: %d",RangingData.RangeMilliMeter);
		PRINTF("\n");
		
	switch(RangingData.RangeStatus)
		{
			case 0: 
			{
				PRINTF("Ranging data is valid\n");
			break;
			}
			case 1: 
			{
				PRINTF("Raised if sigma estimator check is above the internal defined threshold\n");
			break;
			}
			case 2:
			{
				PRINTF("Raised if signal value is below the internal defined threshold\n");
				break;
			}
		
			case 4:
			{
				PRINTF("Raised when phase is out of bounds\n");
				break;
			}
		
			case 5:
			{
				PRINTF("Raised in case of HW or VCSEL failure\n");
				break;
			}
		
			case 7:
			{
				PRINTF("Wrapped target, not matching phases\n");
				break;
			}
			
			case 8:
			{
				PRINTF("Internal algorithm underflow or overflow\n");
				break;
			}
		
			case 14:
			{
				PRINTF("The reported range is invalid\n");
				break;
			}
			default:
			{
				
				PRINTF("Status is:  %d : ", RangingData.RangeStatus);
				PRINTF("\n");
			}
		}	
		
	VL53L1_ClearInterruptAndStartMeasurement( Dev );
 
		/* USER CODE END 2 */
}
}

The output on my serial monitor is:

distance = -1

status = 255

1 REPLY 1
John E KVAM
ST Employee

It could be your initialization is not working.

Try something like:

printf("Autonomous Ranging Test\n");

Status = VL53L1_WaitDeviceBooted(Dev);

  Status += VL53L1_DataInit(Dev);

  Status += VL53L1_StaticInit(Dev);

  Status += VL53L1_SetDistanceMode(Dev, VL53L1_DISTANCEMODE_LONG);

  Status += VL53L1_SetMeasurementTimingBudgetMicroSeconds(Dev, 99000)

  Status += VL53L1_SetInterMeasurementPeriodMilliSeconds(Dev, 100);

  Status += VL53L1_StartMeasurement(Dev);

CHECK_STATUS(Status);

If you don't get Status=0, look into it, but this will verify if everything works.

(I have several drivers, so check the calls to make sure they are right for you.)

But to be honest everything looks good to me.

So I'm guessing it's an I2C platform issue.

Use code snippet to verify.


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. It helps the next guy.