Skip to main content
added 2560 characters in body
Source Link

UPDATE 3

So far, I applied the option or removing and replacing teh Delay() with a timer loop. But I am getting 0 readings. It looks possibly a problem with the way the variable have been set up. Here is the updated code. BUT only returns 0 readings.

Here is the SKETCH

    #include <Wire.h>
#include "Adafruit_AS726x.h"
//create the object
Adafruit_AS726x ams;
//buffer para leer valores en bruto
uint16_t sensorValues[AS726x_NUM_CHANNELS];
//buffer para  guardar los valores calibrados( no esta siendo utilizado en este codigo)
//float calibratedValues[AS726x_NUM_CHANNELS];


void setup() {
  Serial.begin(115200);

  while (!Serial)
    ;

  // inicializa el pin digital LED_BUILTIN como un output.
  pinMode(LED_BUILTIN, OUTPUT);

  //inicia y permite la comunicacion con el sensor
  if (!ams.begin()) {
    Serial.println("could not connect to sensor! Please check your wiring.");
    while (1)
      ;
  }
}

void loop() {

  //lee la temperatura del sensor
  //uint8_t temp = ams.readTemperature();

  //ams.drvOn(); // descomentar esto si quieres usar el led del sensor para hacer medidas
  ams.startMeasurement();  //begin a measurement

  //permite que el sensor lea la data cuando este disponible
  bool rdy = false;
  while (!rdy) {
    delay(5);
    rdy = ams.dataReady();
  }
  //ams.drvOff(); //descomentar esto si quieres usar el led del sensor para hacer medidas

  //lee los valores!
  ams.readRawValues(sensorValues);
  //ams.readCalibratedValues(calibratedValues);

  //Serial.print("{");
  //Serial.print("Temp: ");
  //Serial.print(temp);
  //Serial.print(",");
  //Serial.print(" Violet: ");
  Serial.print(sensorValues[AS726x_VIOLET]);
  Serial.print(",");
  //Serial.print(" Blue: ");
  Serial.print(sensorValues[AS726x_BLUE]);
  Serial.print(",");
  //Serial.print(" Green: ");
  Serial.print(sensorValues[AS726x_GREEN]);
  Serial.print(",");
  //Serial.print(" Yellow: ");
  Serial.print(sensorValues[AS726x_YELLOW]);
  Serial.print(",");
  //Serial.print(" Orange: ");
  Serial.print(sensorValues[AS726x_ORANGE]);
  Serial.print(",");
  //Serial.print(" Red: ");
  Serial.print(sensorValues[AS726x_RED]);
  //Serial.print("}");

  Serial.println();
  ;
}

UPDATE 3

So far, I applied the option or removing and replacing teh Delay() with a timer loop. But I am getting 0 readings. It looks possibly a problem with the way the variable have been set up. Here is the updated code. BUT only returns 0 readings.

Here is the SKETCH

    #include <Wire.h>
#include "Adafruit_AS726x.h"
//create the object
Adafruit_AS726x ams;
//buffer para leer valores en bruto
uint16_t sensorValues[AS726x_NUM_CHANNELS];
//buffer para  guardar los valores calibrados( no esta siendo utilizado en este codigo)
//float calibratedValues[AS726x_NUM_CHANNELS];


void setup() {
  Serial.begin(115200);

  while (!Serial)
    ;

  // inicializa el pin digital LED_BUILTIN como un output.
  pinMode(LED_BUILTIN, OUTPUT);

  //inicia y permite la comunicacion con el sensor
  if (!ams.begin()) {
    Serial.println("could not connect to sensor! Please check your wiring.");
    while (1)
      ;
  }
}

void loop() {

  //lee la temperatura del sensor
  //uint8_t temp = ams.readTemperature();

  //ams.drvOn(); // descomentar esto si quieres usar el led del sensor para hacer medidas
  ams.startMeasurement();  //begin a measurement

  //permite que el sensor lea la data cuando este disponible
  bool rdy = false;
  while (!rdy) {
    delay(5);
    rdy = ams.dataReady();
  }
  //ams.drvOff(); //descomentar esto si quieres usar el led del sensor para hacer medidas

  //lee los valores!
  ams.readRawValues(sensorValues);
  //ams.readCalibratedValues(calibratedValues);

  //Serial.print("{");
  //Serial.print("Temp: ");
  //Serial.print(temp);
  //Serial.print(",");
  //Serial.print(" Violet: ");
  Serial.print(sensorValues[AS726x_VIOLET]);
  Serial.print(",");
  //Serial.print(" Blue: ");
  Serial.print(sensorValues[AS726x_BLUE]);
  Serial.print(",");
  //Serial.print(" Green: ");
  Serial.print(sensorValues[AS726x_GREEN]);
  Serial.print(",");
  //Serial.print(" Yellow: ");
  Serial.print(sensorValues[AS726x_YELLOW]);
  Serial.print(",");
  //Serial.print(" Orange: ");
  Serial.print(sensorValues[AS726x_ORANGE]);
  Serial.print(",");
  //Serial.print(" Red: ");
  Serial.print(sensorValues[AS726x_RED]);
  //Serial.print("}");

  Serial.println();
  ;
}
Solution from me
Source Link

I am still having problemns with the serial. I ented the run with CNTL+c then restarted teh otebook. I am getting failure.

I am still having problemns with the serial. I ented the run with CNTL+c then restarted teh otebook. I am getting failure.

Solution from me
Source Link

Follow-up Update 2:

So, found out that the problem had nothing to do with the code, but with Mathematica. Was running version 11.2 . I first mover the rawReadings = {} line to before the parseData function. There , I noticed that the serial port pick up 7 and 8 dataset. Give me the idea that maybe potentially a problem with the compilation.

I upgraded to WM version 13.1 and the Dynamic is picking up with a continuous readings.

Follow-up Update 2:

So, found out that the problem had nothing to do with the code, but with Mathematica. Was running version 11.2 . I first mover the rawReadings = {} line to before the parseData function. There , I noticed that the serial port pick up 7 and 8 dataset. Give me the idea that maybe potentially a problem with the compilation.

I upgraded to WM version 13.1 and the Dynamic is picking up with a continuous readings.

added 333 characters in body
Source Link
Loading
Missing the Arduino code
Source Link
Loading
Source Link
Loading