This is the How To connect a I2C BMP085 barometric pressure and temperature sensor to Openwrt.
For Python, I2C installation and I2C hardware configuration tips, please read my previous post here:
[[How To] Add 20x4 LCD (HD44780) to a OpenWrt router via I2C](http://[How To] Add 20x4 LCD (HD44780) to a OpenWrt router via I2C)
NOTE: this device operates at 3.3V and does not need a voltage level shifter, so you can connect SDA and SCL pins of this device directly to the correspondent Gpio pins of the router
You can connect many I2c devices to the same bus (SDA and SCL), just wire them in parallel, but pay attention to the total current consumption and operating voltage of each device, you cannot connnect in parallel devices operating at different voltages!
Connections:
3V0 pin = 3.3V of the router
SDA = SDA GPIO the router
SCL = SCL GPIO of the router
GND = GND of the router
lets start:
to check if the system detects the device and to check the I2C address (it should be 77), do the following:
i2cdetect -y 0
test if everything worked. A device should be displayed. For me it looks like this:
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- 77
BMP180 Software
The easiest way to address the sensor is to take an existing library that already has all the functions. Adafruit offers such a library for Raspberry but luckily it also works for OpenWrt
We need to clone the repository of Adafruit (git must be installed).
opkg update
opkg install git git-http
git clone https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git
cd Adafruit-Raspberry-Pi-Python-Code/
git checkout 9ff733d59242a02f7ccd0222001ce80f6090a978
cd Adafruit_BMP085
Then we can do the first test:
python Adafruit_BMP085_example.py
The script will provide an output similar to this one:
Temperature: 25.70 C
Pressure: 1007.08 hPa
Altitude: 50.83