示例#1
0
int main(){
    float temperature;
    float pressure;
    float atm;
    float altitude;

    Barometer mBarometer = Barometer();

    int i = 0;

    for(i; i< 10 ;i++) {

        temperature = mBarometer.bmp085GetTemperature(mBarometer.bmp085ReadUT()); //Get the temperature, bmp085ReadUT MUST be called first
        pressure = mBarometer.bmp085GetPressure(mBarometer.bmp085ReadUP());//Get the temperature
        altitude = mBarometer.calcAltitude(pressure); //Uncompensated caculation - in Meters
        atm = pressure / 101325;

        std::cout << "Temperature: " << temperature << " deg c" << std::endl;
        std::cout << "Pressure: " << pressure << " Pa" << std::endl;
        std::cout << "Ralated Atmosphere: " << atm << std::endl;
        std::cout << "Altitude: " << altitude << " m" << std::endl;
        std::cout << std::endl;
    }

    return 0;
}
void getData() {
	if (started) {
		update = ON;

		barTemp = myBarometer.bmp085GetTemperature(myBarometer.bmp085ReadUT());   //Get the temperature, bmp085ReadUT MUST be called first
		barPres = myBarometer.bmp085GetPressure(myBarometer.bmp085ReadUP());      //Get the pressure
		barAlti = myBarometer.calcAltitude(barPres);                              //Uncompensated caculation - in Meters
		barAtmo = barPres / 101325;

		theTemp = dht.readTemperature();
		theHumi = dht.readHumidity();
	}
}