I2C programming

maxdodo
maxdodo New Member Posts: 4

I am new about UP square board, so for many of you this post could be not useful. I am trying to use I2C bus for a project that I am going to implement. To make a test a took a gyroscope/accelerometer based on MPU6050 chip (GY-521). I installed the mraa libraries and python libraries suggested in the wiki.
with i2cdetect I find the device recognized in the board (address 0x68) : sudo i2cdetect -r -y 5
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
So I suppose that the bus is number 5 and I wrote this simple code:

import mraa as m
x = m.I2c(0x05) # the bus number
x.address(0x68) # the address of sensor

Running the test I get:
Traceback (most recent call last):
File "test.py", line 3, in
x = m.I2c(0x05)
File "/usr/lib/python3.6/dist-packages/mraa.py", line 507, in init
this = _mraa.new_I2c(bus, raw)
ValueError: Invalid i2c bus

What is wrong ?
Thanks
Massimo

Tagged:
Privacy Policy