I2C on UP2 doesn't work as expected. Fails if using more than one sensor.
I'm trying to hook up 2 i2c sensors to my UP2. HTU21D and MPU6050, both running at 3.3 V. When there's just a single sensor on the bus it works fine. The moment I connect another sensor to the bus, the i2c bus fails. When that happens (usually instantly or in a matter of seconds), the script crashes with the following report:
Traceback (most recent call last): File "main.py", line 161, in <module> main() File "main.py", line 138, in main htu21d_status = htu21d.measure() File "#censored#", line 164, in measure self.htu.sampleData() File "/usr/local/lib/python3.8/dist-packages/upm/pyupm_htu21d.py", line 136, in sampleData return _pyupm_htu21d.HTU21D_sampleData(self) ValueError: UPM Invalid Argument: Unknown error in I2c::readReg()
Also when I check the "dmesg" kernel output, these messages come out:
i2c_designware i2c_designware.1: i2c_dw_handle_tx_abort: lost arbitration
i2c_designware i2c_designware.1: controller timed out
Another important fact is, that when this error occurs, the SDA line is stuck at roughly 0.15-0.20 V. SDA voltage doesn't go back up to 3.3 V when the bus is idle. The only way to make it go back to 3.3 V is to reconnect everything all over again (and of course use only one sensor).
I'm not using external pull-up resistors on the bus, because these modules have already inbuilt pull-ups.
I'm using MRAA/UPM library in Python. OS is Ubuntu 20.04.2 LTS. I installed the latest kernel (5.4.0-1-generic #0~upboard2-Ubuntu). I'm also on the newest BIOS (UPA1AM52). And of course as I mentioned already, I'm using the UP2 board.
Sensors are running at 3.3 V. I'm using I2C pins 3, 5. I2C speed is set to "standard" in the BIOS, so it's the slowest 100 kHz option.
WHAT I TRIED
I tried the exact same sensors (with all the same wiring and breadboard) on Arduino and it all worked flawlessly, so the problem will probably be somewhere in UP2.
I also tried to upgrade the BIOS from UPA1AM22 to the newest one. Unfortunately nothing changed.
I'm pretty confident that my code is fine. I'm also sceptical that there's some bug in the MRAA/UPM library that I'm using.
Any help is greatly appreciated. If I forgot to share any important info, I'll provide whatever is needed.