gcjr:
yusuf
there are various issues with your code. suggest you look at the following
-
in your code there's no need to test for 0 == gps.available(). if gps is available, read it. if not just test if the time is expired
-
gps.read() will read whatever is transmitted, regardless if it's a hex or ascii value. and Serial.write will do the same, meaning a value of 0 is 0x30 (see ascii
-
not sure where the value of "a" is set
-
the nested if statements in getPressure() is awkward.
-
in getPressure() you call delay() with the value of status. status is likely to be 0 or 1.
also bear in mind that at 9600 bps, i takes ~1 msec per character. loop() runs many times within a msec and it is unlikely that that you will receive more than 1 character each time loop() runs.
#include <SoftwareSerial.h>
#include <SFE_BMP180.h>
#include <Wire.h>
SFE_BMP180 pressure;
SoftwareSerial gps(2,3);
double baseline;
unsigned long previousMillis = 0;
const long interval = 1000;
void setup()
{
Serial.begin(115200);
gps.begin(9600);
if (pressure.begin())
Serial.println("BMP180 init success");
else
Serial.println("BMP180 init fail (disconnected?)\n\n");
baseline = getPressure();
Serial.print("baseline pressure is measured as: ");
Serial.print(baseline);
Serial.println(" mb");
}
void loop()
{
if (gps.available()) {
Serial.println (gps.read());
}
double a,P;
unsigned long currentMillis = millis();
P = getPressure();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
Serial.print("relative altitude: ");
if (a >= 0.0)
Serial.print(" ");
Serial.println (pressure.altitude(P,baseline),2);
}
}
double getPressure()
{
double T,P;
if (0 == pressure.startTemperature()) {
Serial.println("error starting temperature measurement\n");
return 0;
}
if (0 == pressure.getTemperature(T)) {
Serial.println("error retrieving temperature measurement\n");
return 0;
}
if (0 == pressure.startPressure(3)) {
Serial.println("error starting pressure measurement\n");
return 0;
}
if (0 == pressure.getPressure(P,T)) {
Serial.println("error retrieving pressure measurement\n");
return 0;
}
return(P);
}
Thank you gcjr, I appreciate. I know that there were some logically wrong parts in the code but why I did it is because of the code itself which did not do what it is supposed to do... Or, I might be just a bit tired
Now I have something that works quite good, not perfect though, and I will stop here because I have much more to do and to deal with... I am adding my code here so that new newbies can find what they need quicker. I made some editing and it looks okay for now. Nevertheless, if anything is wrong or can be better, please let me know and I will try to get it better. Thank you for all your helps and understandings 
#include <SoftwareSerial.h>
#include <Adafruit_BMP085.h>
#include <Wire.h>
Adafruit_BMP085 bmp;
SoftwareSerial gps(2,3);
unsigned long previousMillis = 0;
const long interval = 1000;
#define BuzzerPin 11
void setup()
{
gps.begin(9600);
pinMode(BuzzerPin, OUTPUT);
digitalWrite(BuzzerPin, LOW);
if (bmp.begin()) {
Serial.println("BMP180 initialization successfull");
digitalWrite(BuzzerPin, HIGH);
delay(100);
digitalWrite(BuzzerPin, LOW);
delay(100);
digitalWrite(BuzzerPin, HIGH);
delay(100);
digitalWrite(BuzzerPin, LOW);
}
else {
Serial.println("Could not find a valid BMP180 sensor, check wiring!");
digitalWrite(BuzzerPin, HIGH);
delay(500);
digitalWrite(BuzzerPin, LOW);
}
Serial.begin(9600);
}
void loop()
{
Serial.flush();
while(gps.available()>0){Serial.write(gps.read());}
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
Serial.println();
Serial.println();
Serial.print("Altitude = ");
Serial.print(bmp.readAltitude());
Serial.println(" meters");
Serial.println();
Serial.println();
}
}