#MPU6050 python3
Explore tagged Tumblr posts
diyrobotics-blog · 10 years ago
Text
RPi2 + MPU6050 (i2c 3d accelerometer+gyroscope)
I had been planning to use this MPU with the Nano I bought, however after having a blast playing with the kids on RPi2, I wanted to connect this I2C component to the I2C capable RPi2. How hard could it be?
Not hard as it turns out. The hardest part is getting used to Terminal.
Software install
Somewhere through the process, I found this guide, partly copied here in case something happened. There are pictures of the wiring too.
http://blog.bitify.co.uk/2013/11/interfacing-raspberry-pi-and-mpu-6050.html 
In the case of a RPi2, assuming you fixed python3 as in my previous post ‘Raspberry Pi 2 for the kids’ , I believe that the following should be avoided:
> sudo apt-get install python-smbus > sudo apt-get install i2c-tools
The following config file needs editing on with the ‘nano’ editor.
> sudo nano /etc/modules
You will need to add the following lines at the end:
snd-bcm2835 i2c-dev
On RPi2 I did not have issues with blacklisting.
I later found out that I had to reconfigure the board to enable I2C bus 1
Done via 
> sudo raspi-config 
then go to 
Advanced Options ->  I2C enabled <yes> -> I2c module loaded by default <yes>
Then reboot
> sudo reboot
Hardware install and identification
I soldered the pins that came with the MPU6050 in order to be able to insert it on the bread board.
After wiring, I saw a red light on the MPU6050 board, a good sign!
It was time to try and identify if anyone was detected on the I2C bus via:
> sudo i2cdetect -y 1
The result was positive for '68' , which is in hexadecimal for the address of MPU.
0x68 = 104
You can hard wire MPU6050 to respond on 0x69, if you wanted something else on 0x68.
Using MPU6050
At that point you can find the manuals for its I2C interface on the web, and/or find a partial driver in Python3 like I wanted to do
From the same author as above: 
http://blog.bitify.co.uk/2013/11/reading-data-from-mpu-6050-on-raspberry.html
I used it as base for making a teaching course for my 7year old, which we went through last Saturday. I will share it here after.
0 notes