BMP180 I2C with banana pi

Others (MiLight, Hue, Toon etc...)

Moderator: leecollings

Post Reply
User avatar
SESTH
Posts: 5
Joined: Saturday 12 November 2016 23:23
Target OS: Raspberry Pi / ODroid
Domoticz version: V2023.1
Location: Germany
Contact:

BMP180 I2C with banana pi

Post by SESTH »

Hi All,

I'm trying to connect a BMP180 sensor to my raspian running on a banana pi board (BPI-M1). The BMP180 is connected to the GPIO pins 3 and 5. The BPI-M1 seems to have more i2c adapters as the raspberry pi.
i2detect -l

Code: Select all

i2c-0	i2c       	sunxi-i2c.0                     	I2C adapter
i2c-1	i2c       	sunxi-i2c.1                     	I2C adapter
i2c-2	i2c       	sunxi-i2c.2                     	I2C adapter
i2c-3	i2c       	sunxi-i2c.3                     	I2C adapter
i2c-4	i2c       	sunxi-hdmi-i2c                  	I2C adapter
I found my BMP180 at adapter 2.
i2cdetect -y 2

Code: Select all

     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
With the adafruit test script (https://learn.adafruit.com/using-the-bm ... on-library) I was able to read the sensor but I had to configure the adapter

Code: Select all

# Optionally you can override the bus number:
sensor = BMP085.BMP085(busnum=2)
Output:

Code: Select all

Temp = 27.90 *C
Pressure = 95266.00 Pa
Altitude = 516.41 m
Sealevel Pressure = 95271.00 Pa
Then I added I2C sensor BMP085/180 Temp+Baro to Domoticz but I only get error messages in the log.

Code: Select all

Error: BMP085: Error reading sensor data!...
I think the problem is that the sensor module looks at adapter 1 (raspberry pi Model B default adapter) and not at adapter 2. Is it possible to configure the the sensor module to adapter 2?
Regards, Thomas
Raspberry Pi 3B + 4, RFXtrx433
Banana Pi M1, RFLink
User avatar
SESTH
Posts: 5
Joined: Saturday 12 November 2016 23:23
Target OS: Raspberry Pi / ODroid
Domoticz version: V2023.1
Location: Germany
Contact:

Re: BMP180 I2C with banana pi

Post by SESTH »

Based on V3.5895 I made a patch and could solve the problem on the banana pi.

Code: Select all

diff --git a/hardware/I2C.cpp b/hardware/I2C.cpp
index d0d482b..b35bf09 100644
--- a/hardware/I2C.cpp
+++ b/hardware/I2C.cpp
@@ -116,10 +116,14 @@ I2C::I2C(const int ID, const int Mode1)
 
        m_stoprequested = false;
        m_HwdID = ID;
-       m_ActI2CBus = "/dev/i2c-1";
-       if (!i2c_test(m_ActI2CBus.c_str()))
+       m_ActI2CBus = "/dev/i2c-x";
+       for (int i = 2; i >= 0; i--)
        {
-               m_ActI2CBus = "/dev/i2c-0";
+               m_ActI2CBus[9] = i + '0';
+               if (i2c_test(m_ActI2CBus.c_str()))
+               {
+                       break;
+               }
        }
 }
But I have no raspberry pi at my current location to test the compatibility.
Regards, Thomas
Raspberry Pi 3B + 4, RFXtrx433
Banana Pi M1, RFLink
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest