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.
- 292 All Categories
- 104 Announcements & News
- 48 Product News - New Product/Product Change Notice/ End-of-life
- 181 Welcome Developers!
- 49 Unboxing & Project Sharing
- 20 Tech Updates
- 413 UP Products
- UP 4000
- 12 UP Xtreme i11
- 22 UP Squared 6000
- 40 UP Squared Pro
- 132 UP Xtreme
- 797 UP Squared
- 1.4K UP Board
- 86 UP Core Plus
- 217 UP Core
- 3 UP Xtreme Lite
- 41 UP AI Edge
- 213 Starter Kits & Peripheral