I am currently using a SparkFun AS7265X spectral sensor, using an Adafruit Feather esp32s3 board to get data from the sensor over I2C. My goal is to get the data as close to real-time as possible, but the read rate is much slower than I need. I have tried setting the integration cycles to a lower value, but for some reason, it actually makes the read rate slower. I have also tried a different sensor of the same type, but it yeilded the same results. I am creating an object in my code that contains a method to read the data, and setup the sensor. The setup code is being ran in setup(), and the sensor readd method is being ran in loop(). No other configuration for the sensor is being done in setup() or loop(), just calling the methods. Below is the code that I have:
Setup code
void setupSensor()
{
while (sensor.begin() == false)
Serial.println("Sensor does not appear to be connected. Please check wiring. Freezing...");
sensor.setMeasurementMode(AS7265X_MEASUREMENT_MODE_6CHAN_CONTINUOUS); // Continuous measurements
sensor.disableIndicator();
//sensor.setIntegrationCycles(5);
Wire.setClock(400000);
Wire.begin();
if (this->LEDsOn == true)
{
// Turn on LED bulbs
this->sensor.enableBulb(AS7265x_LED_WHITE);
this->sensor.enableBulb(AS7265x_LED_IR);
this->sensor.enableBulb(AS7265x_LED_UV);
}
}
Read code
void scanAllChannels(bool calibrated = false)
{
// Check if calibrated readings are set to true or not
if (calibrated == false)
{
this->channelValues[0] = sensor.getA(); // Get the channel reading
}
else if (calibrated == true)
{
this->channelValues[0] = sensor.getCalibratedA();
}
}
Any help getting this working is greatly appreciated!