0

i connected mpu 6050 digital motion processor with 12c interface with my rspberry pi pico W. I coded it with micropython but when i read the accelerometer data registers, it shows in consistent values which keep on fluctuating a lot. can some help me in determineing what i am doing wrong.

i even tried connecting pull up resistors(4.7K) but nothing changed

Code Output

vimuth
  • 5,064
  • 33
  • 79
  • 116
  • The raw values do jump around a bit, but the difference you are seeing indicates a problem. I have used the MPU6050 and 9250 extensively with TI boards and Pico and Pico_w. I do not use python, so I don't know what checks it implements to ensure data is ready to be read before grabbing values from the I2C bus. That said, if you are reading at 1 micro-second intervals from the I2C bus -- and python is performing no check to ensure data is ready to be read -- then you are likely reading faster than valid acceleration values are updated in the MPU registers -- getting garbage data. – David C. Rankin Apr 28 '23 at 06:15
  • Try increasing the delay to 10 milliseconds so you are reading 100 times per-second and see if the data evens out. – David C. Rankin Apr 28 '23 at 06:17
  • but the sleep method takes argumets in seconds, thus here the delay is 1 second I initially tried with 0.1 and suspected the same thing thus i increased teh delay time but nothing changed – Anmol Goel Apr 28 '23 at 06:23
  • My bad -- like I said, I don't use python, the utime() through me a bit -- `u` generally being the prefix for `micro`... Post your code as test (indented by 4-spaces so it formats as code, or with `\`\`\`python` above the 1st line and `\`\`\`` after the last.) Where do you initialize the MPU? – David C. Rankin Apr 28 '23 at 06:24
  • the raspberry pi pico works on 3.3v logic can that be the problem? – Anmol Goel Apr 28 '23 at 06:27
  • Nope, MPU6050 works just fine with 3.3 (all the way down to 2.7) Are you using the code from the pico-examples repository for the MPU6050? They have a C example -- and I think they have a python one too. See [pico-examples](https://github.com/raspberrypi/pico-examples) – David C. Rankin Apr 28 '23 at 06:37
  • Specifically the [mpu6050_i2c](https://github.com/raspberrypi/pico-examples/tree/master/i2c/mpu6050_i2c) example. – David C. Rankin Apr 28 '23 at 06:42
  • i think i have solved the issue the output has stabilized – Anmol Goel Apr 28 '23 at 06:56
  • the problme was that i was reading from register 0x3B when i tried with 0x3A the output now remains stable and acts accordingly – Anmol Goel Apr 28 '23 at 06:57
  • Good deal. I didn't pick that up in a quick glance as the .png (which is why you include the text of your code in the question `:)` – David C. Rankin Apr 28 '23 at 07:12
  • I wrote an [mpu6050 driver](https://github.com/OneMadGypsy/upy-motion) for pico when it first came out. You can use it. My version has Kalman and complementary filters which will smooth out your results. – OneMadGypsy Apr 30 '23 at 05:34

1 Answers1

0

while reading data from the i2c bus the microcontroller recieves data from the register next to the register adress we give as an argument

since registers 3B to 40 contain accelerometer meter data in mpu6050 so i should have passed 0x3A register adress as an argument