#include <Wire.h>

#include <bmp085.h>

#define LOOPTIME 100
float temp, pres, atm, alt;

void setup()
{
  Serial.begin(115200);
  bmp085_init();
}

int i=0;
#define ALFA 0.2


float alt1=0; 


void loop()
{
  temp = bmp085GetTemperature(bmp085ReadUT()); //MUST be called first for every measurements
  
    pres = bmp085GetPressure(bmp085ReadUP());
  atm = pres / 101325; // "standard atmosphere"
  alt = bmp085PascalToMeter(pres,101000); //Uncompensated caculation - in Meters 
   goto xxx;
  alt = ALFA *alt + (1.0-ALFA)*alt1;
  alt1 = alt;
  xxx:
  i++;
  Serial.print(i);
  Serial.print(" Temp/pres/atm/alt/tid : ");
 
  Serial.print(temp, 2); //display 2 decimal places
  Serial.print(" C ");

  Serial.print(pres, 0); //whole number only.
  Serial.print(" Pa ");

  Serial.print(atm, 4); //display 4 decimal places
  Serial.print(" ");
  Serial.print(alt, 2); //display 2 decimal places
  Serial.print(" M ");
 
 Serial.print(millis());
 Serial.println(" msek");
  delay(LOOPTIME);
}




