I would like to send an atmospheric pressure sensor BMP180 to my controller. Here is my code:
Code: Select all
#include <Wire.h>
#include <ZUNO_BMP180.h>
ZUNO_BMP180 bmp;
ZUNO_SETUP_CHANNELS(
ZUNO_SENSOR_MULTILEVEL(
ZUNO_SENSOR_MULTILEVEL_TYPE_BAROMETRIC_PRESSURE,
SENSOR_MULTILEVEL_SCALE_KILO_PASCAL, // or 0 ?
SENSOR_MULTILEVEL_SIZE_TWO_BYTES, // or 4 bytes ?
2, // two decimals after dot
getter
)
);
word lastValue;
void setup() {
Serial.begin();
if (!bmp.begin()) {
Serial.println("Could not find a valid BMP180 sensor, check wiring!");
}
}
void loop() {
delay(1000);
// Get Temperature
Serial.print("Temperature = ");
Serial.print(bmp.readTemperature());
Serial.println(" *C");
// Get Pressure
Serial.print("Pressure = ");
Serial.print(bmp.readPressure()+800);
Serial.println(" Pa");
lastValue = (bmp.readPressure()+800);
Serial.println(lastValue);
// Calculate altitude assuming 'standard' barometric
// pressure of 1013.25 millibar = 101325 Pascal
Serial.print("Altitude = ");
Serial.print(bmp.readAltitude());
Serial.println(" meters");
// you can get a more precise measurement of altitude
// if you know the current sea level pressure which will
// vary with weather and such. If it is 1015 millibars
// that is equal to 101500 Pascals.
Serial.print("Real altitude = ");
Serial.print(bmp.readAltitude(99082));
Serial.println(" meters");
Serial.println();
// send report to controller (Life Line group)
zunoSendReport(1);
delay(2000);
}
word getter() {
return lastValue;
}
Temperature = 26.30 *C > check ok
Pressure = 101912 Pa > check ok with 800 Pa of compensation.
-29159 > Why ? What's variable type ? long ?
Altitude = 17.83 meters > check ok
Real altitude = -171.42 meters > check ok
- Should I use 2 bytes or 4 bytes in my ZUNO_SETUP_CHANNELS ?
- Should I use 0 or Scale type ?
Someone can help me ?