AS7262 Visible spectral sensor but I just need the Red

For the discussion of Arduino related topics.

Moderator: phalanx

Post Reply
programmer1200
Posts: 1
Joined: Mon Jan 14, 2019 1:20 pm

AS7262 Visible spectral sensor but I just need the Red

Post by programmer1200 » Mon Jan 14, 2019 1:48 pm

I'm attempting to retrieve only the red wavelength data off of the AS7262 Visible spectral sensor but not having the greatest luck modifying the sample code. Sample code 1 gives you a list of different functions that can be implemented and one of those include "int getRed();" but I cant figure out how to implement this into the existing sample . Thank you for the help
----------------------------------------------------------------------------------------------------------------------------------------
/*
This is a library written for the AS726X Spectral Sensor (Visible or IR) with I2C firmware
specially loaded. SparkFun sells these at its website: www.sparkfun.com
Written by Nathan Seidle & Andrew England @ SparkFun Electronics, July 12th, 2017
https://github.com/sparkfun/Qwiic_Spect ... sor_AS726X
Do you like this library? Help support SparkFun. Buy a board!
Development environment specifics:
Arduino IDE 1.8.1
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
---AVAILABLE FUNCTIONS---
AS726X(TwoWire &wirePort = Wire, byte gain = 3, byte measurementMode = 3);
void takeMeasurements();
void takeMeasurementsWithBulb();
void printMeasurements();
byte getTemperature();
float getTemperatureF();
void setMeasurementMode(byte mode);
boolean dataAvailable();
void enableIndicator();
void disableIndicator();
void setIndicatorCurrent(byte current);
void enableBulb();
void disableBulb();
void setBulbCurrent(byte current);
void softReset();
void setGain(byte gain);
void setIntegrationTime(byte integrationValue);
void enableInterrupt();
void disableInterrupt();
//Get the various color readings
int getViolet();
int getBlue();
int getGreen();
int getYellow();
int getOrange();
int getRed();
//Get the various NIR readings
int getR();
int getS();
int getT();
int getU();
int getV();
int getW();
//Returns the various calibration data
float getCalibratedViolet();
float getCalibratedBlue();
float getCalibratedGreen();
float getCalibratedYellow();
float getCalibratedOrange();
float getCalibratedRed();
float getCalibratedR();
float getCalibratedS();
float getCalibratedT();
float getCalibratedU();
float getCalibratedV();
float getCalibratedW();
*/

#include "AS726X.h"

AS726X sensor;

void setup() {
sensor.begin();
}

void loop() {
sensor.takeMeasurements();
sensor.printMeasurements();
}
------------------------------------------------------------------------------------------------------------

millercommamatt
Posts: 13
Joined: Tue Jul 24, 2018 10:53 am

Re: AS7262 Visible spectral sensor but I just need the Red

Post by millercommamatt » Wed Jan 23, 2019 1:54 pm

It looks like the printMeasurements function prints everything. Has that worked for you?

You can try something like Serial.println(sensor.getRed());

User avatar
CircuitSmarts
Posts: 13
Joined: Wed Jan 30, 2019 8:42 am

Re: AS7262 Visible spectral sensor but I just need the Red

Post by CircuitSmarts » Sat Feb 09, 2019 7:15 am

programmer1200 wrote:
Mon Jan 14, 2019 1:48 pm
I'm attempting to retrieve only the red wavelength data off of the AS7262 Visible spectral sensor but not having the greatest luck modifying the sample code. Sample code 1 gives you a list of different functions that can be implemented and one of those include "int getRed();" but I cant figure out how to implement this into the existing sample . Thank you for the help
----------------------------------------------------------------------------------------------------------------------------------------
/*
This is a library written for the AS726X Spectral Sensor (Visible or IR) with I2C firmware
specially loaded. SparkFun sells these at its website: www.sparkfun.com
Written by Nathan Seidle & Andrew England @ SparkFun Electronics, July 12th, 2017
https://github.com/sparkfun/Qwiic_Spect ... sor_AS726X
Do you like this library? Help support SparkFun. Buy a board!
Development environment specifics:
Arduino IDE 1.8.1
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
---AVAILABLE FUNCTIONS---
AS726X(TwoWire &wirePort = Wire, byte gain = 3, byte measurementMode = 3);
void takeMeasurements();
void takeMeasurementsWithBulb();
void printMeasurements();
byte getTemperature();
float getTemperatureF();
void setMeasurementMode(byte mode);
boolean dataAvailable();
void enableIndicator();
void disableIndicator();
void setIndicatorCurrent(byte current);
void enableBulb();
void disableBulb();
void setBulbCurrent(byte current);
void softReset();
void setGain(byte gain);
void setIntegrationTime(byte integrationValue);
void enableInterrupt();
void disableInterrupt();
//Get the various color readings
int getViolet();
int getBlue();
int getGreen();
int getYellow();
int getOrange();
int getRed();
//Get the various NIR readings
int getR();
int getS();
int getT();
int getU();
int getV();
int getW();
//Returns the various calibration data
float getCalibratedViolet();
float getCalibratedBlue();
float getCalibratedGreen();
float getCalibratedYellow();
float getCalibratedOrange();
float getCalibratedRed();
float getCalibratedR();
float getCalibratedS();
float getCalibratedT();
float getCalibratedU();
float getCalibratedV();
float getCalibratedW();
*/

#include "AS726X.h"

AS726X sensor;

void setup() {
sensor.begin();
}

void loop() {
sensor.takeMeasurements();
sensor.printMeasurements();
}
------------------------------------------------------------------------------------------------------------
Hi,

The simplest way of doing is:

Code: Select all

#include "AS726X.h"

AS726X sensor;

int redColor =0;

void setup() {
  sensor.begin();
}

void loop() {
redColor = getRed();
Serial.println(redColor);
  sensor.takeMeasurements();
  sensor.printMeasurements();
}

Arduino starter kits help get small developers dreaming big
https://designnotes.com/

Post Reply