Hi all,
I am trying to setup and read 2 VL53L1X sensors on an esp32. I am trying to set the adr of the sensors to 0x30, and reset one of them, so its i2c adr goes back to the default ox29, as explained here.
When I run my program, I get this error printed continuoously
Backtrace: 0x400d12a4:0x3ffb1f20 0x400d14eb:0x3ffb1f40 0x400d1525:0x3ffb1f60 0x400d0d89:0x3ffb1f80 0x400d3752:0x3ffb1fb0 0x40086a75:0x3ffb1fd0
Rebooting…
�
�␜ޠ��J��1���␘s�␌�␌�
���Guru Meditation Error: Core 1 panic'ed (IntegerDivideByZero). Exception was unhandled.
Core 1 register dump:
PC : 0x400d12a4 PS : 0x00060930 A0 : 0x800d14ee A1 : 0x3ffb1f20
A2 : 0x40000000 A3 : 0x000000ff A4 : 0x3ffc0038 A5 : 0x00000001
A6 : 0x00060520 A7 : 0x00000000 A8 : 0x00000000 A9 : 0x3ffb1f00
A10 : 0xffffffff A11 : 0x00000029 A12 : 0x00000001 A13 : 0x00000001
A14 : 0x00000000 A15 : 0x3ffb0060 SAR : 0x0000001c EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000
ELF file SHA256: 0000000000000000
Here is my code. I dont understand what can cause this, how am I dividing an int by 0 here??
#include <Arduino.h>
#include <VL53L1X.h>
#include <Wire.h>
VL53L1X Lsensor;
VL53L1X Rsensor;
#define VL53L1X_DEFAULT_ADR (0x29)
#define LEFT_VL53L1X_ADR (VL53L1X_DEFAULT_ADR) // default adr is reset
#define LEFT_VL53L1X_XSHUT_PIN (34)
#define RIGHT_VL53L1X_ADR (0x30)
#define RIGHT_VL53L1X_XSHUT_PIN (-1)
void setup(void)
{
Serial.begin(9600);
Wire.begin();
Wire.setClock(400000); // use 400 kHz I2C
pinMode(LEFT_VL53L1X_XSHUT_PIN, OUTPUT);
digitalWrite(LEFT_VL53L1X_XSHUT_PIN, HIGH);
Rsensor.setAddress(RIGHT_VL53L1X_ADR);
delay(10);
digitalWrite(LEFT_VL53L1X_XSHUT_PIN, LOW);
delay(10);
Lsensor.init();
Lsensor.setTimeout(500);
Lsensor.setDistanceMode(VL53L1X::Long);
Lsensor.setMeasurementTimingBudget(50000);
Lsensor.startContinuous(50);
Rsensor.init();
Rsensor.setTimeout(500);
Rsensor.setDistanceMode(VL53L1X::Long);
Rsensor.setMeasurementTimingBudget(50000);
Rsensor.startContinuous(50);
}
void loop()
{
Serial.print("reading L ");
Serial.println(Lsensor.read());
Serial.print("reading R ");
Serial.println(Rsensor.read());
delay(500);
}