Very much an Arduino newbie here, so hoping this is a simple fix. Anyways, I'm trying to get a lidar sensor working, and I am using a helloworld sketch off of github. GitHub - stm32duino/VL53L4CX: Arduino library to support the VL53L4CX Time-of-Flight high accuracy ranging sensor with multi target detection
The code compiles and verifies successfully and without any warnings (I have all warnings at 'all'), and it is supposed to start running the sensor, but the Serial Monitor never even opens up, and it doesn't appear any of the code is executing. I've tried adding print statements all around the code to see what's running and what's not, and still nothing.
I'm not 100% sure the way my sensor is wired is compatible with the code. I'm using an Adafruit Qt Py with SAMD21, and the code appears to be written primarily for the STM32 Nucleo board. Either way, shouldn't print statements still work even if the sensor isn't wired correctly? I'm just surprised I'm getting no output, error or otherwise.
Any feedback is much appreciated, thanks!
#include <vl53l4cx_class.h>
#include <vl53l4cx_def.h>
#include <vl53l4cx_dmax_private_structs.h>
#include <vl53l4cx_dmax_structs.h>
#include <vl53l4cx_error_codes.h>
#include <vl53l4cx_error_exceptions.h>
#include <vl53l4cx_hist_map.h>
#include <vl53l4cx_hist_private_structs.h>
#include <vl53l4cx_hist_structs.h>
#include <vl53l4cx_ll_def.h>
#include <vl53l4cx_ll_device.h>
#include <vl53l4cx_nvm_map.h>
#include <vl53l4cx_nvm_structs.h>
#include <vl53l4cx_platform_user_config.h>
#include <vl53l4cx_platform_user_data.h>
#include <vl53l4cx_platform_user_defines.h>
#include <vl53l4cx_preset_setup.h>
#include <vl53l4cx_register_map.h>
#include <vl53l4cx_register_settings.h>
#include <vl53l4cx_register_structs.h>
#include <vl53l4cx_tuning_parm_defaults.h>
#include <vl53l4cx_types.h>
#include <vl53l4cx_xtalk_private_structs.h>
/**
******************************************************************************
* @file VL53L4CX_Sat_HelloWorld.ino
* @author SRA
* @version V1.0.0
* @date 16 March 2022
* @brief Arduino test application for the STMicrolectronics VL53L4CX
* proximity sensor satellite based on FlightSense.
* This application makes use of C++ classes obtained from the C
* components' drivers.
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT(c) 2022 STMicroelectronics</center></h2>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
/*
* To use this sketch you need to connect the VL53L4CD satellite sensor directly to the Nucleo board with wires in this way:
* pin 1 (GND) of the VL53L4CD satellite connected to GND of the Nucleo board
* pin 2 (VDD) of the VL53L4CD satellite connected to 3V3 pin of the Nucleo board
* pin 3 (SCL) of the VL53L4CD satellite connected to pin D15 (SCL) of the Nucleo board
* pin 4 (SDA) of the VL53L4CD satellite connected to pin D14 (SDA) of the Nucleo board
* pin 5 (GPIO1) of the VL53L4CD satellite connected to pin A2 of the Nucleo board
* pin 6 (XSHUT) of the VL53L4CD satellite connected to pin A1 of the Nucleo board
*/
/* Includes ------------------------------------------------------------------*/
#include <Arduino.h>
#include <Wire.h>
#include <vl53l4cx_class.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <assert.h>
#define DEV_I2C Wire
#define SerialPort Serial
#ifndef LED_BUILTIN
#define LED_BUILTIN 13
#endif
#define LedPin LED_BUILTIN
// Components.
VL53L4CX sensor_vl53l4cx_sat(&DEV_I2C, A1);
/* Setup ---------------------------------------------------------------------*/
void setup()
{
// Led.
pinMode(LedPin, OUTPUT);
// Initialize serial for output.
SerialPort.begin(115200);
SerialPort.println("Starting...");
// Initialize I2C bus.
DEV_I2C.begin();
// Configure VL53L4CX satellite component.
sensor_vl53l4cx_sat.begin();
// Switch off VL53L4CX satellite component.
sensor_vl53l4cx_sat.VL53L4CX_Off();
//Initialize VL53L4CX satellite component.
sensor_vl53l4cx_sat.InitSensor(0x12);
// Start Measurements
sensor_vl53l4cx_sat.VL53L4CX_StartMeasurement();
SerialPort.println("before loop\n");
}
void loop()
{
VL53L4CX_MultiRangingData_t MultiRangingData;
VL53L4CX_MultiRangingData_t *pMultiRangingData = &MultiRangingData;
uint8_t NewDataReady = 0;
int no_of_object_found = 0, j;
char report[64];
int status;
do {
status = sensor_vl53l4cx_sat.VL53L4CX_GetMeasurementDataReady(&NewDataReady);
} while (!NewDataReady);
//Led on
digitalWrite(LedPin, HIGH);
if ((!status) && (NewDataReady != 0)) {
status = sensor_vl53l4cx_sat.VL53L4CX_GetMultiRangingData(pMultiRangingData);
no_of_object_found = pMultiRangingData->NumberOfObjectsFound;
snprintf(report, sizeof(report), "VL53L4CX Satellite: Count=%d, #Objs=%1d ", pMultiRangingData->StreamCount, no_of_object_found);
SerialPort.print(report);
for (j = 0; j < no_of_object_found; j++) {
if (j != 0) {
SerialPort.print("\r\n ");
}
SerialPort.print("status=");
SerialPort.print(pMultiRangingData->RangeData[j].RangeStatus);
SerialPort.print(", D=");
SerialPort.print(pMultiRangingData->RangeData[j].RangeMilliMeter);
SerialPort.print("mm");
SerialPort.print(", Signal=");
SerialPort.print((float)pMultiRangingData->RangeData[j].SignalRateRtnMegaCps / 65536.0);
SerialPort.print(" Mcps, Ambient=");
SerialPort.print((float)pMultiRangingData->RangeData[j].AmbientRateRtnMegaCps / 65536.0);
SerialPort.print(" Mcps");
}
SerialPort.println("");
if (status == 0) {
status = sensor_vl53l4cx_sat.VL53L4CX_ClearInterruptAndStartMeasurement();
}
}
digitalWrite(LedPin, LOW);
}