XU4 odroid-wiringpi strange behaviour on I2C

Post Reply
Posts: 6
Joined: Wed Jun 24, 2020 3:28 pm
languages_spoken: english, italian
ODROIDs: Odroid XU4
Has thanked: 0
Been thanked: 0

XU4 odroid-wiringpi strange behaviour on I2C

Post by hellhammer09 »

Hi everyone,
I need your support for some strange behaviour of the odroid-wiringpi python package.

I tested the i2c communication with the AD5121 digipot from Analog Devices. The code is the following:

Code: Select all

import odroid_wiringpi as wpi

# Setup
i2c_dev = "/dev/i2c-1"
digipot_addr = 0x2F
i2c_df = wpi.iringPiI2CSetupInterface(i2c_dev, digipot_addr)

# Communication
## Write 0x40 on the memory
err = wpi.wiringPiI2CWriteReg(i2c_fd, 0x10, 0x40)
## Read value of the memory
response = wpi.wiringPiI2CReadReg16(i2c_fd, 0x3003)
I tried to perform the two steps separately, and the value of the digipot memory is set correctly. In fact, I wrote that value (and many other) with wiringpi and read back the memory content using

Code: Select all

i2ctransfer -f -y 1 w2@0x2F 0x30 0x03 r2
Every value set is read back correctly.

Instead, If I write and read back using wiringpi I always read two values:
  • the first call will read 0x7
  • the second and subsequent call will read 0x3807
But, there is an even stranger behaviour. When I perform the following steps:
  • write using wiringpi
  • read using i2ctransfer
  • read using wiringpi
the read from wiringpi is correct!

How can I solve this problem? Maybe it has to do with the I2C buffer not being managed correctly?
I took the wiringpi code from this topic viewtopic.php?t=27732 and from this wiki https://pi4j.com/1.2/apidocs/com/pi4j/wiringpi/I2C.html

Thank you in advance for your help.

User avatar
Site Admin
Posts: 34661
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
Has thanked: 828 times
Been thanked: 715 times

Re: XU4 odroid-wiringpi strange behaviour on I2C

Post by odroid »

Refer this example codes to see how we could access some sensors via XU4 I2C with WiringPi Python wrapper.
https://github.com/hardkernel/WEATHER-B ... on_weather

Post Reply

Return to “Hardware and peripherals”

Who is online

Users browsing this forum: No registered users and 2 guests