Exemplo n.º 1
0
int main(int argc, char **argv) {
  printf("BMPO85 examples program\n");
  I2Cdev::initialize();
  BMP085 barometer ; // BMP085 class default I2C address is 0x77, specific I2C addresses may be passed as a parameter here
  if ( barometer.testConnection() ) 
    printf("BMP085 connection test successful\n") ;
  else {
    fprintf( stderr, "BMP085 connection test failed! exiting ...\n");
    return 1;
  }
  barometer.loadCalibration();
  float temperature;
  float pressure;
  float altitude;
  while (true) {
    barometer.setControl(BMP085_MODE_TEMPERATURE);
    bcm2835_delay(5); // wait 5 ms for conversion 
    temperature = barometer.getTemperatureC();
    barometer.setControl(BMP085_MODE_PRESSURE_3) ; //taking reading in highest accuracy measurement mode
    bcm2835_delay( barometer.getMeasureDelayMicroseconds() / 1000 );
    pressure = barometer.getPressure();
    altitude = barometer.getAltitude(pressure);
    printf("  Temperature: %3.1f deg C      Pressure %3.3f kPa      altitude %3.1f m\r", temperature, pressure/1000.0, altitude);
    fflush(stdout);
    bcm2835_delay(200);
  }
  return 1; 
}
Exemplo n.º 2
0
double Sensor::getBMP085altitude() {
    BMP085 dps = BMP085();  
    Wire.begin();
    dps.init();
    long Temperature = 0, Pressure = 0, Altitude = 0;
    dps.getTemperature(&Temperature); 
    dps.getPressure(&Pressure);
    dps.getAltitude(&Altitude);
    return (double) Altitude;
}
Exemplo n.º 3
0
double Sensor::getBMP085pressure() {
    Serial.println("At getPressure");
    BMP085 dps = BMP085();  
    Wire.begin();
    dps.init();
    long Temperature = 0, Pressure = 0, Altitude = 0;
    dps.getTemperature(&Temperature); 
    dps.getPressure(&Pressure);
    dps.getAltitude(&Altitude);
    Serial.print("The pressure is: ");Serial.println("Pressure");
    return (double) Pressure;
}
Exemplo n.º 4
0
/*
 * Main Loop 
 */
void loop() {
	wdt_reset();
	mD.vals.uslCount++;									//Increment main datarecord count
	AccelerometerScaled Ascaled = accel.ReadScaledAxis();	//Get Scaled Accelerometer
	AccelerometerRaw Araw = accel.ReadRawAxis();			//Get Raw Accelerometer
	MagnetometerScaled Mscaled = compass.ReadScaledAxis();	//Get Scaled Magnetometer
	MagnetometerRaw Mraw = compass.ReadRawAxis();			//Get Raw Magnetometer
	LGgyro.read();											//Get Gyro

	// offset compass by hard iron
	Mraw.XAxis += 40;
	Mraw.YAxis += 261;
	Mraw.ZAxis += 54;

	//write Acc, Mag, & Gyro values to record
	float AxisGs = Ascaled.XAxis;
	mD.vals.AcXPayload = AxisGs * 100;
	AxisGs = Ascaled.YAxis;
	mD.vals.AcYPayload = AxisGs * 100;
	AxisGs = Ascaled.ZAxis;
	mD.vals.AcZPayload = AxisGs * 100;
	mD.vals.MgXPayload = Mscaled.XAxis;
	mD.vals.MgYPayload = Mscaled.YAxis;
	mD.vals.MgZPayload = Mscaled.ZAxis;
	mD.vals.GyXPayload = LGgyro.g.x;
	mD.vals.GyYPayload = LGgyro.g.y;
	mD.vals.GyZPayload = LGgyro.g.z;

	//Perform tilt compensation calculation save to record
	sixDOF.compCompass(Mraw.XAxis, -Mraw.YAxis, -Mraw.ZAxis, Araw.XAxis, Araw.YAxis, Araw.ZAxis, true);
	float compHeading = sixDOF.atan2Int(sixDOF.xAxisComp(), sixDOF.yAxisComp());
	compHeading = compHeading /100;
	if (compHeading < 0 ) {
		compHeading = abs(compHeading);
	} else {
		compHeading = 180 - compHeading + 180;
	}
	mD.vals.CmpssPayload = compHeading;
	
	//get BMP085 values save to record
	dps.getTemperature(&TmpPayloadFULL); 
	dps.getPressure(&mD.vals.PressurePayload);

 	mD.vals.TmpPayload = (int16_t)(TmpPayloadFULL);	
	mD.vals.TmpExternal = (int16_t)(sensors.getTempC(outsideThermometer)* 10);
	sensors.requestTemperaturesByAddress(outsideThermometer); // Send the command to get temperatures
	
	//get GPS data
	byte lcount = 0;									//reset a loop counter
	while (!NEWGPSDATA && lcount++ < 255) {				//Exit the loop if we have new data or have been round it a number of times
		NEWGPSDATA = feedgps();							
	}
	if (NEWGPSDATA) {									//We have new GPS data, get all of the fields we need.
		int tmp_year = 0;
		gps.crack_datetime(&tmp_year, &mD.vals.month, &mD.vals.day,&mD.vals.hour, &mD.vals.minute, &mD.vals.second, &mD.vals.hundredths, &mD.vals.age);
		mD.vals.year = tmp_year - 2000;
		
        if (gps.altitude() != TinyGPS_HJOE::GPS_INVALID_ALTITUDE && gps.altitude() >= 0) {
			gps.get_position(&mD.vals.iLat, &mD.vals.iLong, &mD.vals.age);
			mD.vals.iAlt = gps.altitude(); 
			mD.vals.iAngle = gps.course();
			mD.vals.iHspeed = gps.speed(); 
			mD.vals.bSats = gps.satellites();
			mD.vals.ihdop = gps.hdop();
		}
		SET_LED_Status(SET_LED_BLUE,0);					//Flash blue to show we are getting GPS data
	} else {
		SET_LED_Status(SET_LED_GREEN,0);				//Flash Green to show that we are looping but not getting GPS data
	}

	if(ETSerialIn.receiveData()){

	}
  
	//flip flop between I2C's to avoid both on one loop
	if (SENDWIRE && (millis() - elapseSIM900) > WAIT_SIM900) {
		mD.vals.tCount++;
		ETI2Cout.sendData(I2C_SLV_SIM900_ADDRESS);		
		elapseSIM900 = millis();
	}

	if (!SENDWIRE && (millis() - elapseNTXB) > WAIT_NTXB) {
		mD.vals.tCount++;
		ETI2Cout.sendData(I2C_SLV_NTXB_ADDRESS);
		elapseNTXB = millis();
		//get I2C_SLV_SIM900_ADDRESS data
	}

	writeSDData();										//Write the data record to the SD card
	SET_LED_Status(SET_LED_OFF,0);						//turn off the LED
	NEWGPSDATA = false;									//Reset the New GPS Data flag
	SENDWIRE = !SENDWIRE;								//Flipflop this 
}