APDS 9960 gesture recognition works on UNO, but doesn't on NANO

So I'm experiencing weirdest thing. I'm using Sparkfun APDS-9960 library and GestureTest to test out the module.

In my project, I want to use NANO and APDS-9960. But for some reason only the gesture example doesn't work on my NANO while it works on UNO. Every other sketch works on both of my boards.

On NANO it inits and starts the gesture engine, but it doesn't recognize anything.

Is there a way to troubleshoot it?

Edit:

After some tinkering there is problem with readgesture method, this is how it looks.

Init passes,
engine start passes,
right after engine start ISR gets triggered, even though nothing is in front of sensor
isGestureAvailable is triggered successfully (even though there is nothing to sense)
and then it gets stuck in readgesture method.

As the processor on both boards is the same I guess a wiring problem is responsible for this. Please provide a wiring diagram for both setups.

It’s not wiring problem, on both boards all the sketches (except the gesture one) work.

When I switch the boards I only plug in cables into extensions so no connections are changed.

But since you insist…

all connections from APDS go from itself to bi directional LLC.

Black - GND, Red - 5v, Maroon - 3v3, Green - SCL, Yellow - SDA, Orange - interrupt

I was looking around the source code and saw debug flag so I ran it,
this is on UNO: APDS-9960 Debug, valid - Pastebin.com
and this is on NANO: APDS-9960 Debug, invalid - Pastebin.com

NANO doesn't escape the while(1) look in getGesture

Uno can put out 150mA of 3.3V current, Nano only 50mA.
Measure the 3.3V line on the Nano and see if it's drooping, indicating a lack of current.

CrossRoads:
Uno can put out 150mA of 3.3V current, Nano only 50mA.
Measure the 3.3V line on the Nano and see if it's drooping, indicating a lack of current.

It's in spec, I measured 34mA with my multimeter. In library it states:

* APDS-9960 current draw tests (default parameters):
 *   Off:                   1mA
 *   Waiting for gesture:   14mA
 *   Gesture in progress:   35mA

I'm also using the I/O expansion shield that has dedicated AMS-1117 3v3 regulator. Power is not the problem. Every other example works flawlessly. It's something about that loop, line 379 :

/* Keep looping as long as gesture data is valid */
 while(1)

It never ends, as can be seen in the pastebin logs, while on UNO it escapes successfully.

It's something abut that it triggers at init and never escapes.

I did some testing with power.

I used my NANO as power source and UNO as the signal receiver. The same error occurred where it got stuck in a loop. After quick wire change to get power and signal from UNO it worked fine.
Also tried the other way around where UNO is supplying power and NANO is taking the signal, but it didn’t change anything. Taking any power from NANO resulted in failure, even with the breakout board with dedicated 3v3 AMS1117 which is good and 5V from UNO. Other sketches worked fine with any power setup!!! Only the GestureTest didn’t work.

I tested with a multimeter the power outputs. 5V from NANO is 4.6V (I also checked the USB connection receptacle and it’s 5V, somethings with the regulator or this is normal with NANO) and 5V from UNO is 5V. 3V3 on NANO is 3.7V. This is on open circuit voltage.

I have no idea what to do.

Post the code here, folks won't (or are blocked) look in pastebin to get it.

Diode drop from USB to 5V pin is expected on Nano.

Nano's 3.3V comes from FTDI chip internal regulator. You have a real Nano, or a clone with something else?

Clone with CH340G, but as I sad the I/O expansion board has 1117 3v3.

People can't see the pastebin? I just opened in incognito and everything works fine. In the pastebin links there is only debug data from the APDS9960 lib, showing raw data from the sensor that doesn't make sense to me and doesn't help.

I have no idea what to test to get any idea why it fails to escape the loop and return the data.

This makes no sense, everything works except for the gesture recognition.

Clone with CH340G

You should tell us if you don't use standard hardware. You are wasting our time if we look at the wrong schematics trying to solve your problem. Post the schematics of the board you use! Don't expect us to search for it!

People can't see the pastebin?

People may see it but you're in duty to make our job of helping you as straightforward as possible. One part of that is providing the necessary information within the forum. There should be no reason for us to follow links to advertisement-driven external sites.

This makes no sense, everything works except for the gesture recognition.

You may hide other information from us that might be important but as you don't think it's important you don't tell us.
So provide this information to us:

  • links to the schemata of all involved hardware that is not original Arduino hardware (because we can find that information on arcuino.cc)
  • a complete wiring diagram of the setup you use to experience the problem described above
  • the complete code you use for that

I have an official arduino nano and also have the same problem. All sketches in the Library work(including those with the interrupt). I am using the robodyn version of the apds and have tested a number of them with the nano. No cable here to test with my uno but I will dig one up soon.

I am using the robodyn version of the apds and have tested a number of them with the nano.

And once again: Post links to the hardware you use or at least schematics of it!

not that it will help, Just like the first TOF sensors little thought has gone out in rushing out new sensors out the door because its hip.

Go and reverse engineer a schematic of that board. I would never buy any hardware without schematics because you don't know how to wire that stuff. Regarding the pictures I guess that the board contains some level converters but then the value of 3V3 to be applied to the Vin pin is wrong. Follow all the lines on the board and draw the resulting schematic, then post it here.

Do you get the interrupts correctly? Have you check with a scope/logic analyzer?

Hi All

I’m right now playing with this same ADP sensor board mentioned sensor board (3V but 5V signal tolerant) and I’m having the same issue.

I haven’t tried with an arduino UNO, but with an arduino MEGA (original) does not work. Same thing, it hangs on a subroutine when handling gesture. All other examples of the library work perfectly, only the gesture one hangs up.

I have an oscilloscope with me and I can see the interrupt triggering correctly.

I’m powering the sensor board with 3V3 from an external supply giving 3V3 at board. The Arduino seems to be handling the 3V3 correctly with the level converters.

I will dig into the code a little bit see if I can find something there.

(3V but 5V signal tolerant)

Where did you find that information? On the linked page there's absolutely no information about how to connect that board.

What software do you use with it?

To add to the story - I am having exactly the same problem, ie all the other Sparkfun APDS-9960 Examples (including ProximityInterupt) work but the GestureTest example does not - hangs after:

SparkFun APDS-9960 - GestureTest
--------------------------------
APDS-9960 initialization complete
Gesture sensor is now running

The difference is that I am using a 3.3V Arduino Pro-Mini so no voltage level problems here.
The 3.3V supply is drooping by about 200mV and a 10,000mfd cap reduces this to 50mV but doesn't help.
The interupt signal looks OK about 20mS wide with a rep rate of ~70mS.

Any more bright ideas/suggestions ???

Since no-one else has any bright ideas - I will offer the following solution:

When editing the Sparkfun library to work with the ESP8266 instead of the Arduino, Jonathan Ulmer found it necessary to change the threshold read parameter from LED_BOOST_300 to LED_BOOST_100 in the file: SparkFun_APDS9960.cpp.

When I edited this in the Sparkfun library and compiled it again for the Arduino Pro-Mini, lo and behold the gesture sensor started working! Perhaps someone with more time on their hands can figure the root cause of this problem?

In the meantime, here are the details:

Here is the link to Jonathan’s library:

In the file SparkFun_APDS9960.cpp, search and find the line:

if( !setLEDBoost(LED_BOOST_300) ) {

and edit it to read:

if( !setLEDBoost(LED_BOOST_100) ) {

That would verify CrossRoad's assumption that the smaller 3V3 voltage regulator of the Nano is the problem.

With LED_BOOST_300 the IR LED in the chip is consuming over 16mA while with LED_BOOST_100 it's only below 4mA. Given the Nano has a voltage regulator that is able to provide 50mA, the 16mA seems like a relevant part in the setup.

alport:
Since no-one else has any bright ideas - I will offer the following solution:

In the file SparkFun_APDS9960.cpp, search and find the line:

if( !setLEDBoost(LED_BOOST_300) ) {

and edit it to read:

if( !setLEDBoost(LED_BOOST_100) ) {

Thanks ! This fixed the issue I had with APDS9960 and the Nano :slight_smile: I've been searching for hours...