void loop() {
    Accelerometer *accelerometer = Sensors::getAccelerometer();
    if(accelerometer) {
        Vector3 a = accelerometer->getAcceleration();
        Serial.print("Acceleration (m/s^2)  ");
        Serial.print(a.x);
        Serial.print(", ");
        Serial.print(a.y);
        Serial.print(", ");
        Serial.println(a.z);
    }

    Barometer *barometer = Sensors::getBarometer();
    if(barometer) {
        float p = barometer->getPressure();
        Serial.print("Pressure (hPa)        ");
        Serial.println(p);

        float a = barometer->getAltitude();
        Serial.print("Altitude (m)          ");
        Serial.println(a);
    }

    Gyroscope *gyroscope = Sensors::getGyroscope();
    if(gyroscope) {
        Vector3 g = gyroscope->getRotation();
        Serial.print("Rotation (rad/s)      ");
        Serial.print(g.x);
        Serial.print(", ");
        Serial.print(g.y);
        Serial.print(", ");
        Serial.println(g.z);
    }

    Magnetometer *magnetometer = Sensors::getMagnetometer();
    if(magnetometer) {
        Vector3 m = magnetometer->getMagneticField();
        Serial.print("Magnetic Field (uT)   ");
        Serial.print(m.x);
        Serial.print(", ");
        Serial.print(m.y);
        Serial.print(", ");
        Serial.println(m.z);

        float azimuth = magnetometer->getAzimuth();
        Serial.print("Azimuth (deg)         ");
        Serial.println(azimuth);
    }

    Thermometer *thermometer = Sensors::getThermometer();
    if(thermometer) {
        float t = thermometer->getTemperature();
        Serial.print("Temperature (C)       ");
        Serial.println(t);
    }

    delay(50);
}
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();
	}
}
Example #3
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;
}
//The setup function is called once at startup of the sketch
void setup() {
	started = false;

	// set up the LCD's number of columns and rows:
	lcd.begin(16, 2);
	lcd.setRGB(colorR, colorG, colorB);
	lcd.clear();

	lcd.setCursor(0,0);
	lcd.println("Wheather init   ");
	Serial.begin(9600);
	delay(200);

	lcd.setCursor(0,0);
	lcd.println("Display init    ");
	tm1637.set();                              //activation de l'afficheur
	tm1637.init();                             //Initialisation de l'afficheur
	delay(200);

	lcd.setCursor(0,0);
	lcd.println("Barometer init  ");
	myBarometer.init();                         //initialisation du barometre
	delay(200);

	lcd.setCursor(0,0);
	lcd.println("Thermometer init");
	dht.begin();
	delay(200);

	lcd.setCursor(0,0);
	lcd.println("Clock init      ");
	clock.begin();
	delay(200);

	lcd.setCursor(0,0);
	lcd.println("Timer init      ");
	//Timer1.initialize(500000);                  //activation du timer pour une interruption chaque seconde
	//Timer1.attachInterrupt(getData);            //appel getData ˆ chaque interruption
  	delay(200);

	lcd.setCursor(0,0);
	lcd.println("Wheather ready  ");
	delay(200);
	lcd.clear();
	started = true;
}