APDS9960 - Gesture Sensor and MySensors Sleep



  • I'm trying to build a gesture sensor switch using adps9960 module that runs on battery and also accommodates temp/humidity via dht11.

    Setup works with examples provided with Sparkfun library - so electronics ok. I see the gesture sensor activate interrupt 0 from pro-mini 3.3v. Device works fine in non-sleep mode as MySensors to Webthings.io

    Sleep mode using the interrupt and FALLING only wakes after ms sleep, not from interrupt activity.
    The difference between example code and MySensor example code https://www.mysensors.org/download/sensor_api_20#sleeping is

    1. No allocation of INPUT pin for interrupt pin - assume its done in MySensors
    2. No specification of attach interrupt - assume its done in MySensors
    3. No definition of an ISR - again assume its done in MySensors

    Anyone had success with this - the adps 9960 sets off the interrupt - tested by the Sparkfun example code ... device tech specs says it pulls low after an action detected on the proximity sensor engine..



  • I did more investigation played around with sleep outside of mysensors and found a bit of code in a proximity sensor example:

        // Reset flag and clear APDS-9960 interrupt (IMPORTANT!)
      isr_flag = 0;
      if ( !apds.clearProximityInt() ) {
          Serial.println("Error clearing interrupt");
      }
    

    I then needed to play around with delays to allow the sensor to catchup..

    void loop() {
    delay(1000);
    

    Recoding back to MySensors

    if ( !apds.clearProximityInt() ) {
          Serial.println("Error clearing interrupt");
      }
      wakeupReason = sleep(digitalPinToInterrupt(INT_PIN), FALLING, sleepTime);
    

    setting up the interrupt pin with a pullup forced the FALLING when pin dragged down by the sensor.

    void setup() {
        pinMode(INT_PIN, INPUT_PULLUP);
    

    All this is on caveat it makes it through some more testing.


Log in to reply
 

Suggested Topics

  • 87
  • 10
  • 3
  • 7
  • 9
  • 7

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts