2

I am working on a project where I need to get the RGB light value from surrounding ambient light.

For that I am using an ESP32 with a Sparkfun ISL29125 breakout board. I have tried to scan available/connected I2C devices addresses. I'm getting the 0x44 address in the output, which is the address of the ISL29125.

But when running the following code, I am not getting any output. I have added the library to the Arduino IDE.

I have checked all wire connections. 2 other sensors are connected to the I2C bus.

I have connected the pins as follows:

GPIO21 (ESP32) -> SDA (ISL29125) GPIO22(ESP32) -> SCL (ISL29125).

I'm supplying 3.3v and GND from ESP32.

I have scanned the I2C bus and getting the addresses of all connected sensors including the ISL29125.

  • 0X38
  • 0X44 (Address of the ISL29125)
  • 0X47

Following is the source code.

#include <Wire.h>
#include <SparkFunISL29125.h>
SFE_ISL29125 RGB_sensor;
void setup() {
  // Initialize serial communication
  Serial.begin(115200);
  Serial.println("Hello123");
  // Initialize the ISL29125 with simple configuration so it starts sampling
  if (!RGB_sensor.init()) {
    Serial.println("Sensor Initialization Problem\n\r");
  }
}

void loop() {
  Serial.println("Hello");
  // Read sensor values (16 bit integers)
  unsigned int red = RGB_sensor.readRed();
  unsigned int green = RGB_sensor.readGreen();
  unsigned int blue = RGB_sensor.readBlue();
  
  // Print out readings, change HEX to DEC if you prefer decimal output
  Serial.print("Red: "); Serial.println(red,HEX);
  Serial.print("Green: "); Serial.println(green,HEX);
  Serial.print("Blue: "); Serial.println(blue,HEX);
  Serial.println();
  delay(2000);
}

This is the output I am getting

[     4][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
Hello123
[    21][I][esp32-hal-i2c.c:75] i2cInit(): Initialising I2C Master: sda=21 scl=22 freq=100000

I am not getting any RGB value or the code is getting stuck in the init() method. Can anyone guide me? What can be the problem? What is my mistake?

7
  • please remove the pictures of text ... replace them with the text ... format as code for readability ... that should stop the downvotes because your question will be readable by everyone, not just people with good eyesight
    – jsotola
    Sep 29, 2023 at 18:55
  • 1
    The code is a slightly instrumented stock example. If you want to be somewhat more certain where you're hanging it's best to .flush() after your got-here type messages. Otherwise you may successfully queue the message but hang before the message actually gets transmitted through hardware. There is at least small chance that showing your wiring would help. With reasonable assumptions about what you're not showing what you are showing looks fine. So, show more.
    – timemage
    Sep 29, 2023 at 19:20
  • @jsotola you can click the image for bigger/more readable text. Still sucks compared to real text though...
    – dandavis
    Sep 29, 2023 at 21:43
  • @jsotola thank you for input. I have corrected the question. Sep 30, 2023 at 3:33
  • @timemage I have rechecked the wiring and it's proper. otherwise it shouldn't show the address. I have connected the pins as follows GPIO21 (ESP32) -> SDA (ISL29125), GPIO22(ESP32) -> SCL (ISL29125). Supplying 3.3v and GND from ESP32. Sep 30, 2023 at 3:36

1 Answer 1

1

The library file "SparkFunISL29125.cpp" contains this: Wire.begin(); and I guess you want it to contain Wire.begin(21,22) from what you have said in a later comment. Best would be to comment out Wire.begin(); in the library and put the corrected version in your sketch. In such a situation I'd suggest copying the .cpp and .h files of the library into the sketch folder. You also have to change this in the sketch: #include <SparkFunISL29125.h> to #include "SparkFunISL29125.h" to address the local copy.

Further, the schematic of the SparkFun ILS29125 breakout board shows that the on board I2C pullup resistors are connected via a solder jumper which by default is not bridged. You appear to have done the I2C scan test with two other devices connected and may have "benefitted" from their I2C pullup resistors. If you did the live test with the ILS29125 alone, there may have been no I2C pullup resistors in the circuit.

enter image description here

schematic

5
  • "via a solder jumper which by default is not bridged" You can see the non-masked stub of copper running between the pads like you can see them leaving each pad to the left. If you play with brightness/contrast you will see the trace itself under the mask. Language in Sparkfun's hookup guide for the module confirms they are bridge by default; the pads are for reconnecting it really. I'm surprised supplying the pin numbers manually did anything because the output listing (and Wire/board variant source code) indicate that it is already using those pins Initialising I2C Master: sda=21 scl=22.
    – timemage
    Sep 30, 2023 at 17:42
  • @timemage I've added the schematic which shows a default open solder jumper. Of course it is not impossible that that they have simply used the wrong footprint. The detail on the board picture is not really clear enough to come to any conclusion. The symptoms, that is hanging, tends to indicate a pullup resistor problem. Maybe the OP comes back and says something more.
    – 6v6gt
    Sep 30, 2023 at 19:20
  • 1
    imgur.com/a/VxQZkk1 The left is a view of the Eagle brd file. The right is the original image just adjusted for contrast and brightness, rotated, mirrored (it's the bottom layer of the eagle file). Hookup guide says "If you want to disable the on-board 10kΩ I2C pullup resistors -- in case you want to use those built into your microcontroller or other external pull-ups -- simply cut the two traces between the three pads on the backside of the board. If you decide you want the pull-ups later, you can always solder the pads back together."
    – timemage
    Sep 30, 2023 at 21:43
  • More for future readers than anything. The OP has already accepted. It's all stuff I researched before leaving the initial comment. That's why I find it surprising that that their issue is resolved. Anyway, perhaps they are as they appear in the schematic. But, I don't believe so. For what it's worth the UNO schematics also represent the cuttable RESET connection the same way as an open, even though it's closed on a shipped board.
    – timemage
    Sep 30, 2023 at 21:49
  • @timemage It is certainly a mystery. It does appear from what you have found that simply a misleading symbol was used in the schematic. Maybe Eagle does not or did not have a normally closed solder jumper schematic symbol. So the board designer also works with an open jumper then draws a track through it. Also plausible is that on the specific device used by the OP any closed solder jumpers had been already cut for reasons suggested in the guide you quoted. Unless the OP comes back we can only guess.
    – 6v6gt
    Oct 1, 2023 at 2:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.