Artemis Nano with AS7263 spectral sensor does not return any readings.

I have a Artemis Nano and try to get readings from a AS7263 spectral sensor.

The sensor is connected with a Qwiic cable. The sensor is detected successfully but the first call to takeMeasurementsWithBulb() does not return. The bulb on the sensor turns on but does not turn off. For details please see the code below.

I have tested the same setup with a Thing Plus board and that works without problems.

Another thing that worries me is that when I connect a terminal to the serial port to check the output it looks like the board resets and restarts the code!

Here is the code I’m running:

Moderator edit to add code tags.

#include "AS726X.h"

AS726X sensor;

byte GAIN = 2;
byte MEASUREMENT_MODE = 3;
bool sensor_initialized = false;

void setup() {
  Wire.begin();
  Serial.begin(115200);
  pinMode(LED_BUILTIN, OUTPUT);
  sensor_initialized = sensor.begin(Wire, GAIN, MEASUREMENT_MODE);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000);

  if (sensor_initialized) {
    Serial.println("Starting reading");
    unsigned long start_time = millis();
    sensor.takeMeasurementsWithBulb();
    unsigned long duration= millis() - start_time;
    Serial.print("Reading: R[");
    Serial.print(sensor.getCalibratedR(), 2);
    Serial.print("] S[");
    Serial.print(sensor.getCalibratedS(), 2);
    Serial.print("] T[");
    Serial.print(sensor.getCalibratedT(), 2);
    Serial.print("] U[");
    Serial.print(sensor.getCalibratedU(), 2);
    Serial.print("] V[");
    Serial.print(sensor.getCalibratedV(), 2);
    Serial.print("] W[");
    Serial.print(sensor.getCalibratedW(), 2);
    Serial.print("] ");
    Serial.print(duration);
    Serial.print(" ms");    
    Serial.println();
  }
  else {
      Serial.println("Sensor not initialized");
  }
}

Hi asprenger – I must have missed this message, sorry!

This definitely sounds like some behavior that should be investigated more closely because AFAIK the I2C library is working as expected. I will ask one of our Tech Support members to try to reproduce the problem.

Also the board does reset when the serial monitor is opened – this is a fairly standard Arduino feature. It enables UART bootloaders to work automatically. It is possible, however, to establish a serial connection without resetting the board in several ways. Here are two:

  1. Use ‘Serial1’ and an external USB-serial adapter, and only connext the TX, RX, and GND lines (the DTR, RTS, and other control lines are used to reset the board so not connecting them will prevent it)

  2. Use a terminal program that gives you control over the state of the control lines at all times - choosing the right settings would prevent the reset. (Python’s pyserial module should allow you to do this in code if you prefer)

Hi asprenger,

I have no issues running any of the examples from the [Arduino Library with an Artemis development board so I would recommend going back to those and comparing the examples to your custom code to identify the issue. I am afraid we cannot help debug your custom code.

If you have issues running any of the examples on your Artemis, let us know and we would be happy to help troubleshoot.](GitHub - sparkfun/SparkFun_AS7265x_Arduino_Library: An Arduino library for the trifecta of spectral sensors covering 18 discrete wavelengths from NIR to UV.)

Thanks for your help, but you have probably tested with the wrong sensor. You have sent me a link to the AS7265x library but I have the problem with a AS7263 NIR (https://www.sparkfun.com/products/14351), as I have stated in the message subject.

I have installed the SparkFun AS726X library in Arduino IDE and just tried all 3 provided examples, none of them produces any output on the serial monitor. I have cross checked the 3 examples with the same sensor on a Thing Plus and they worked. Well actually the Example3 did not work because it initializes Wire and Serial inside the loop, this initialization must be moved to the setup method.

Please check again if you can reproduce the problem with the correct sensor.

Hi again,

Ah, my mistake. Thanks for clarifying which sensor you’re using. I am afraid the current version of the AS726X Arduino library is incompatible with Artemis. This is a [known issue and we are working on a revision of the library that should fix some other minor problems as well as get it working with the Artemis core. Unfortunately, we do not have an estimate on when that will be completed. If you want to keep track of when the fix is live, that issue I linked above will be updated and closed out once we get this library up and running with Artemis.](Incompatible with Artemis · Issue #4 · sparkfun/Qwiic_Spectral_Sensor_AS726X · GitHub)

Is this issue solved? I’m planning to buy an Artemis to work with AS7263. I would be happy to know the status before buying Artemis!