Soldering 2 different sensor modules to 1 ground

Hello everyone.

I finalised a small arduino project using the Feather 32u4 and APDS9960 not long ago, so that's all soldered and done. However, I realised I need to add a Piezo Beeper in, which needs to be connected to a ground pin.

Is it possible to solder 2 wires of different modules into 1 ground hole pin?. Will it cause one of the sensor module to not work, etc? Apologies if this looks like a simple question as I just began learning Arduino. I searched google and most of them uses breadboard, which I want to avoid using.

Additional Info Board: Adafruit Feather 32u4 Module 1: APDS9960 Gesture sensor Module 2: Small enclosed Piezo W

Thank you in advance.

Hi kennylistiandi,

Quick answer, ground is ground is ground. It's all the same ground if you have put your circuit together correctly. Signal and power can be very different, but the ground same throughout your project. (not: there are exceptions, but they won't sneak up on you - you will know when you have - and want - two different ground values.

So yes, in general, you can connect all your modules to the same ground connector. That said, perhaps you should show your circuit.

Another point - the gesture sensor is a sensor - it's right in the name. Sensors are input devices - they generate a signal that the controller board (your Feather) reads and does something with. The beeper is an output device. you send it a signal, and it does something. It's not a sensor. (well, a piezo could be used as a sensor, but you are wanting to make noise with it, right?)

Hi ChrisTenone,

Thanks for the info, forgive my knowledge on this!
That said, you are correct. I intend to add a buzzer to create a sound whenever a gesture is sensed.

Wiring:

The board IRL:

Is this alright?

I was just worried if I soldered the piezo in, it might screw up the (already working) gesture sensor.
But thanks for the input.

Code, just in case:

#include <Arduino.h>
#include <SPI.h>
#include "Adafruit_BLE.h"
#include "Adafruit_BluefruitLE_SPI.h"
#include "Adafruit_BluefruitLE_UART.h"

#include "BluefruitConfig.h"


#include <Wire.h>
#include <SparkFun_APDS9960.h>



#if SOFTWARE_SERIAL_AVAILABLE
  #include <SoftwareSerial.h>
#endif

    #define FACTORYRESET_ENABLE         1
    #define MINIMUM_FIRMWARE_VERSION    "0.6.6"
    #define MODE_LED_BEHAVIOUR          "MODE"
/*=========================================================================*/


// Pins
#define APDS9960_INT 0 // Needs to be an interrupt pin, attach to Pin number 0 (RX)

// Constants

// Global Variables
SparkFun_APDS9960 apds = SparkFun_APDS9960();
int isr_flag = 0;


// A small helper
void error(const __FlashStringHelper*err) {
  Serial.println(err);
  while (1);
}

const int buzzer = 13; //buzzer to bluefruit 13


/**************************************************************************/
/*!
    @brief  Sets up the HW an the BLE module (this function is called
            automatically on startup)
*/
/**************************************************************************/
void setup(void)
{
  while (!Serial);  // required for Flora & Micro
  delay(500);

  Serial.begin(115200);
  Serial.println(F("Adafruit Bluefruit Command Mode Example"));
  Serial.println(F("---------------------------------------"));

  /* Initialise the module */
  Serial.print(F("Initialising the Bluefruit LE module: "));

  if ( !ble.begin(VERBOSE_MODE) )
  {
    error(F("Couldn't find Bluefruit, make sure it's in CoMmanD mode & check wiring?"));
  }
  Serial.println( F("OK!") );

  if ( FACTORYRESET_ENABLE )
  {
    /* Perform a factory reset to make sure everything is in a known state */
    Serial.println(F("Performing a factory reset: "));
    if ( ! ble.factoryReset() ){
      error(F("Couldn't factory reset"));
    }
  }

  /* Disable command echo from Bluefruit */
  ble.echo(false);

  Serial.println("Requesting Bluefruit info:");
  /* Print Bluefruit information */
  ble.info();

  Serial.println(F("Please use Adafruit Bluefruit LE app to connect in UART mode"));
  Serial.println(F("Then Enter characters to send to Bluefruit"));
  Serial.println();

  ble.verbose(false);  // debug info is a little annoying after this point!

  /* Wait for connection */
  while (! ble.isConnected()) {
      delay(500);
  }

  // LED Activity command is only supported from 0.6.6
  if ( ble.isVersionAtLeast(MINIMUM_FIRMWARE_VERSION) )
  {
    // Change Mode LED Activity
    Serial.println(F("******************************"));
    Serial.println(F("Change LED activity to " MODE_LED_BEHAVIOUR));
    ble.sendCommandCheckOK("AT+HWModeLED=" MODE_LED_BEHAVIOUR);
    Serial.println(F("******************************"));
  }

  ///////////////////SparkFun APDS-9960
  ////////////////////////////////////////////////////////////
    // Set interrupt pin as input
  pinMode(APDS9960_INT, INPUT);
  
  Serial.println(F("--------------------------------"));
  Serial.println(F("SparkFun APDS-9960 - GestureTest"));
  Serial.println(F("--------------------------------"));
  Serial.println("INT attach to pin "+digitalPinToInterrupt(APDS9960_INT));

  // Initialize interrupt service routine
  attachInterrupt(digitalPinToInterrupt(APDS9960_INT), interruptRoutine, FALLING);

  // Initialize APDS-9960 (configure I2C and initial values)
  if ( apds.init() ) {
    Serial.println(F("APDS-9960 initialization complete"));
  } else {
    Serial.println(F("Something went wrong during APDS-9960 init!"));
  }

  // Start running the APDS-9960 gesture sensor engine
  if ( apds.enableGestureSensor(true) ) {
    Serial.println(F("Gesture sensor is now running"));
  } else {
    Serial.println(F("Something went wrong during gesture sensor init!"));
  }

  pinMode(buzzer, OUTPUT); // Set buzzer - pin 9 as an output
  
}

/**************************************************************************/
/*!
    @brief  Constantly poll for new command or response data
*/
/**************************************************************************/
void loop(void)
{
  // Check for user input
  char inputs[BUFSIZE+1];

  // receive from apds
  
  if( isr_flag == 1 ) {
    detachInterrupt(digitalPinToInterrupt(APDS9960_INT));
    handleGesture();
    isr_flag = 0;
    attachInterrupt(digitalPinToInterrupt(APDS9960_INT), interruptRoutine, FALLING);
  }

  // receive from apds
  if ( getUserInput(inputs, BUFSIZE) )
  {
    // Send characters to Bluefruit
    Serial.print("[Send] ");
    Serial.println(inputs);

    ble.print("AT+BLEUARTTX=");
    ble.println(inputs);

    // check response stastus
    if (! ble.waitForOK() ) {
      Serial.println(F("Failed to send?"));
    }
  }

  // Check for incoming characters from Bluefruit
  /*ble.println("AT+BLEUARTRX");
  ble.readline();
  if (strcmp(ble.buffer, "OK") == 0) {
    // no data
    return;
  }
  // Some data was found, its in the buffer
  Serial.print(F("[Recv] ")); Serial.println(ble.buffer);
  ble.waitForOK();*/


  /*unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= 1000) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW) {
      ledState = HIGH;
    } else {
      ledState = LOW;
    }
    tone(buzzer, 1000);
  }
  else
  {
    notone(buzzer);
  }*/
  
}

/**************************************************************************/
/*!
    @brief  Checks for user input (via the Serial Monitor)
*/
/**************************************************************************/
bool getUserInput(char buffer[], uint8_t maxSize)
{
  // timeout in 100 milliseconds
  TimeoutTimer timeout(100);

  memset(buffer, 0, maxSize);
  while( (!Serial.available()) && !timeout.expired() ) { delay(1); }

  if ( timeout.expired() ) return false;

  delay(2);
  uint8_t count=0;
  do
  {
    count += Serial.readBytes(buffer+count, maxSize);
    delay(2);
  } while( (count < maxSize) && (Serial.available()) );

  return true;
}

void interruptRoutine() {
  isr_flag = 1;
}

void handleGesture() {
    String curr_gesture;
    if ( apds.isGestureAvailable() ) {
    switch ( apds.readGesture() ) {
      case DIR_UP:
        curr_gesture = "UP";
        //Serial.println(curr_gesture);
        break;
      case DIR_DOWN:
        //Serial.println("DOWN");
        curr_gesture = "DOWN";
        //Serial.println(curr_gesture);        
        break;
      case DIR_LEFT:
        curr_gesture = "LEFT";
        break;
      case DIR_RIGHT:
        curr_gesture =  "RIGHT";
        break;
      case DIR_NEAR:
        curr_gesture = "NEAR";
        break;
      case DIR_FAR:
        curr_gesture = "FAR";
        break;
      default:
      curr_gesture = "NONE";
        //Serial.println("NONE");
    }
    Serial.println(curr_gesture); 
    tone(buzzer, 1000); // Send 1KHz sound signal...
    delay(1000);        // ...for 1 sec
    noTone(buzzer);     // Stop sound...   

    ble.print("AT+BLEUARTTX=");
    ble.println(curr_gesture);

    // check response stastus
    if (! ble.waitForOK() ) {
      Serial.println(F("Failed to send?"));
    }    
  }
}

edit: pic not showing

You're gonna solder it to pin 13? Is there an LED already on pin 13? I do that with a device I have, and it works splendidly. The buzzer clicks and the LED flashes. Yeah, just solder it in. If there is any complication (I don't have your hardware, so I can't test it) you can just cut the wires.

If you want to test it before you solder (always a good idea) just wrap the wires around the connector good and tight, and see if it works. Solder it if it does.