RPi.GPIO python module for Pine A64/A64+
#78
Has anybody used this library for I2C?

I got my first I2C device recently, this temp/pressure sensor. I tried reading it from an ESP8266 and an arduino first and didn't have any luck, so I decided to give it a try on the pine64. It shows up on i2cdetect, and if I run "sudo i2cdump twi1 0x76" it dumps a bunch of data, so I'm guessing it's wired up right.

I saw in the notes in github that this library has I2C "borrowed from pyA20", so a little googling found me some documentation here (you have to scroll a bit to get to the I2C info).

From that info, I put together this python script:
Code:
#!/usr/bin/env python3
from RPi import I2C

I2C.init("/dev/twi1")
I2C.open(0x76)

# set power mode to forced
I2C.write([0xF4,0x01])
sleep(1)

# dump data
I2C.write([0xF7])
value = I2C.read(1)
print(value)

I2C.close()
quit()

Now when I run this (as root) using python3, I get this error:
Code:
Traceback (most recent call last):
 File "./bmp280_readonce.py", line 2, in <module>
   from RPi import I2C
 File "/usr/lib64/python3.4/site-packages/RPi/I2C/__init__.py", line 4, in <module>
   from RPi._I2C import *
ImportError: dynamic module does not define init function (PyInit__I2C)

I tried changing the first line to use python2 instead of python3, and then I get this error instead:
Code:
Traceback (most recent call last):
 File "./bmp280_readonce.py", line 5, in <module>
   I2C.open(0x76)
IOError: [Errno 2] No such file or directory

Any idea what I'm doing wrong?
  Reply


Messages In This Thread
RE: RPi.GPIO python module for Pine A64/A64+ - by psychedup - 09-01-2017, 07:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  fm transmitter with gpio weasel18 2 4,852 09-10-2019, 04:28 AM
Last Post: desai_amogh
  How to use dts or other setup to declare gpio pin Interrupt (e.g. a button)? dkebler 1 3,614 06-12-2019, 10:37 AM
Last Post: dkebler
Lightbulb Sample GPIO codes highlighting RPi.GPIO-PineA64 and the PI bus MarkHaysHarris777 6 11,184 06-07-2019, 12:37 AM
Last Post: tllim
Star GPIO, SPI and I2C C++ Lib databit 7 11,257 02-04-2019, 05:45 AM
Last Post: Jeff R
Information Howto: Controlling Pine64 GPIO via the filesystem (sysfs) on linux pfeerick 4 11,902 01-24-2019, 03:36 AM
Last Post: Fifth
  GPIO and SPI SamR1 20 31,752 03-15-2018, 10:32 AM
Last Post: jomoengineer
Question GPIO shockr 7 14,841 03-11-2018, 01:52 AM
Last Post: jomoengineer
  Read GPIO problem shworker 14 21,268 08-17-2017, 01:21 PM
Last Post: martinayotte
  Cross-wired Uart Ports between two Pine Boards via Cat5 Cable MarkHaysHarris777 10 16,078 11-20-2016, 04:17 AM
Last Post: pfeerick
  GPIO fiq capability joseph 3 6,131 11-10-2016, 06:07 PM
Last Post: joseph

Forum Jump:


Users browsing this thread: 1 Guest(s)