This is not a problem but a fact. And there is also a precise reason: the first model of the PI, with 256 Mb ram uses the I2C channel 0 instead of the I2C channel 1 adopted in the further versions. So, as the Microstack accelerometers is hardware compatible with the PI model A+, the software no.
The key was to discover from what was depending this issue, that is the i2C channel settings. And nothing changes if you manually enable also the channel 1 because it is question of internal settings of the system.
The problem
Install the Microstack software as explained in the guides. Then with the suggested tests with the accelerometer you see that instead of the coordinates you see on the terminal a series of communication errors. The most important is the last line returned from the command
/usr/lib/python3/dist-packages/microstacknode/accelerometer $ python3 /usr/share/doc/python3-microstacknode/examples/accelcat.py
Traceback (most recent call last):
File "/usr/share/doc/python3-microstacknode/examples/accelcat.py", line 8, in <module>
accelerometer.init()
File "/usr/lib/python3/dist-packages/microstacknode/accelerometer/mma8452q.py", line 114, in init
self.i2c_master.open()
File "/usr/lib/python3/dist-packages/microstackcommon/i2c.py", line 61, in open
posix.O_RDWR | extra_open_flags)
OSError: [Errno 2] No such file or directory: '/dev/i2c-0'
The reason is that the PI tries to manage the i2c-0 while the Microstack is set to work with the i2c-1
Workaround
Enable the i2C0 (I have left also the i2C 1 but it is meaningless)
$>sudo nano /boot/config.txt
and add (if not yet present) the following three lines to the bottom of the file.
dtparam=i2c0=on dtparam=i2c1=on dtparam=i2c_arm=on
Then save the file and reboot. After reboot, with the command
$>i2cdetect -y 0
you should see a table with the currently installed i2C devices
0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- 1d -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- UU 70: -- -- -- -- -- -- -- --
At the address 0xd3 you will see 1d that is just the i2C ID of the Microstack accelerometer. All this is correct but it is only half of the solution of the problem. As a matter of fact, if you launch again the accelerometer test program you continue to see a problem connecting with the device.
The reason is that the Microstack-common land Microstack-node installed libraries try to open by default the i2C address 1 that we can't use
Make nother couple of extremely simple changes:
open with a sudo editor the following two files
/usr/lib/python3/dist-packages/microstacknode/accelerometer/mma8452q.py
and
/usr/lib/python3/dist-packages/microstackcommon/i2c.py
In one of the first top lines, you see
DEFAULT_I2C_BUS = 1
in both of them. Change to
DEFAULT_I2C_BUS = 0
save the files and the accelerometer will work!








Top Comments