APDS Gesture Sensors Connecting Inconsistently

I’ve been working with APDS gesture sensors, primarily the Adafruit one, and I’m having trouble getting them to connect consistently. I’ll hook one up to a Photon or Argon using the code below and it will work fine. The next one that I hook up – nothing. The wiring, and the devices are the same. Is there a cache or something that I should be clearing, or something like that?

Thanks in advance!

// This #include statement was automatically added by the Particle IDE.
#include <APDS_Trigger.h>

// This #include statement was automatically added by the Particle IDE.
#include <SparkFun_APDS9960.h>

#include "APDS_Trigger.h"

//revision history
//040320 -- copied over from  APDS-GESTURE-TEST.ino
//040720 -- added "DIR_NONE" to gestures.
//040920 -- removed "DIR_NONE" -- it was generated 4 events on startup, and then no more. 

// location --> syntax = <LOCATION_CODE> Location IDs = CIC, TH
// keep one of these commented
#define LOCATION "CIC"
//#define LOCATION "TH"

// SEND_TO is LOCATION + BLOCK
#define SEND_TO "CICACTIONBLOCK"
//#define SEND_TO "THACTIONBLOCK"

// SEND_AS is LOCATION + BLOCK . This is for sending self-related info
#define SEND_AS "CICAPDSINFO"
//#define SEND_AS "THAPDSINFO"

const uint8_t gestures[] = {DIR_LEFT, DIR_RIGHT, DIR_UP, DIR_DOWN, DIR_NEAR, DIR_FAR};//removed DIR_NONE

class APDS : public APDS_Trigger
{
    public:
        APDS(){}
        ~APDS(){}
        void performAction() override
        {
            Serial.print("Approved gesture\n");
         Particle.publish(SEND_TO,"AUTO2",PRIVATE);
        // Particle.publish(SEND_TO,"PRINT",PRIVATE);
     // Particle.publish(SEND_TO,"DISPLAY",PRIVATE);
     // Particle.publish(SEND_TO,"AUTO0",PRIVATE);
      // Particle.publish(SEND_TO,"AUTO1",PRIVATE);
       // Particle.publish(SEND_TO,"AUTO3",PRIVATE);
        // Particle.publish(SEND_TO,"TONE",PRIVATE);
        }
};

APDS apds;

void setup()
{
   Serial.begin(115200);
// while(!Serial.isConnected()) Particle.process();
 Serial.println(apds.init(gestures, sizeof(gestures) / sizeof(uint8_t), true));
}

void loop()
{
    apds.update();
}

I wonder if the different chips are set for different default I2C addresses and only the ones where your calling the correct address work wile the others don’t?

Where are the sensors coming from?

I’ve seeing nothing abnormal with the ADPS sensor I have left running for days detecting distance & light levels.

It has been a while since I received a APDS9960 and tried it out.

I do remember thinking that the reliability of gesture detection was limited; it seemed to work well L to R but not so much top to bottom.

Looking at your code snippet - why are you including the same thing essentially 3 times?

Thanks RWB – I hadn’t thought about the 12C address idea.

The sensors are from Adafruit and DFRobot.

I’ve also had great reliability from the sensors once I get them running. But setting them up has been a crap shoot. That’s what’s mystifying me.

Thanks so much for weighing in!

Hi Armor, Thanks for the ideas.

I’ve also noticed that: all the APDS9960 chips seem to work best Left to Right.

I’ll get back to you on that code duplication.

Thanks again for the response!

Hi DC, nice to see you are still tinkering with Particle devices!
Since you mention that you have sensors from different vendors, perhaps @RWB is right and their default I2C address is not the same?

Have you tried by any chance the sample code DFrobot provides by any chance?

Cheers,
Gustavo.

PS: I just saw in the data sheet provided by dfrobot that the I2C address is always the same:

image

Hi Gustavo!

I’m going to look into that.

And, no, I wasn’t aware that DFrobot had sample code. Going to try that as well.

Do you think it makes sense to use the library from the same company as created the APDS9960 breakout board: in other words the Sparkfun library with the Sparkfun APDS9960 breakout board; Adafruit library with Adafruit APDS9960 board? Or doesn’t that really matter: it’s the same chip.

Thanks for the thoughtful tips!

Oh and Armor, now I think I know what you meant by the code duplication: I’m using these in a few different locations around the Boston area. I don’t want them triggering each other.

Does that explain it?

I would go with the most popular first, then try the others.
This is from Particle Build:

image

Good advice. And thanks for the research: 0x39 it is. That removes one variable!

I think I’ve resolved it! Someone at Cambridge Hackspace suggested double checking the supply and grounds. So I chucked the breadboard and directly connected the apds9960s to the Photons and Argons. And they all seem to be working fine now. That was surprising to me, because I thought that breadboards were generally reliable. And I could feel the jumper wires scratching the connective layer below. But now I’ll always be aware that they can introduce some variation.
Thanks everybody for the help!

1 Like

On some breadboards the supply rails are not connected all the way through but may have a gap at the middle of the board (usually indicated by broken red/blue lines)

2 Likes

great to hear, DC!!!

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