0

I have a system that utilises 2 VL53L0X sensors. This works fine for the majority of time, but after around 20 hours till 2 days (varying), the ESP resets due to Software a WDT, I've managed to do a stack trace, and this is the result:

PC: 0x40100529: Twi::busywait(unsigned char) at /Users/martin/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/core_esp8266_si2c.cpp line 271
EXCVADDR: 0x00000000

Decoding stack results
0x40218f25: Twi::readFrom(unsigned char, unsigned char*, unsigned int, unsigned char) at /Users/martin/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/core_esp8266_si2c.cpp line 405
0x4010083e: millis() at /Users/martin/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/core_esp8266_wiring.cpp line 188
0x4021913c: twi_readFrom(unsigned char, unsigned char*, unsigned int, unsigned char) at /Users/martin/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/core_esp8266_si2c.cpp line 1042
0x402090b0: TwoWire::requestFrom(unsigned char, unsigned int, bool) at /Users/martin/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/libraries/Wire/Wire.cpp line 129
0x402090dc: TwoWire::requestFrom(unsigned char, unsigned char) at /Users/martin/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/libraries/Wire/Wire.cpp line 143
0x402140eb: VL53L0X::readReg(unsigned char) at /Users/martin/Documents/Arduino/libraries/vl53l0x-arduino-1.02/VL53L0X.cpp line 322
0x40214442: VL53L0X::readRangeContinuousMillimeters() at /Users/martin/Documents/Arduino/libraries/vl53l0x-arduino-1.02/VL53L0X.cpp line 816
0x40201f00: readVLXSensors() at /Users/martin/Documents/Arduino/TEST_WS2812/TEST_WS2812.ino line 674
0x402083c7: loop() at /Users/martin/Documents/Arduino/TEST_WS2812/TEST_WS2812.ino line 596
0x40218404: loop_wrapper() at /Users/martin/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/core_esp8266_main.cpp line 172

This is the function that reads the sensors (initiated from the main loop):

void readVLXSensors() {

  if (readTop) {
    distSensorTop_distance = distSensorTop.readRangeContinuousMillimeters();
    if (distSensorTop.timeoutOccurred()) {
      distSensorTop_distance = 99999;
    }
    readTop = !readTop;

  } else {
    distSensorBottom_distance = distSensorBottom.readRangeContinuousMillimeters();

    if (distSensorBottom.timeoutOccurred()) {
      distSensorBottom_distance = 99999;
    }
    readTop = !readTop;
  }

}

As you can see as last desperate measure, I alternate the reading of the sensors, where as before I just read both sensors after each other. But even this approach still gives the WDT resets.

I don't believe it is (my)code nor the VL53L0X Library.. Any one an approach on this one?

  • 1
    It looks like the twi library goes into a tight loop waiting for a response from the sensor, and there's no yield in there. – Majenko May 4 at 13:39
  • Thats part of the esp core isn't? – martin010 May 4 at 13:50
  • Yep. Make sure you're on the latest version of the core. – Majenko May 4 at 13:50
  • Yes I am on 2.6.3 – martin010 May 4 at 13:53
  • I can see that busywait() doesn't yield, and it doesn't really want to either. Maybe you could add a yield() call just before you query each sensor. – Majenko May 4 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.