Hi! I am using the ISL29125 color sensor, but I haven’t been able to get any expected results. I downloaded this library (GitHub - sparkfun/SparkFun_ISL29125_Breakout_Arduino_Library: Arduino Library and example code for the ISL29125), and I am only trying to run the example code in ISL29125Basics.ino. I added some Serial.print commands to check the state of some things, and even though the init() function works, I always get color values that are either 0 or 65535 (the maximum value).
For extra context, I am using this sensor in an Alphabot2-Ar robot, which uses a board similar to Arduino UNO: the Waveshare R3 PLUS. I am using a logic level converter, and connected everything as is explained in this video https://www.youtube.com/watch?app=desktop&v=MwdANEcTiPY&t=0s&ab_channel=DroneBotWorkshop.
Am I doing something wrong, or did I maybe get a faulty sensor? Is there any way for me to check if it is working correctly?
EDIT: Just to discard some variables, I went to get an Arduino UNO (in the back it says the model is R3), that is not connected to anything else, and it still gave the same values. Although at first the init() was not working, but after I added the following code that only tries to find devices, it started working (I don’t really know why):
Wire.begin();
byte error, address;
int nDevices = 0;
for (address = 1; address < 127; address++) {
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0) {
Serial.print("I2C device found at 0x");
Serial.println(address, HEX);
nDevices++;
}
}
if (nDevices == 0)
Serial.println("No I2C devices found");
Does beginning a transmission to the address help it in the init()? This is the init code:
bool SFE_ISL29125::init()
{
bool ret = true;
uint8_t data = 0x00;
// Start I2C
Wire.begin();
// Check device ID
data = read8(DEVICE_ID);
if (data != 0x7D)
{
ret &= false;
}
// Reset registers
ret &= reset();
// Set to RGB mode, 10k lux, and high IR compensation
ret &= config(CFG1_MODE_RGB | CFG1_10KLUX, CFG2_IR_ADJUST_HIGH, CFG_DEFAULT);
return ret;
}
// Reset all registers - returns true if successful
bool SFE_ISL29125::reset()
{
uint8_t data = 0x00;
// Reset registers
write8(DEVICE_ID, 0x46);
// Check reset
data = read8(CONFIG_1);
data |= read8(CONFIG_2);
data |= read8(CONFIG_3);
data |= read8(STATUS);
if (data != 0x00)
{
return false;
}
return true;
}