Go Down

Topic: Problem with "APDS-9960 RGB and Gesture Sensor" interface (Read 723 times) previous topic - next topic

britto

Hi, I am working on gesture recognition sensor interface. I get communication error, and the error code is 2.

here is my code (Sample code in Arduino IDE).

 
#include <Wire.h>
#include "paj7620.h"

/*
Notice: When you want to recognize the Forward/Backward gestures, your gestures' reaction time must less than GES_ENTRY_TIME(0.8s).
        You also can adjust the reaction time according to the actual circumstance.
*/
#define GES_REACTION_TIME      500            // You can adjust the reaction time according to the actual circumstance.
#define GES_ENTRY_TIME         800            // When you want to recognize the Forward/Backward gestures, your gestures' reaction time must less than GES_ENTRY_TIME(0.8s).
#define GES_QUIT_TIME         1000

void setup()
{
   uint8_t error = 0;

   Serial.begin(9600);
   Serial.println("\nPAJ7620U2 TEST DEMO: Recognize 9 gestures.");

   error = paj7620Init();         // initialize Paj7620 registers
   if (error)
   {
      Serial.print("INIT ERROR,CODE:");
      Serial.println(error);
   }
   else
   {
      Serial.println("INIT OK");
   }
   Serial.println("Please input your gestures:\n");
}

void loop()
{
   uint8_t data = 0, data1 = 0, error;
   
   error = paj7620ReadReg(0x43, 1, &data);            // Read Bank_0_Reg_0x43/0x44 for gesture result.
   if (!error)
   {
      switch (data)                            // When different gestures be detected, the variable 'data' will be set to different values by paj7620ReadReg(0x43, 1, &data).
      {
         case GES_RIGHT_FLAG:
            delay(GES_ENTRY_TIME);
            paj7620ReadReg(0x43, 1, &data);
            if(data == GES_FORWARD_FLAG)
            {
               Serial.println("Forward");
               delay(GES_QUIT_TIME);
            }
            else if(data == GES_BACKWARD_FLAG)
            {
               Serial.println("Backward");
               delay(GES_QUIT_TIME);
            }
            else
            {
               Serial.println("Right");
            }         
            break;
         case GES_LEFT_FLAG:
            delay(GES_ENTRY_TIME);
            paj7620ReadReg(0x43, 1, &data);
            if(data == GES_FORWARD_FLAG)
            {
               Serial.println("Forward");
               delay(GES_QUIT_TIME);
            }
            else if(data == GES_BACKWARD_FLAG)
            {
               Serial.println("Backward");
               delay(GES_QUIT_TIME);
            }
            else
            {
               Serial.println("Left");
            }         
            break;
         case GES_UP_FLAG:
            delay(GES_ENTRY_TIME);
            paj7620ReadReg(0x43, 1, &data);
            if(data == GES_FORWARD_FLAG)
            {
               Serial.println("Forward");
               delay(GES_QUIT_TIME);
            }
            else if(data == GES_BACKWARD_FLAG)
            {
               Serial.println("Backward");
               delay(GES_QUIT_TIME);
            }
            else
            {
               Serial.println("Up");
            }         
            break;
         case GES_DOWN_FLAG:
            delay(GES_ENTRY_TIME);
            paj7620ReadReg(0x43, 1, &data);
            if(data == GES_FORWARD_FLAG)
            {
               Serial.println("Forward");
               delay(GES_QUIT_TIME);
            }
            else if(data == GES_BACKWARD_FLAG)
            {
               Serial.println("Backward");
               delay(GES_QUIT_TIME);
            }
            else
            {
               Serial.println("Down");
            }         
            break;
         case GES_FORWARD_FLAG:
            Serial.println("Forward");
            delay(GES_QUIT_TIME);
            break;
         case GES_BACKWARD_FLAG:       
            Serial.println("Backward");
            delay(GES_QUIT_TIME);
            break;
         case GES_CLOCKWISE_FLAG:
            Serial.println("Clockwise");
            break;
         case GES_COUNT_CLOCKWISE_FLAG:
            Serial.println("anti-clockwise");
            break; 
         default:
            paj7620ReadReg(0x44, 1, &data1);
            if (data1 == GES_WAVE_FLAG)
            {
               Serial.println("wave");
            }
            break;
      }
   }
   delay(100);
}

What can be wrong ? The module failure or I2c needs external pullup or any other communication problem ? Please suggest.

bos1714

Hello there!

I've had a good deal of experience with this sensor. And I have gotten similar errors. Can you make sure that all of the power and ground pins to the sensor are correctly wired and that the ground for the sensor and whatever Arduino you are using?

While you're at it. Can you post a picture of your schematic with all wiring as it can help solve problems.

Thanks
Time line? Time isn't made out of lines. It is made out of circles. That is why clocks are round.

britto

Hello there,

https://www.dx.com/p/produino-gy-apds9900-llc-apds-9900-rgb-and-gesture-sensor-module-i2c-breakout-for-arduino-2022955#.XCxBD2t95hF

This is the module, I am using.

Connected 4 pins to arduino Uno board.

Sensor side        Arduino side

Vin               -        3.3 V
Gnd              -        Gnd
SDA              -        SDA
SCL               -        SCL

pull up resistors are not connected.

bos1714

Sorry for the delay.

I see from the pictures in the link you posted that there is a 10k resistor array, and the SDA and SCL pins appear to be going to that and to the supply, which means those are the pull up resistors. It also means that unless you have pull-ups on the Uno, the interface itself should be working.

Is the code you posted the entire segment. There appears to be a function called paj7620Init() that is called at the beginning. This is most likely where the error shows up. Can you post the code of that function?
Time line? Time isn't made out of lines. It is made out of circles. That is why clocks are round.

britto

Thank you for your response.

As far as I know, paj7620Init() is an API that is used for register initialization, same as Serial.begin(9600) to initiate serial communication. It has to get handled internally.

And, You are correct, that is the function returns the transmission error.

bos1714

As far as I know, paj7620Init() is an API that is used for register initialization, same as Serial.begin(9600) to initiate serial communication. It has to get handled internally.
So by this do you mean that the code for this function cannot be seen? When you include the library, you are using quotation marks instead of carrots, which indicate that the code is in the same work directory as the .ino file. Can you post that code?
Time line? Time isn't made out of lines. It is made out of circles. That is why clocks are round.

Go Up