Community
cancel
Showing results for 
Search instead for 
Did you mean: 
AAmar2
New Contributor I
1,687 Views

How to use mraa.i2c with python?

Jump to solution

Hi! so I finally got internet access to my galileo gen2 as it was couple of months back. I wish to interface MPU6050 with gal gen2 and after some searching I found a blog by sarweshkumar(https://sarweshcr.blogspot.in/2015/03/mpu6050-with-intel-galileo-python.html?showComment=14836172499... c6454811632972619468 Internet of Things (IoT): MPU6050 with Intel Galileo (Python interface) ) that uses smbus to connect to MPU6050. Instead of smbus ,I wish to use i2c from mraa class in python.I also do not wish to use jeff rowberg's code in c(as I used to do with my arduino! after all the purpose of using intel gal gen2 is ability to code in PYTHON!) Can anyone help me,please?

0 Kudos

Accepted Solutions
idata
Community Manager
63 Views

Hi Mishra007,

 

 

Thanks for reaching out.

 

 

I just found this example in the UPM repository: https://github.com/intel-iot-devkit/upm/blob/master/examples/python/mpu60x0.py. Maybe it can be useful for you, I recommend you to give it a try and let us know if it works for you.

 

 

Have a nice day.

 

 

Regards,

 

-Leonardo

View solution in original post

8 Replies
AAmar2
New Contributor I
63 Views

FGT

Hi fernando,I forgot to tag you here! Any help my friend?

idata
Community Manager
64 Views

Hi Mishra007,

 

 

Thanks for reaching out.

 

 

I just found this example in the UPM repository: https://github.com/intel-iot-devkit/upm/blob/master/examples/python/mpu60x0.py. Maybe it can be useful for you, I recommend you to give it a try and let us know if it works for you.

 

 

Have a nice day.

 

 

Regards,

 

-Leonardo

View solution in original post

AAmar2
New Contributor I
63 Views

Intel Corporation wrote:

Hi Mishra007,

 

 

Thanks for reaching out.

 

 

I just found this example in the UPM repository: https://github.com/intel-iot-devkit/upm/blob/master/examples/python/mpu60x0.py https://github.com/intel-iot-devkit/upm/blob/master/examples/python/mpu60x0.py. Maybe it can be useful for you, I recommend you to give it a try and let us know if it works for you.

 

 

Have a nice day.

 

 

Regards,

 

-Leonardo

Hi i got it working,i cloned the entire directory in my /hom/root directory of galileo. I then connected the MPU6050 with the galileo and it was working!This is the screenshot!

Now My only concern is what are the gyro values?Are they quaternions?Euler angles?Or anything else?A better documentation of the code would have been really helpful! My only grievance with upm folks is that I couldnt find a decent documentation pdf like those available for other python libraries like scipy,numpy,control etc. I would really appreciate and help me if I can get my hands on the documentation or examples!

 

Thanks in advance!
idata
Community Manager
63 Views

 

Hi Mishra007,

 

 

I think that there is a lot information about this, if you check the MPU6050 datasheet ( https://www.invensense.com/wp-content/uploads/2015/02/MPU-6000-Datasheet1.pdf), you will find that the Gyroscope gives the values of Angular Velocity (degrees/sec) and the Accelerometer the unit used is g.

 

 

About the UPM documentation https://github.com/intel-iot-devkit/upm, you can find in the README information about the sensors, the API documentation and more. In your case there is information for your sensor in this link: http://iotdk.intel.com/docs/master/upm/classupm_1_1_m_p_u60_x0.html# details.

 

 

I hope you find this helpful.

 

 

Regards,

 

-Leonardo
AAmar2
New Contributor I
63 Views

Intel Corporation wrote:

 

Hi Mishra007,

 

 

I think that there is a lot information about this, if you check the MPU6050 datasheet (https://www.invensense.com/wp-content/uploads/2015/02/MPU-6000-Datasheet1.pdf https://www.invensense.com/wp-content/uploads/2015/02/MPU-6000-Datasheet1.pdf), you will find that the Gyroscope gives the values of Angular Velocity (degrees/sec) and the Accelerometer the unit used is g.

 

 

About the UPM documentation https://github.com/intel-iot-devkit/upm https://github.com/intel-iot-devkit/upm, you can find in the README information about the sensors, the API documentation and more. In your case there is information for your sensor in this link: http://iotdk.intel.com/docs/master/upm/classupm_1_1_m_p_u60_x0.html%23details http://iotdk.intel.com/docs/master/upm/classupm_1_1_m_p_u60_x0.html# details.

 

 

I hope you find this helpful.

 

 

Regards,

 

-Leonardo

Hi leonardo!

Thanks for the reply. After my post I did read the MPU6050 datasheet and came to realize it is a rate gyro--which means it gives "rate" instead of displacement.I even modified the upm code to get stable filtered displacement values. Now my concern is-- if the upm/mpu60x0.py code that you've suggested above displays rates--in degrees per seconds--then why is my galileo showing those weird rates(for instance 11.23 about x axis,-2.73 about y and -4.68 about z-axis!) even when MPU6050 was sitting idle on my table? Are these offsets?if so,then how to remove those offsets?

 

I also went ahead and saw the source code of pyupm-

http://iotdk.intel.com/docs/master/upm/python/_modules/pyupm_mpu9150.html pyupm_mpu9150 — upm v1.0.2-9-g0849fbc documentation

and couldnt find any subroutine to calibrate or remove offsets in mpu6050. Kindly help!

idata
Community Manager
63 Views

Hi Mishra007,

 

 

I'm not sure if they are offsets, in case they are you can set them as 0 in your own code. Now, if you need more information about the code that I provided you, I recommend you to try to contact the author of the code to assist you in a better way with your doubts.

 

 

Have a nice day.

 

 

Regards,

 

-Leonardo
AAmar2
New Contributor I
63 Views

Yep thats what I did too,I mean I tried to remove offset by keeping the mpu6050 on a flat surface without an motion and taking the average of first 10000 readings(this is purely arbitrary and can be any number) and then subtracting this average from every subsequent reading. I am able to get values with something like 0.0023 --which is much better than what it was earlier.

 

I was wondering if they have a function to remove offset thats all.Anyways thanks for the reply!
idata
Community Manager
63 Views

Hi Mishra007,

 

 

It was a pleasure to help you. Feel free to contact us when you have doubts.

 

 

Have a nice day.

 

 

Regards,

 

-Leonardo