Detecting nutrients with AS7265x

Hi,

Sorry to ask, but does anyone know how I can get this AS7265x connected to arduino uno to detect potassium. I used the following code, but I get errors.

#include <Wire.h> 
#include <SparkFun_AS7265X.h> 

AS7265X mySensor; 

void setup() { 
  Serial.begin(9600); 
  Wire.begin(); 
  if (
    mySensor.begin() == false) { 
      Serial.println("Sensor not detected!"); 
      while (1); } 
      Serial.println("Sensor online!"); } 
      
void loop() { 
    mySensor.takeMeasurements(); Serial.print("Calibrated value 1: "); 
    Serial.println(mySensor.getCalibratedValue(AS72651_NIR)); 
    Serial.print("Calibrated value 2: "); 
    Serial.println(mySensor.getCalibratedValue(AS72652_NIR)); 
    Serial.print("Calibrated value 3: "); 
    Serial.println(mySensor.getCalibratedValue(AS72653_NIR)); // Add more as needed for other spectral bands 
    
    delay(1000);

}

Great job on posting the code, add an annotated schematic showing exactly how you have connected everything. Be sure to include all power, ground and power sources.

Great job posting the code! To help us assist you further, please include an annotated schematic that shows exactly how everything is connected. Be sure to include all power, ground, and power sources in the schematic.

What errors are you getting?

What spectroscopic signature of potassium are you hoping to detect?

Since there are NO specific results showing in the data sheet for any specific material, that tells me you need to calibrate the device. Since you are going to look for potassium, you need to calibrate the device using potassium and then look for matching spectrum results when doing your test material.

Hi, sorry for the late reply, so much going one:

I got an error like this
error: 'class AS7265X' has no member named 'getCalibratedRed'; did you mean 'getCalibratedR'?

But just changed it to
Serial.println(Sensor.getCalibratedA()); and one error gone, so I know my senor is configured correctly and so I think you for the reply.

I am not sure this is the path to potassium or other nutrients, but feel a bit better.

Thanks, how do I do that with code?
I am literally just starting out and had a few months getting things wrong, so decided to ask as I didn't want to bother anyone before I had tried some other stuff.

The idea is to get nutrients and ffer better food advice to individuals, so if I can get one which I deduce is potassium at 766nm in the range of sensor 400nm to 940nm, I would then try sodium at 564nm. I've come to terms with the phrase, "this is not a sprint".

Are you attempting flame photometery?

Well, begin by telling us if your last chemistry class will give you access to material containing potassium. Sodium compounds you have in the house: table salt. Those materials will give you sources of specific metals for calibration and testing.

Not really.
Urine contains nutrients, so it’s possible to find them with wavelengths

Hi Paul,

I was hoping to find small traces of nutrients in urine.

But after calibration!

Indeed

So I managed to use the following code to calibrate the sensor:

#include <Wire.h> 
#include <SparkFun_AS7265X.h> 

AS7265X sensor; 

void setup() { 
  Serial.begin(9600); 
  Wire.begin(); 

// Initialize the sensor 
if (!sensor.begin()) { 
  Serial.println("Sensor not detected. Please check wiring."); 
  while (1); } 
  Serial.println("Sensor online!"); }

  //Once the sensor is started we can increase the I2C speed
  //#Wire.setClock(400000);

void loop() { 

// Take measurements 

// Read calibrated values for different spectral bands 

  sensor.takeMeasurements(); //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.print(",");

  Serial.println();

delay(1000); // Delay for 1 second before taking another measurement

}

The one here gives errors so I didn't use it, I did however buy a board:
SparkFun_AS7265x_Arduino_Library/examples/Example3_Settings/Example3_Settings.ino at main · sparkfun/SparkFun_AS7265x_Arduino_Library · GitHub

Once calibrated, how can I check these values ?

I did two tests, one with a white watch strap and my hand, here are the results.


This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.