Incorrect Readings When Digital and Analog Sensor Share Common GND/PWR

So I've been working on getting two sensors to work in harmony while connected to an Arduino Micro or Uno. I'm using a digital PIR sensor and an analog ultrasonic sensor to detect motion. To make things nice an compact I designed a case the sensors can sit in and connect to a 4 wire JST (one for GND, one for PWR, one for data from PIR, and the other for data from Ultrasonic).

The sensors work completely fine by themselves and even when they are placed on a breadboard together using a common ground to the Arduino. However, as soon as I soldered the GNDs from the two sensors together to one of the JST wires the analog readings of the ultrasonic sensor no longer make sense an either stick to the same number or spike.

I also found it strange that during prototyping I had a 12 LED Neopixel ring light up whenever both sensors reached a threshold. The LEDs were also using the same GND/PWR and whenever they would turn on the analog readings of the Ultrasonic sensor would jump. But when I moved the GND of the Ultrasonic sensor to a different pin on the Arduino the readings were find even when the lights were on. I just found this strange since I thought the Arduino has the same ground potential on each pin.

I've included an image of my setup (the data pin on the digital PIR is disconnected here).

Any help would be greatly appreciated and I can easily provide code/data sheets/whatever information is needed!

I can easily provide code/data sheets/

Yes that is a good start. Also pleases resize your photograph so that most of it is not in the next bedroom.

Yeah sorry about that giant image, fixed it.

PIR Sensor (Panasonic AMN23111 Spot Sensor) :
Ultrasonic Sensor (Maxbotix LV-EZ3) :\

Simple test code:

#include <Adafruit_NeoPixel.h>

const int anPin = 4;
const int pirPin = 2;

float detectTime = 150.0;
float leaveTime = 600.0;
float presence = 0.0;
float noPresence = 0.0;

int calibrationTime = 3; 

long anVolt, inches;
int sum=0;
int avgrange=60;

Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, 4, NEO_GRB + NEO_KHZ800);

void setup() {

  //This opens up a serial connection to shoot the results back to the PC console
  strip.begin();; // Initialize all pixels to 'off'
  pinMode(pirPin, INPUT);
  digitalWrite(pirPin, LOW);

  //give the sensor some time to calibrate
  Serial.print("calibrating sensor ");
    for(int i = 0; i < calibrationTime; i++){
    Serial.println(" done");
    Serial.println("SENSOR ACTIVE");

void loop() {

  for(int i = 0; i < avgrange ; i++)
    anVolt = analogRead(anPin)/2;
    sum += anVolt;
  inches = sum/avgrange;

  if(digitalRead(pirPin) == HIGH && inches <= 10.0){
      noPresence = 0.0;
      if(presence >= detectTime) {
        presence = 0.0;
        colorFill(strip.Color(255, 0, 255));
  if(digitalRead(pirPin) == LOW && inches >= 10.0){
    presence = 0.0;
    if(noPresence >= leaveTime) {
      noPresence = 0.0;
      colorFill(strip.Color(0, 0, 0));

  //reset sample total
  sum = 0;

void colorFill(uint32_t color) {
    for(uint16_t i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, color);

Thanks for fixing the picture. Now I can see it all I can positively say I am non the wiser as to what it shows.

However if your problem is one of things not working when you join grounds it is unlikely to be your software that is at fault, it is likely to be the hardware. Can you produce a schematic showing what you have wired please.