Spectral Triad not showing up correctly

I’m using this sensor in a project involving an AI model run on a Raspberry Pi. The data is read first on an Arduino UNO R3. This is the error I’m getting now:

Sensor does not appear to be connected. Please check wiring. Freezing...

I’ve checked all the wiring. I’ve made sure everything is up to date. I’ve also tried using both internal and external pullups. I tried using an I2C scanner, and the sensor did show up correctly with the address of 0x49. It just never shows up when I use my code. Very, very rarely, it does work. Can you please help? I had a fully working project, but it stopped working correctly recently. I need to have this wrapped up as soon as possible. I have a couple of images attached of the setup, sorry they aren’t the clearest. I appreciate any help you can provide.

Here is my code:

#include "SparkFun_AS7265X.h" //Click here to get the library: http://librarymanager/All#SparkFun_AS7265X
AS7265X sensor;

const int btn = 7;


void serialFlush(){
  while(Serial.available() > 0) {
    char t = Serial.read();
  }
}

void setup()
{
  Serial.begin(115200);
  pinMode(btn, INPUT);
  pinMode(20, INPUT);
  pinMode(21, INPUT);


  if (sensor.begin() == false)
  {
    Serial.println("Sensor does not appear to be connected. Please check wiring. Freezing...");
    while (1)
      ;
  }
  sensor.disableIndicator();

}

bool wait = true;
bool pressed = false;
int bState = 0;

void loop(){

  while (pressed == false) {
    bState = digitalRead(btn);
    if ((bState == HIGH) && (pressed == false)){
      Serial.println('b');
      pressed = true;
    }
  }

  while (wait) {
    if (Serial.available() > 0) {
      wait = false;
    }
  }

  sensor.takeMeasurementsWithBulb(); //This is a hard wait while all 18 channels are measured
  Serial.print(sensor.getCalibratedA()); //410nm
  Serial.print(",");
  Serial.print(sensor.getCalibratedB()); //435nm
  Serial.print(",");
  Serial.print(sensor.getCalibratedC()); //460nm
  Serial.print(",");
  Serial.print(sensor.getCalibratedD()); //485nm
  Serial.print(",");
  Serial.print(sensor.getCalibratedE()); //510nm
  Serial.print(",");
  Serial.print(sensor.getCalibratedF()); //535nm
  Serial.print(",");

  Serial.print(sensor.getCalibratedG()); //560nm
  Serial.print(",");
  Serial.print(sensor.getCalibratedH()); //585nm
  Serial.print(",");
  Serial.print(sensor.getCalibratedR()); //610nm
  Serial.print(",");
  Serial.print(sensor.getCalibratedI()); //645nm
  Serial.print(",");
  Serial.print(sensor.getCalibratedS()); //680nm
  Serial.print(",");
  Serial.print(sensor.getCalibratedJ()); //705nm
  Serial.print(",");

  Serial.print(sensor.getCalibratedT()); //730nm
  Serial.print(",");
  Serial.print(sensor.getCalibratedU()); //760nm
  Serial.print(",");
  Serial.print(sensor.getCalibratedV()); //810nm
  Serial.print(",");
  Serial.print(sensor.getCalibratedW()); //860nm
  Serial.print(",");
  Serial.print(sensor.getCalibratedK()); //900nm
  Serial.print(",");
  Serial.print(sensor.getCalibratedL()); //940nm
  Serial.println();
  wait = true;
  pressed = false;
  serialFlush();
}

The Uno is a 5v IO device, that board wants 3.3v…implement a logic level converter/shifter to interface 5v with 3.3v

A voltage divider would be fine for this, right? (I don’t have a proper logic level shifter.)

I added voltage dividers to shift the logic levels down to 3.3v, and this still isn’t working. I mean, the logic levels are correct, and my multimeter is reading 3.19 volts on SDA and the same on SCL. This is while running the I2C scanner script. The power and status lights are both on. Now, however, the I2C scanner is not detecting the board. Is it more likely an Arduino-side issue, or something with the sensor itself?

You said Ear it was working with the I2C scanner sketch, what changed since then?

Resistor dividers are slow but might be fast enough for the scanner and might fail with the app sketch. I recommend getting a logic level shifer board, that will be able to handle higher speeds.

Earlier, I had it on the default 5v logic for Arduino Uno, but now I have checked everything and brought it down to 3.3v.

Quick update: I tested a different I2C sensor (GY-521) and it worked, so I think the issue is probably with the AS7265x itself.

Has your problem been solved?

I have the same problem as you:

I use the Arduino mega2560 platform and use the example 1 given by SparkFun (Example1_BasicReadings: https://github.com/sparkfun/SparkFun_AS … adings.ino), which is displayed in the IDE serial port window:

Sensor does not appear to be connected. Please check wiring. Freezing…

I added the print value of value in the SparkFun_AS7265X.cpp file as shown in the figure below, where the arrow points. The small probability of value is 48 or 50, and the high probability is 0.

And if I press the reset button multiple times, there is a small probability that the sensor data can be obtained, but there is a high probability that the data cannot be obtained and the above error will be reported.

If your problem is solved, I hope you can share your solution with me.

add_code.png

hello, I need some more help: I bought a fresh sensor from the website as the old one didn’t even work with serial. I am trying to test with the example code. Now, it just prints

“AS7265x Spectral Triad Example”

and stops. I have switched to a logic level shifter as well.

Hello, I have gone down to just the sensor and the base code- example 1. However, it hangs at

if (sensor.begin() == true)

Can you please help?

After encountering the same problem using the ESP32-C6-MINI, I implemented a for loop to give the sensor some additional chances to initialize. This has solved the problem for me:

Serial.println("AS7265x Spectral Triad Example");

for (int j=0; j<15;)
    {
      sensor.begin();
      delay (50);

      if (sensor.begin()==true)
      j=50
      ;

      else
      {
        Serial.print("Sensor failed to initialize, retrying... ");
        Serial.print(j+1);  
        Serial.println("/15");

        j++;
      }
    }

I encountered the same issue using the Adafruit M4 Express (SAMD51)- adding the loop fixed the problem - took 12 attempts. Thanks kk7dci.

AS7265x Spectral Triad Example
Sensor failed to initialize, retrying… 1/15
Sensor failed to initialize, retrying… 2/15
Sensor failed to initialize, retrying… 3/15
Sensor failed to initialize, retrying… 4/15
Sensor failed to initialize, retrying… 5/15
Sensor failed to initialize, retrying… 6/15
Sensor failed to initialize, retrying… 7/15
Sensor failed to initialize, retrying… 8/15
Sensor failed to initialize, retrying… 9/15
Sensor failed to initialize, retrying… 10/15
Sensor failed to initialize, retrying… 11/15
Sensor failed to initialize, retrying… 12/15

1 Like

Glad that it worked for you.