Closed zhanko73 closed 6 years ago
I analysed more the begin() and found an issue in the read8(). I compared it with the bmp180's cpp and it is handled a bit different way: TSL2951: The "while (! Wire.available());" is waiting for the number of bytes to be read, however, in case of a disconnected sensor this will wait forever. uint8_t Adafruit_TSL2591::read8(uint8_t reg) { Wire.beginTransmission(TSL2591_ADDR); Wire.write(0x80 | 0x20 | reg); // command bit, normal mode Wire.endTransmission();
Wire.requestFrom(TSL2591_ADDR, 1); while (! Wire.available()); return Wire.read(); }
BMP085/BMP180: This does not wait for the number of bytes, only read. Also please note after the write they run an "end transmission" then they open it for a second time when reading. (In case of TSL2591 they do not re-open it again, however it looks working.) uint8_t Adafruit_BMP085::read8(uint8_t a) { uint8_t ret;
Wire.beginTransmission(BMP085_I2CADDR); // start transmission to device
Wire.write(a); // sends register address to read from
Wire.send(a); // sends register address to read from
Wire.endTransmission(); // end transmission
Wire.beginTransmission(BMP085_I2CADDR); // start transmission to device Wire.requestFrom(BMP085_I2CADDR, 1);// send data n-bytes read
ret = Wire.read(); // receive DATA
ret = Wire.receive(); // receive DATA
Wire.endTransmission(); // end transmission
return ret; }
OK try now!
This part of the Adafruit's example code for tsl2591 test does not work correctly: if (tsl.begin()) { Serial.println("Found a TSL2591 sensor"); } else { Serial.println("No sensor found ... check your wiring?"); while (1); } REASON: tsl.begin() will hung up if no sensor detected. Expected behavior would be to display a message (no sensor found) the stop running. Instead, it looks like the begin() hungs up. It looks like I'm not alone with this problem (I have just seen on adafruit's forum.)