This erlang application works on the Raspberry PI using the "erlang_ale" library to interface using I2C to the BMP085 device.
Before you can get air temperatures or pressures, you need to start a process to communicate with the BMP085 device. Call bmp085:start_link()
and get {ok, <sensor pid>}
. Use the value in all your calls to get temperatures and pressures.
When you call bmp085:read_temp(Sensor_PID)
, you get {ok,<temperature in Celsius>, <temperature in Fahrenheit>}
.
For example, I called it now and got {ok,21.51,70.72}
.
When you call bmp085::read_pressure(Sensor_PID)
, you get {ok, <air pressure in Pa>}
. 1 Pa equals 0.01hPa or 0.01mbar.
For example, I called it now and got {ok,98958}
.
When you call bmp085:read_altitude(Sensor_PID)
, you get {ok, <altitude in meters>}
. This implements the algorithm found in the data sheet for the Bosch BMP180, but I'm not impressed with the results. It doesn't get close to the results I expect for today's test location in the U.S. Midwest. It is strongly affected by local air pressure variation. I guess that makes sense. Some stuff is "real".
All the development and testing of this software was done on a Raspberry PI model B using Erlang version 18. The sensor was an Adafruit Bosch BMP180 pressure sensor.