SPX-17979 Qwiic Sound Trigger board not soft resetting?

Hello!

I am working with the SPX-17979 sound trigger board and I think I’m either doing something wrong or part of the sample code isn’t actually working as expected. I currently have the 4 pins at the bottom hooked up the the board (SCL, SDA, GND, and +3.3V).

I’ll put the full code at the bottom for reference but the part I want to focus on is this portion:

// Now we need to reset the sound event by:
    myTrigger.digitalWrite(VM1010_MODE, LOW); // Get ready to pull the VM1010 MODE pin low
    myTrigger.pinMode(VM1010_MODE, OUTPUT); // Change the PCA9536 GPIO0 pin to an output. It will pull the VM1010 MODE pin low
    myTrigger.pinMode(VM1010_MODE, INPUT); // Change the PCA9536 GPIO0 pin back to an input (with pull-up), so it will not 'fight' the mode button

I expect that after a trigger event is hit, the arduino board will communicate to the PCA9536 via the I2C bus to tell it to set the pin low and then go back into input mode after the debouncing period (which I have set to 500 ms). Unfortunately, I’m not seeing that section of the code do anything and, once it’s triggered, I have to manually ground the pin using an external wire (since it’s so sensitive that touching the board or even trying to use the button, but that’s another issue entirely) will set it off.

I can manually reset it by grounding the pin but the PCA9536 doesn’t appear to be doing anything. Do I have something setup incorrectly or am I misunderstanding how this should work?

Any info you can give me would be greatly appreciated. Thanks!

Below is the full code:

#include <SparkFun_PCA9536_Arduino_Library.h> // Click here to get the library: http://librarymanager/All#SparkFun_PCA9536

PCA9536 myTrigger;

unsigned long lastTrigger; // Keep a record of when the last trigger took place (millis)

#define VM1010_MODE 0 // The VM1010 mode pin is connected to GPIO0 on the PCA9536
#define VM1010_TRIG 1 // The VM1010 trigger pin (Dout) is connected to GPIO1 on the PCA9536

void setup()
{
  Serial.begin(115200);
  Serial.println(F("Qwiic Sound Trigger Example"));

  Wire.begin(); // We communicate with the PCA9536 via I2C

  pinMode(LED_BUILTIN, OUTPUT); // The LED on the sound trigger will only flash very briefly
  digitalWrite(LED_BUILTIN, LOW); // We will flash LED_BUILTIN for a full second on each sound event

  // Initialize the Sound Trigger PCA9536 with a begin function
  if (myTrigger.begin() == false)
  {
    Serial.println(F("Sound Trigger (PCA9536) not detected. Please check wiring. Freezing..."));
    while (1)
      ;
  }

  // Configure VM1010_TRIG (GPIO1) as an input for the VM1010 trigger signal (Dout)
  myTrigger.pinMode(VM1010_TRIG, INPUT);

  // Configure VM1010_MODE (GPIO0) as an input for now.
  // The pull-up resistor on the sound trigger will hold the VM1010 in "Wake On Sound" mode.
  // We will configure VM1010_MODE as an output when we want to pull the MODE pin low to clear the wake-up event.
  myTrigger.pinMode(VM1010_MODE, INPUT);

  lastTrigger = millis(); // Initialize lastTrigger

  Serial.println(F("Waiting for a sound event..."));
}

void loop()
{
  // Check for a new sound (wake-up event) every millisecond (approx.)
  delay(1);

  // Check for a wake-up event by reading the VM1010 Trigger (Dout) pin
  // Dout will go high when a sound is detected
  if (myTrigger.digitalRead(VM1010_TRIG) == HIGH)
  {
    // We have detected a sound so:

    // Lets tell the user about it:
    Serial.println();
    Serial.print(F("Sound detected! It has been "));
    Serial.print(millis() - lastTrigger);
    Serial.println(F(" ms since the last sound event"));

    lastTrigger = millis(); // Update lastTrigger

    // Flash LED_BUILTIN for a full second. The LED on the sound trigger will only flash briefly
    digitalWrite(LED_BUILTIN, HIGH);

    // Unless your sound is _very_ quick ( ~ 10 milliseconds ), you will see multiple sounds events from the VM1010
    // You can "debounce" those by adding a delay before resetting the VM1010
    delay(500); // Uncomment this line to "debounce" sound events

    // Now we need to reset the sound event by:
    //myTrigger.digitalWrite(VM1010_MODE, LOW); // Get ready to pull the VM1010 MODE pin low
    //myTrigger.pinMode(VM1010_MODE, OUTPUT); // Change the PCA9536 GPIO0 pin to an output. It will pull the VM1010 MODE pin low
    //myTrigger.pinMode(VM1010_MODE, INPUT); // Change the PCA9536 GPIO0 pin back to an input (with pull-up), so it will not 'fight' the mode button
  }

  // Check if it has been more than one second since the last sound event
  // If it has, turn LED_BUILTIN off
  if (millis() > (lastTrigger + 1000))
  {
    digitalWrite(LED_BUILTIN, LOW);
  }
}

I guess it’s working now? I don’t understand as it definitely wasn’t working last night. I was uploading the code, it was resetting everytime but it wasn’t clearing the bit.

Only thing I can think of is there’s a header on the Arduino Uno that the back of the board might’ve been shorting to? That’s my best guess but I know I pulled it up at one point to avoid that . . . Regardless, it seems to work now and I don’t think I changed anything (but clearly I must have). Oh well, false alarm, I guess!

Excellent! A lot of the SparkX products can be finnicky when being setting up; glad to see you got it working!