sparkfun / apds-9960_rgb_and_gesture_sensor Goto Github PK
View Code? Open in Web Editor NEWBreakout board for the Avago APDS-9960 proximity, light, RGB, and gesture sensor, made by SparkFun Electronics.
License: Other
Breakout board for the Avago APDS-9960 proximity, light, RGB, and gesture sensor, made by SparkFun Electronics.
License: Other
Hi, When I connect APDS-9960 to my arduino uno and run GestureTest example, In init process, I always get 0x9F, when read value from APDS9960_ID register, what's wrong with it
Please delete this issue. I cannot do it by myself.
I have downloaded the files from, here, the code seems to be running, on uploading the sketch to the arduino the code shows running but the gesture sensor is not detecting any gesture, on the other hand the proximity detection and ambiance light color detection works perfectly fine. Kindly help!
I connect vcc to 3.3V, SDA to A4, SCL to A5. BUt when i try to run proximitysensor.ino in my serial monitor i have only this:
SparkFun APDS-9960 - ProximitySensor
and nothing else... how i can fix it ??
In the file "APDS-9960_RGB_and_Gesture_Sensor/Libraries/Arduino/APDS-9960_RGB_and_Gesture_Sensor_Arduino_Library/src/SparkFun_APDS9960.cpp", the function "wireWriteDataBlock()" is not used, but it contains a bug.
The sequence should be: beginTransmission - write - write -write - endTransmission
However, instead of writing data, a Wire.beginTransmission() is called (multiple) times.
At the moment it is at line 2152.
I'm using a glass cover (90% IR transmittance) on top of the sensor. Because of this there's always data in the FIFO and it's stuck in this if statement -
if( (gstatus & APDS9960_GVALID) == APDS9960_GVALID ) {
.......}
From what I understood, the FIFO becomes empty after the gesture is completed and then it enters this else statement -
else {
/* Determine best guessed gesture and clean up */
delay(FIFO_PAUSE_TIME);
decodeGesture();
motion = gesture_motion_;
#if DEBUG
Serial.print("END: ");
Serial.println(gesture_motion_);
#endif
resetGestureParameters();
return motion;
}
and the final gesture is determined. So the gesture is not being detected because it never enters this else statement. How can I solve this problem? Thanks!
Hi,
I am facing a weird kind of problem. Int pin is not issuing interrupt some times. I have tried with almost 5 to 6 modules. what could be cause of error?
Here is snippet of code
// Initialize APDS-9960 (configure I2C and initial values)
if (apds.init()) {
printf("APDS-9960 initialization complete\n");
} else {
printf("Something went wrong during APDS-9960 init!\n");
}
// Adjust the Proximity sensor gain
if (!apds.setProximityGain(PGAIN_8X)) {
printf("Something went wrong trying to set PGAIN\n");
}
// Set proximity interrupt thresholds
if (!apds.setProximityIntLowThreshold(PROX_INT_LOW)) {
printf("Error writing low threshold\n");
}
if (!apds.setProximityIntHighThreshold(PROX_INT_HIGH)) {
printf("Error writing high threshold\n");
}
// Start running the APDS-9960 proximity sensor (with interrupts)
if (apds.enableProximitySensor(true)) {
printf("Proximity sensor is now running in Interrupt mode\n");
} else {
printf("Something went wrong during sensor init!\n");
}
while (1) { // Read the proximity value
if (!apds.readProximity(proximity_data)) {
printf("Error reading proximity value\n");
} else {
printf("Proximity: %u\n", proximity_data);
}
if(!apds.clearProximityInt()){
printf("Error in clearing Interrupt \n");
}
}
I want to use Sourcegraph for APDS-9960_RGB_and_Gesture_Sensor code search, browsing, and usage examples. Can an admin enable Sourcegraph for this repository? Just go to https://sourcegraph.com/github.com/sparkfun/APDS-9960_RGB_and_Gesture_Sensor. (It should only take 30 seconds.)
Thank you!
i am using the following sketch to copy color to RGB LED using APDS9960 RGB sensor.
the sketch was uploaded successfully, but the LED is not working when color is put in front of the sensor!
#include <Wire.h>
#include "Adafruit_APDS9960.h"
Adafruit_APDS9960 apds;
#define redpin 3
#define greenpin 5
#define bluepin 6
#define commonAnode false
byte gammatable[256];
void setup() {
Serial.begin(9600);
Serial.println("Color View Test!");
if (apds.begin()) {
Serial.println("Found sensor");
} else {
Serial.println("No TCS34725 found ... check your connections");
while (1); // halt!
}
pinMode(redpin, OUTPUT);
pinMode(greenpin, OUTPUT);
pinMode(bluepin, OUTPUT);
for (int i=0; i<256; i++) {
float x = i;
x /= 255;
x = pow(x, 2.5);
x *= 255;
if (commonAnode) {
gammatable[i] = 255 - x;
} else {
gammatable[i] = x;
}
//Serial.println(gammatable[i]);
}
}
void loop() {
//create some variables to store the color data in
uint16_t clear, red, green, blue;
//wait for color data to be ready
while(!apds.colorDataReady()){
delay(5);
}
//get the data and print the different channels
apds.getColorData(&red, &green, &blue, &clear);
Serial.print("red: ");
Serial.print(red);
Serial.print(" green: ");
Serial.print(green);
Serial.print(" blue: ");
Serial.print(blue);
Serial.print(" clear: ");
Serial.println(clear);
Serial.println();
delay(1000);
// Figure out some basic hex code for visualization
uint32_t sum = clear;
float r, g, b;
r = red; r /= sum;
g = green; g /= sum;
b = blue; b /= sum;
red *= 256; green *= 256; blue *= 256;
Serial.print("\t");
Serial.print((int)r, HEX); Serial.print((int)g, HEX); Serial.print((int)b, HEX);
Serial.println();
analogWrite(redpin, gammatable[(int)r]);
analogWrite(greenpin, gammatable[(int)g]);
analogWrite(bluepin, gammatable[(int)b]);
}
Hi,
How can I use in same time all sensors: color sensor, gesture senor and proximity sensor?
Changing the PGAIN value in line 61 in the example ProximitySensor.ino has no effect. This is because the enableProximitySensor function (line 66) sets the DEFAULT_PGAIN. Therefore PGAIN changes through setProximityGain needs to be done after enabling the sensor.
I tried to use the library on esp8266, but it was constantly rebooting....
On a wemos mini I think I am getting INT lockups for the gesture sensor.
I am still getting brightness readings over i2c ok.
It seems like the swipe works good for the first 15-30 swipes but then will stop working, or if I leave it running overnight in the morning the gesture sensor no longer activates.
I put a 2 second timeout in the apds.readGesture() function to try an avoid lockups if an object gets placed in front of the sensor but that didnt help.
Everything is hooked up ok to my Arduino Uno, but then when the program is run it seems to freeze at the following statement (breakpoint B isn't executed). What could be the problem?
--from init method--
/* Read ID register and check against known values for APDS-9960 */
if( !wireReadDataByte(APDS9960_ID, id) ) {
Serial.println("breakpoint B");
return false;
}
I have this in my setup():
// Initialize interrupt service routine
attachInterrupt(0, interruptRoutine, FALLING);
// Initialize APDS-9960 (configure I2C and initial values)
if ( apds.init() ) {
Serial.println(F("APDS-9960 initialization complete"));
} else {
Serial.println(F("Something went wrong during APDS-9960 init!"));
}
// Adjust the Proximity sensor gain
if ( !apds.setProximityGain(PGAIN_2X) ) {
Serial.println(F("Something went wrong trying to set PGAIN"));
}
// Start running the APDS-9960 proximity sensor (no interrupts)
if ( apds.enableProximitySensor(false) ) {
Serial.println(F("Proximity sensor is now running"));
} else {
Serial.println(F("Something went wrong during sensor init!"));
}
// Start running the APDS-9960 gesture sensor engine
if ( apds.enableGestureSensor(true) ) {
Serial.println(F("Gesture sensor is now running"));
} else {
Serial.println(F("Something went wrong during gesture sensor init!"));
}
And the values from the proximity are either 41 or below 10, but if I remove the if ( apds.enableGestureSensor(true) ) {...
then it works well with values between 0 and 255.
How can I make both of those features to work well together?
Hi,
The example "GestureTest" doesn't work (For hardware compatibility ) :
because interrupt management is not correct :
attachInterrupt(0, interruptRoutine, FALLING);
must be
attachInterrupt(APDS9960_INT, interruptRoutine, FALLING);
and loop() must be :
void loop() {
if( isr_flag == 1 ) {
detachInterrupt(APDS9960_INT);
handleGesture();
isr_flag = 0;
attachInterrupt(APDS9960_INT, interruptRoutine, FALLING);
}
}
I run the Colorsensor example ,but the value read form it is more then 255,it's very big.
What the data mean read from the color sensor.isn't it mean the RGB vlue in ambient light?
Who can tell me the answer?
Very strange, i bought such a sensor and also a bidirectional converter. But if i use this, the demo gesture sketch tells me that the sensor could not be initialized. I measured the voltages and can confirm the levelconverter works correct. On APDS-Side it uses 3.3V for SCA,SCL and also INT (i know it's not necessary, but so what the board has 4 converters on it) and on the Arduino Uno side 5V for logic level.
Now, after playing around for a while a decided to test the signals (! NOT Vcc, for shure!) without the converter, hence i know it possible kill my sensor... But for some reason it then works! I'm confused. Checked everything double, test again, but it is that way: using a converter -> no chance. without it -> all right.
Can somebody clearify this? The sensor is the simple one, without any extra logic on board. Just the cap and the pullups.
Can you please give me a hint, what the color sense (RGB feature) does?
I tried it but somehow the results aren't consistent
It always shows almost equal amounts of R G and B about 1/3 of the total ambient light
I tried to put the sensor in front of something Blue or Green or Red, but nothing changed too drasticaly.
Is this the feature or does it do something else ?
bool disableProximitySensor() function is not implemented, calling it results in compile error. See line 342 of SparkFun_APDS9960.cpp.
The following function definition should give it the proper functionality.
/**
this statement is always false since uint8_t cannot be negative in any circumstances.
I have bought an apds9960 sensor and attached it to my MKR1000 board. The library is saying initialization complete but then proximity readings are always 0. the Color Sensor and Ambient light examples are working but the readings of green and blue are wrong (-1, 0). What could be the problem? thanks.
I was thinking is a problem with the IR led.
Hello,
I have translated the file "SparkFun_APDS9960.cpp" with a very niggling compiler and found some little warnings "comparison is always true" and "comparison is always false":
First warning:
bool SparkFun_APDS9960::setMode(uint8_t mode, uint8_t enable)
.. /* Change bit(s) in ENABLE register */
enable = enable & 0x01;
if( mode >= 0 && mode <= 6 ) {
-> My suggestion:
bool SparkFun_APDS9960::setMode(uint8_t mode, uint8_t enable)
.. /* Change bit(s) in ENABLE register */
enable = enable & 0x01;
if(mode <= 6 ) {
Second warning:
int SparkFun_APDS9960::readGesture()
{
uint8_t fifo_level = 0;
uint8_t bytes_read = 0;
...
if( bytes_read == -1 ) {
return ERROR;
}
-> My suggestion:
int SparkFun_APDS9960::readGesture()
{
uint8_t fifo_level = 0;
int8_t bytes_read = 0; //not uint8_t
With my changes the code is a little bit easier.
The version now in the Arduino Library Manager is 1.4.2 of the SparkFun APDS9960 RGB and Gesture Sensor Arduino Library repo. It cannot accept the device id of 0xA8. Would you please update the verion in the Arduino Library Manager? Thanks.
I've set GFIFOTH to trigger an interrupt when the fifolevel is greater than 8 datasets. In the interrupt handler I read the U,L,D,R registers until GFLVL is zero within a while loop and stored the values into an array, so that I can compare the initial and final values to decode my gesture. But I have been getting values such as 255 in the registers. Following are the values I obtained while debugging, the first time it went to the interrupt handler when I waved my hand from left to right.
U int[100] [19, 35, 65, 125, 216, 255, 255, 255, 255, 255, 255, 255, 255, 244, 34, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...]
D int[100] [20, 38, 70, 122, 197, 255, 255, 255, 255, 255, 255, 255, 255, 168, 27, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...]
L int[100] [7, 9, 19, 34, 70, 138, 255, 255, 255, 255, 255, 255, 255, 255, 39, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...]
R int[100] [39, 63, 117, 200, 255, 255, 255, 255, 255, 255, 255, 255, 255, 53, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...]
With values such as this I'm totally out of range and I can't properly decode the gestures. Any ideas why this is happening?
Hi,
there is a problem in the gestur recognition if you deactivate one pair of the photodiodes via the
"Gesture Configuration Three Register (0xAA)" register.
If one gesture dimension is switched off the complete recognition does not work anymore. It always returns NONE.
A quick fix seems to be by commenting out the lines 816-820 and changing the AND (&&) in line 803 and 836 into a OR (||).
Tested with v1.1.5 of https://github.com/SpenceKonde/ATTinyCore
Arduino Uno works with level converters
Attiny85 works when using 3.3v and 5v w/ level converter.
Attiny84 and Attiny841 do not work at 3.3v or at 5v w/ level converter.
Attiny84(1) do work with color sense examples.
I seem to be getting the following error when compiling on ESP8266 (NodeMCU 1.0).
What's also weird is that the ESP8266WiFi "-" error only appears when I utilize your library. If I'm using the Adafruit one, everything works properly (but I'd like to use yours).
The errors appear even when the sketch is completely empty (only utilizing your library), so even though I hope it's an issue on my side, I doubt it is.
`/Users/user/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/libraries/ESP8266WiFi/src/include/wl_definitions.h:46:18: error: expected identifier before '-' token
#define NA_STATE -1
^
/Users/user/Documents/Arduino/libraries/SparkFun_APDS9960_RGB_and_Gesture_Sensor/src/SparkFun_APDS9960.h:198:3: note: in expansion of macro 'NA_STATE'
NA_STATE,
^
/Users/user/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/libraries/ESP8266WiFi/src/include/wl_definitions.h:46:18: error: expected '}' before '-' token
#define NA_STATE -1
^
/Users/user/Documents/Arduino/libraries/SparkFun_APDS9960_RGB_and_Gesture_Sensor/src/SparkFun_APDS9960.h:198:3: note: in expansion of macro 'NA_STATE'
NA_STATE,
^
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.