Sensor Ground Problem_Not working when connected all the sensors together.

Hi Guys,
I am new to Arduino and electronics field.I am currently working in a project which involves Arduino Leonardo which uses three sensors- pressure,level (tilt) and rain sensors. I got the codes for all of them from forums like this and all of them are working individually.
But when I try to integrate all the three sensors, I can incorporate the level and rain sensors, but not the pressure sensor. First, I thought it was a coding issue. But the codes are compiling correctly. When I went through several Arduino forums, somebody has mentioned that this is a common issue, and it is happening due to the common ground of all the three sensors and we have to connect the sensors individually using the other GND ports available in the microcontroller. But even if I connect the GND pins like that and isolate the individual circuits, I am not getting the output. We have tried connecting it using a separate power supply, and still, the issue persists.The following options I have tried and failed -
1.Connected the sensors using an external power supply of 5V
2.Made use of the 3.5,5 V pins and the two GND pins to connect individually
3.Connected the sensors to the external power supply
4.Changed the sensors and even the microcontroller to make sure that all of them are working fine.
I am supplying the microcontroller via USB and I am not getting a correct output if I am not giving the supply voltage of sensors from the Vcc and GND pins of microcontroller.
The components I am using are furnished below and I am attaching the circuit diagram and copy pasting the codes below (sorry due to attachment size issues) The codes are not mine,but works perfectly.

Microcontroller – Arduino Leonardo AtMega 32U4 W5500
Pressure sensor – BMP 180
Level Sensor (tilt) – XC 4575
Rain (water) sensor - XC4603

Pressure sensor Codes__________

#include <Wire.h>
#include <Adafruit_BMP085.h>
#define seaLevelPressure_hPa 1013.25
Adafruit_BMP085 bmp;
void setup()
if (!bmp.begin()) {
Serial.println(“Could not find a valid BMP085 sensor, check wiring!”);
while (1) {}
void loop() {
Serial.print(“Temperature = “);
Serial.println(” *C”);

Serial.print(“Pressure = “);
Serial.println(” Pa”);

Serial.print(“Altitude = “);
Serial.println(” meters”);

Serial.print(“Pressure at sealevel (calculated) = “);
Serial.println(” Pa”);

Serial.print(“Real altitude = “);
Serial.print(bmp.readAltitude(seaLevelPressure_hPa * 100));
Serial.println(” meters”);


Level Sensor and Rain sensor codes_____

int rainPin = A0;
int greenLED = 6;
int redLED = 7;
// you can adjust the threshold value
int thresholdValue = 500;
void setup(){
pinMode(rainPin, INPUT);
pinMode(greenLED, OUTPUT);
pinMode(redLED, OUTPUT);
digitalWrite(greenLED, LOW);
digitalWrite(redLED, LOW);
pinMode(2, OUTPUT);
pinMode(4, INPUT);
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(rainPin);
if(sensorValue < thresholdValue){
Serial.println(" - It’s wet");
digitalWrite(greenLED, LOW);
digitalWrite(redLED, HIGH);
else {
Serial.println(" - It’s dry");
digitalWrite(greenLED, HIGH);
digitalWrite(redLED, LOW);
if (digitalRead(4) == 1)
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);}
digitalWrite(2, LOW);
digitalWrite(3, LOW);}

Thank You very much

Are you saying you are trying to combine two different programs for one Arduino?

Yes. Actually there are three sensors - pressure, Level (tilt), and rain. I have already combined level and rain sensors and they are working fine. But I can't connect the pressure sensor.