PINE64
Examples of I2c in Python - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: PINE A64(+) (https://forum.pine64.org/forumdisplay.php?fid=4)
+--- Forum: Pine A64 Hardware, Accessories and POT (https://forum.pine64.org/forumdisplay.php?fid=32)
+---- Forum: POT modules (https://forum.pine64.org/forumdisplay.php?fid=8)
+---- Thread: Examples of I2c in Python (/showthread.php?tid=2935)



Examples of I2c in Python - blanius - 12-12-2016

I want to try to use a RFID reader that is i2c controlled, Is there any example code on using the i2c on the Pine64?
How close is it to the Pi i.e. can I reference tutorials and examples from the Pi?


RE: Examples of I2c in Python - martinayotte - 12-15-2016

You can grab this library : https://github.com/swkim01/RPi.GPIO-PineA64
I've contribute to add I2c and SPI almost 4 weeks ago.
There is no example provided, but it should look like :

Code:
from RPi import I2C as i2c

i2c.init("/dev/i2c-1")
i2c.open(0x20)
i2c.write([0x00, 0x00])



RE: Examples of I2c in Python - HayseedGeek - 12-29-2016

(12-15-2016, 03:37 PM)martinayotte Wrote: You can grab this library : https://github.com/swkim01/RPi.GPIO-PineA64
I've contribute to add I2c and SPI almost 4 weeks ago.

I attempted to update my RPi.GPIO-PineA64 by cloning from GitHub and when I run Python setup.py install I get the  errors shown below. I'm sure somehow I've probably misconfigured my system or am overlooking something obvious or simple. Does anyone have any suggestions on correctly installing the RPi.GPIO-PineA64 package with all its new goodies?

_______________________________________

In file included from source/i2c/i2c_lib.c:34:0:
/usr/include/linux/i2c-dev.h:37:8: error: redefinition of ‘struct i2c_msg’
 struct i2c_msg {
        ^
In file included from source/i2c/i2c_lib.c:33:0:
/usr/include/linux/i2c.h:68:8: note: originally defined here
 struct i2c_msg {
        ^
In file included from source/i2c/i2c_lib.c:34:0:
/usr/include/linux/i2c-dev.h:89:7: error: redefinition of ‘union i2c_smbus_data’
 union i2c_smbus_data {
       ^
In file included from source/i2c/i2c_lib.c:33:0:
/usr/include/linux/i2c.h:129:7: note: originally defined here
 union i2c_smbus_data {
       ^
error: command 'aarch64-linux-gnu-gcc' failed with exit status 1


RE: Examples of I2c in Python - dkryder - 12-29-2016

you might try installing the build-essential package and see if that helps.


RE: Examples of I2c in Python - martinayotte - 12-30-2016

It seems that your kernel header files are no consistent each others, maybe one come from one version and the other from other.
Check the date of both /usr/include/linux/i2c.h and /usr/include/linux/i2c-dev.h to see if they are the same.
Which image are you using ? I strongly recommend one that use the longsleep kernel.


RE: Examples of I2c in Python - dkryder - 01-10-2017

(12-30-2016, 03:39 PM)martinayotte Wrote: It seems that your kernel header files are no consistent each others, maybe one come from one version and the other from other.
Check the date of both /usr/include/linux/i2c.h and /usr/include/linux/i2c-dev.h to see if they are the same.
Which image are you using ? I strongly recommend one that use the longsleep kernel.

you were correct about the dates of the files being out of sync. copied over those two from a new image and the compile ran successfully.


RE: Examples of I2c in Python - GliderHenry - 09-27-2017

Hello,
I have been working on a project that needs to use I2C from python.
With a small hack, I managed to get the adafruit I2C libraries working.
I have submitted a pull request via github to include the changes into adafruit's version.
If you need to, you can also find my modifications on github...

https://github.com/henryirvine/Adafruit_Python_GPIO.git

Happy hacking.
Henry


RE: Examples of I2c in Python - GliderHenry - 10-02-2017

I have been working on getting the Adafruit library for the BN055  9DOF IMU working.
The adafruit code only needs to be modified to set which pin you are using to run the reset pin.
The catch was that the GPIO needed to be identified as the RPi equivalent GPIO.
After that, everything works great.

It's a one line change in the example code, but I have forked the adafruit library and it is available on github here:
https://github.com/henryirvine/Adafruit_Python_BNO055.git

The base adafruit GPIO library I have also patched to work with Pine64, it is available on github here:
https://github.com/henryirvine/Adafruit_Python_GPIO.git

Have fun with your Pine64, I sure am!


RE: Examples of I2c in Python - tllim - 10-02-2017

(10-02-2017, 08:25 PM)GliderHenry Wrote: I have been working on getting the Adafruit library for the BN055  9DOF IMU working.
The adafruit code only needs to be modified to set which pin you are using to run the reset pin.
The catch was that the GPIO needed to be identified as the RPi equivalent GPIO.
After that, everything works great.

It's a one line change in the example code, but I have forked the adafruit library and it is available on github here:
https://github.com/henryirvine/Adafruit_Python_BNO055.git

The base adafruit GPIO library I have also patched to work with Pine64, it is available on github here:
https://github.com/henryirvine/Adafruit_Python_GPIO.git

Have fun with your Pine64, I sure am!

Appreciated and thanks on the code.