SPI programming in Python - pyboard 1v1 + MPU9250

Status
Not open for further replies.

mheruian

Junior Member level 3
Joined
Jan 18, 2018
Messages
31
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
412
Hi Folks,

I am so beginner when it comes to embedded systems. I want to learn how to program them and a lot referred me to python since prototyping is fast and codes are simple to understand. I now know the basics of Python and I do like its straight-forwardness. I'm currently programming a Pyboard v1.1 and i now know the syntax on SPI also.

Now, i have my SPI device; it is a MPU9250 and I can't see python tutorial with it regarding SPI - all i2c. This leads me to reading internally the libraries of the SPI for MPU 9250 and done some coding like setting/writing modes then fetching raw/unprocessed gyro + accelerometer data and who_am_i of it. Now, when I'm going to test it out via interactive or script mode programming on python, i get data but all returns 0 or 0 > data. I do print the results and view them via python run by terminal/command line.

so far, i have tried (4) MPU9250 sensors and they always output 0x00 or 0 in whoami, (fifo count) sampling also of gyro and accelerometer is always 1. I have check my connections/wires and all are on their correct places:

MPU -> Pyboard:
SDA -> MOSI
ADO -> MISO
SCL -> SCK
nCS -> CS (GPIO)



Result of my simulation.



Then later on, the fifo count = 0 after few simulations

I don't have any oscilloscopes or logic analyzers as others suggest me to check it using those

I'll attach the code that I am using and THIS is reference (it's a github spi mpu9250 library, you can check its other files on that site also) I am decoding, what I'm after is the acquisition of initial raw data samples upon start up w/o processing them to real values and the who_am_i operation. The code is straight-forward where i didn't even create a separate file/library to handle spi transmission so you'll see a lot of redundant spi transmission codes.

I hope you can help me, Thanks
 

Attachments

  • main.txt
    3.6 KB · Views: 149

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…