Read from lux hangs in bright light I am using VMEL6040 sensors and occasionally under bright light the read can hang, rather than using a wdt to recover I would like to ask some questions about the library.
as for debugging the sensors run stabley (several days at reads every 250 ms) in low light, but over 6k lux they can crash.
I am using wire.h here
in the header
TwoWire *_i2cPort;

the read value calls the ReadRegister function:
uint16_t SparkFun_Ambient_Light::_readRegister(uint8_t _reg)
{

  uint16_t _regValue; 

  _i2cPort-&gt;beginTransmission(_address); 
  _i2cPort-&gt;write(_reg); // Moves pointer to register.
  _i2cPort-&gt;endTransmission(false); // 'False' here sends a restart message so that bus is not released
  _i2cPort-&gt;requestFrom(_address, static_cast&lt;uint8_t&gt;(2)); // Two reads for 16 bit registers
  _regValue = _i2cPort-&gt;read(); // LSB
  _regValue |= uint16_t(_i2cPort-&gt;read()) &lt;&lt; 8; //MSB
  return(_regValue);

}

is there a reason they are not checking the return of the _i2cPort-&gt;endTransmission(false);call? I am wondering if I should check that and not call the requestFrom if it does, i.e.:
uint16_t SparkFun_Ambient_Light::_readRegister(uint8_t _reg)
{

  uint16_t _regValue; 

  _i2cPort-&gt;beginTransmission(_address); 
  _i2cPort-&gt;write(_reg); // Moves pointer to register.
  if (_i2cPort-&gt;endTransmission(false) == 0) { // 'False' here sends a restart message so that bus is not released
      _i2cPort-&gt;requestFrom(_address, static_cast&lt;uint8_t&gt;(2)); // Two reads for 16 bit registers
      _regValue = _i2cPort-&gt;read(); // LSB
      _regValue |= uint16_t(_i2cPort-&gt;read()) &lt;&lt; 8; //MSB
      return(_regValue);
  }
  else
      return 0;
}

Or could my error be from the static casting do int?
so I think I got it, the problem was that on a fail wire.read() returns an int -1
when that gets converted to a unint16 its a big number then it gets left shifted and overflows
the solution was:
uint16_t SparkFun_Ambient_Light::_readRegisterLight(uint8_t _reg)
{
    int lsb;
    int msb;

    _i2cPort-&gt;beginTransmission(_address);
    _i2cPort-&gt;write(_reg); // Moves pointer to register.
    if (_i2cPort-&gt;endTransmission(false) == 0) { // 'False' here sends a restart message so that bus is not released

        unsigned long tstamp = millis();
        while ((_i2cPort-&gt;available() &lt; 2) &amp;&amp; ((millis() - tstamp) &lt; 10));

        if ((_i2cPort-&gt;available() &lt; 2)) {
            _i2cPort-&gt;requestFrom(_address, 2); // Two reads for 16 bit registers
            lsb = _i2cPort-&gt;read(); // LSB
            msb = _i2cPort-&gt;read(); //MSB

            if ((lsb &gt;= 0) &amp;&amp; (lsb &lt;= 256) &amp;&amp; (msb &gt;= 0) &amp;&amp; (msb &lt;= 256)) {                    
                _regValue = lsb + msb * 256;
            }
        }


        return(_regValue);
    }
    else
        return _regValue;//last read 
}

This contains some extra error handling I added, but will leave in such as:

timeout on waiting for a response
checking on properly closing the bus in end transmission
checking for errors from the read

I didn't do error handling as I would need to rewrite the whole library, and for my application repeating the last reading is sufficient.