Ventilation Machine with I2C

hello guys me and my friend who is also my project partner in our associate electronic engineering degree are working on final project to recieve our degree , and what we’re working on is a ventilation machine that works with Arduino Mega as the main board and the sensors are MAX30102, MS5803 Pressure Sensor, i2c 20X4 LCD, and DHT-11 temperature sensor.
and as we learned from the internet each sensor needs to be communicated by it own address, as well start requesting data from registery and such as i2c works.
but some how all the sensor working together without the requesting the communication and such (which makes it for us alot easier ) but we want to know why .
so my main question how do we communicate the right way, or its okay to communicate like that, il post the code we made through until now.

#include <LCD.h>
#include <Wire.h>
#include “MAX30105.h”
#include “spo2_algorithm.h”
#include <LiquidCrystal_I2C.h>
#include <SparkFun_MS5803_I2C.h>

#include “dht.h”
#include <Servo.h>

#define dht_apin A0 // DHT TEMP Sensor

Servo myservo; //Creating Servo Objects to Control It.

dht DHT;

int ms5803 = 0x77, lcdi2c = 0x3F , max30102 = 0x57;

MS5803 sensor(ADDRESS_HIGH); //( ADDRESS_HIGH = 0x7, ADDRESS_LOW = 0x77)
LiquidCrystal_I2C lcd(0x3F,2,1,0,4,5,6,7);
MAX30105 particleSensor;

double pressure_abs, pressure_relative, altitude_delta, pressure_baseline;

double base_altitude = 1655.0; // Altitude of SparkFun’s HQ in Boulder, CO. in (m)

#define MAX_BRIGHTNESS 255

#if defined(AVR_ATmega328P) || defined(AVR_ATmega168)
//Arduino Uno doesn’t have enough SRAM to store 100 samples of IR led data and red led data in 32-bit format
//To solve this problem, 16-bit MSB of the sampled data will be truncated. Samples become 16-bit data.
uint16_t irBuffer[100]; //infrared LED sensor data
uint16_t redBuffer[100]; //red LED sensor data
#else
uint32_t irBuffer[100]; //infrared LED sensor data
uint32_t redBuffer[100]; //red LED sensor data
#endif

int32_t bufferLength; //data length
int32_t spo2; //SPO2 value
int8_t validSPO2; //indicator to show if the SPO2 calculation is valid
int32_t heartRate; //heart rate value
int8_t validHeartRate; //indicator to show if the heart rate calculation is valid

byte pulseLED = 11; //Must be on PWM pin
byte readLED = 13; //Blinks with each data read

int SW = 7; ;

/////////////////////////////////////////////////////////////////////////
void setup()
{

Serial.begin(115200);

//////////////////////////////Servo///

myservo.attach(10);

pinMode(SW,INPUT);////////Condition If the Switch is ON or OFF//

Wire.begin();///////////////I2c Library

/////////////////////////////////////Pressure Sensor Setup//
sensor.reset();
sensor.begin();

pressure_baseline = sensor.getPressure(ADC_4096);

////////////////////// Lcd Starting Display///
lcd.begin(20,4);
lcd.setBacklightPin(3,POSITIVE); //LCD
lcd.setBacklight(HIGH);

lcd.clear();
lcd.setCursor(2,1);
lcd.print(“E&T Vent Machine”);

///////////////////////MAX 30102/////////

pinMode(pulseLED, OUTPUT);
pinMode(readLED, OUTPUT);

!particleSensor.begin(Wire, I2C_SPEED_FAST);

byte ledBrightness = 60; //Options: 0=Off to 255=50mA
byte sampleAverage = 4; //Options: 1, 2, 4, 8, 16, 32
byte ledMode = 2; //Options: 1 = Red only, 2 = Red + IR, 3 = Red + IR + Green
byte sampleRate = 100; //Options: 50, 100, 200, 400, 800, 1000, 1600, 3200
int pulseWidth = 411; //Options: 69, 118, 215, 411
int adcRange = 4096; //Options: 2048, 4096, 8192, 16384

particleSensor.setup(ledBrightness, sampleAverage, ledMode, sampleRate, pulseWidth, adcRange); //Configure sensor with these settings

////////////////////////////////////

}

void loop()
{

DHT.read11(dht_apin);

bufferLength = 100; //buffer length of 100 stores 4 seconds of samples running at 25sps

//read the first 100 samples, and determine the signal range
for (byte i = 0 ; i < bufferLength ; i++)
{
while (particleSensor.available() == false) //do we have new data?
particleSensor.check(); //Check the sensor for new data

redBuffer = particleSensor.getRed();
_ irBuffer = particleSensor.getIR();_
* particleSensor.nextSample(); //We’re finished with this sample so move to next sample*
* }*
* //calculate heart rate and SpO2 after first 100 samples (first 4 seconds of samples)*
* maxim_heart_rate_and_oxygen_saturation(irBuffer, bufferLength, redBuffer, &spo2, &validSPO2, &heartRate, &validHeartRate);
_
//Continuously taking samples from MAX30102. Heart rate and SpO2 are calculated every 1 second*_
* while (1)*
* {*
* //dumping the first 25 sets of samples in the memory and shift the last 75 sets of samples to the top*
* for (byte i = 25; i < 100; i++)*
* {*
_ redBuffer[i - 25] = redBuffer*;
irBuffer[i - 25] = irBuffer;
}
//take 25 sets of samples before calculating the heart rate.
for (byte i = 75; i < 100; i++)
{
while (particleSensor.available() == false) //do we have new data?
particleSensor.check(); //Check the sensor for new data*

* digitalWrite(readLED, !digitalRead(readLED)); //Blink onboard LED with every data read*
redBuffer = particleSensor.getRed();
irBuffer = particleSensor.getIR();
* particleSensor.nextSample(); //We’re finished with this sample so move to next sample*
* //send samples and calculation result to terminal program through UART*_

_ if ( (irBuffer*>180000) && (digitalRead(SW)==HIGH))
{*_

lcd.clear();
lcd.setCursor(0,0);
lcd.print(“SpO2=”);
lcd.print(spo2, DEC);
lcd.print("%");
lcd.setCursor(0,1);
lcd.print(“BPM=”);
lcd.print(heartRate);
* ////////////////////////////////////////////////////////////////////////////////////DHT-11 Sensor*
* lcd.setCursor(0,3);*
* lcd.print(“Temp”);*
* lcd.print(DHT.temperature);*
* lcd.println("C ");*
//////////////////////////////////////////////////////////////////////////////////////////////////////// MS5803
* lcd.setCursor(0,2);*
* lcd.print(“PSR=”);*
* lcd.println(pressure_abs);
Serial.print("Pressure : ");
Serial.print(pressure_abs);
Serial.print(’\n’);
pressure_abs = sensor.getPressure(ADC_4096);
if ( pressure_abs>1010)
_ {
myservo.write(180);
delay (500);
}
else if (pressure_abs<1040)
{
myservo.write(100);
delay(500);
}*_

* }*

else
{
lcd.clear();
* lcd.setCursor(0,0);*
* lcd.print(“Please Insert Patient To Sensor”);*

}
* //After gathering 25 new samples recalculate HR and SP02*
* maxim_heart_rate_and_oxygen_saturation(irBuffer, bufferLength, redBuffer, &spo2, &validSPO2, &heartRate, &validHeartRate);*

* }*
* }*
* delay(10);*
/////////////////////////////////////////////////////////////////////////////////

}
thanks for helping us !!
and the main thing that it does reads values of the pressure sensor and by that values it pushes a servo motor that compresses a vent balloon

Read the how to use this forum-please read sticky to see how to properly post code. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code in code tags.

What is your problem?

MAX30102 is an I2C device
MS5803 Pressure Sensor is an I2C device
i2c 20X4 LCD is an I2C device, and
DHT-11 is an especial 1-wire device.

The above sensors are being driven by their respective libraries in your sketch and it should be alright.