mBlock Extension:
Sensor BMP180 (ver. 0.0.3)
Extension for sensor BMP180
(Barometric, Temperature and Altitude sensor). The Extension contains commands for initializing the sensor, load temperature, load barometric pressure and altitude (in several user selectable units). Sensor-Arduino connection (for I2C interface Arduino Uno): SDA
– pin A4
, SCL
– pin A5
, GND
– ground pin and VIN
– pin +3V3
or +5V
(if 3V3-regulator is in the sensor included!)
- This command initializes the sensor
BMP180
. It is possible to set numerical corrections of measured quantities here. The sensor is relatively inexpensive, it measures well, but often has a systematic error (it needs to be corrected byoffset
). This function is the basic initialization – function must always be used at the beginning of the program (even if we do not want to correct the values)! - The function returns a numerical value (
float
) of the measured temperature. You can choose output units. The output value can be used for output, further calculation or in a condition. - The function returns a numerical value (
float
) of the measured barometric pressure. You can choose output units. - The function returns the numerical value (
float
) of the barometric pressure converted to sea level. (You can select the output units, you need to enter the current altitude.) This function (from ver. 0.0.3) recalculates the pressure using the ICAO formula – The temperature value is also used in the calculation. - The function returns a numerical value (
float
) of altitude, it is calculated from barometric pressure, temperature and the specified pressure at sea level. The value is rather informative, it depends on the current weather. (You can choose output units, the current pressure at sea level must be entered.)
Example:
As an example of using the extension, here is a code for measuring temperature, barometric pressure and altitude (using the BMP180 sensor).
All obtained data are listed on the Serial port
. The following figure shows the program code.
Auxiliary variables teplota
, tlak
and vyska
are used to store values. The output of the functions can be inserted also directly into output to the Serial Port
.
And this is the real result!