VL53L1X does not initialize correctly when powered from a battery

I have this project where I have 2 VL53L1X sensors and they get initialized one after the other. This works when powered from USB, and it used to work when powered from a battery, but now it seems like a the second sensor fails to initialize only when powered from a Lipo battery, when powered from USB 5V, it works fine…
I may think it has to do with the code, even though I dont recall changing it since it last worked? Here is my initialization function (on Arduino). This function basically fails @ sensor.init() but I can’t get why:

VL53L1X sensor;

int8_t init()


  if (!sensor.init(0)) 
    PRINT("Tof Switch init failed");
    return -1;


  return 0;

void reboot()
  pinMode(_shutPin, OUTPUT);
  pinMode(_shutPin, INPUT);

int8_t _initCommunication()
  PRINT("Initializing Wire for TOF sensor");
  Wire.setClock(400000); // use 400 kHz I2C
  return 0;


If it works when you power it via USB, the most likely cause would be either an inadequate power supply (make sure your battery is charged) or incorrect connections in your battery setup (such as a missing ground to the second board). So, you might double check those things.

However, from the code you posted, I do not see anything that would be needed for setting up two sensors (e.g. there is only one VL53L1X object); is this the code you are using for the setup that uses 2 sensors? Could you post a simplified, but complete, program that demonstrates the problem?