Accelerameter MCU 'rpi' shutdown: Unable to open i2c device

Basic Information:

Printer Model: Rat Rig V-Core 3 500
MCU / Printerboard: Octopus 1.1
klippy.logRatOSklippy.log (576.9 KB)

printer.cfg (14.7 KB)

Fill out above information and in all cases attach your klippy.log file. Pasting your printer.cfg is not needed

Describe your issue: Can not get my accelerameter working. I have a GY-521 MPU-6050 with a RPi 4b. I have followed all directions 3 times. Getting error: MCU ‘rpi’ shutdown: Unable to open i2c device. Something seems wrong in my printer.cfg. I beleive all the wires are fine.

Please help, I have been stuck on this for 2 days.

1 Like

Here is my wiring

Did you really enable i2c on the RasPi4?
https://www.klipper3d.org/RPi_microcontroller.html#optional-enabling-i2c
Especially the part with changing the boot/config.txt

I added dtparam=i2c_arm=on,i2c_arm_baudrate=400000 in /boot/config.txt
IC2 is on.
Got so frustrated, I just ordered the adx345. Maybe it will be an easier config

This is gonna sound a little dumb, but are you sure I2C is enabled? Did you get this screen when enabling it?
image
If you’re sure, then it’s possible that your accelerometer is 5V only. In that case, ordering a new one was the right call.

Best of luck!

Just as another data point, I’m having the same issue on RPI4b with same module, it works during initial tests like noise test but then stops during actual TEST_RESONANCES

I know the picture looks like the screw is shorting out the PCB but it is not… It is M2.5 screw.

I followed all instructions with raspi-config and the config.txt file too.

I think something is wrong with these particular modules? I have the same one as the OP.

Axes noise for xy-axis accelerometer: 9.330907 (x), 61.949372 (y), 17.011836 (z)
MEASURE_AXES_NOISE

accelerometer values (x, y, z): 10184.933862, -210.689746, -263.362183
ACCELEROMETER_QUERY

MCU ‘rpi’ shutdown: Unable write i2c device
Once the underlying issue is corrected, use the
“FIRMWARE_RESTART” command to reset the firmware, reload the
config, and restart the host software.
Printer is shutdown
Testing frequency 11 Hz
Testing frequency 10 Hz
Klipper state: Shutdown
Testing frequency 9 Hz
Testing frequency 8 Hz
Testing frequency 7 Hz
Testing frequency 6 Hz
Testing frequency 5 Hz
TEST_RESONANCES AXIS=X

Is this the same ADXL345 as in the first photo?
There a screw pushed a capacitor from its place critically next to a pin of another chip.
Maybe now this often gets contact.
Can you test a different accelerometer?
Or at least just put this sensor onto the desk so it stays still while the print head resonates. So you hopefully can check whether the sensor or the printer causes the shutdowns.

These are not ADXL345 - but MPU-6050 which is also supported by Klipper since last year: Measuring Resonances - Klipper documentation

I do not believe that broken component is the problem of the OP - mine has no broken components just to be clear. And both of the base tests work, but I do have more I could try just for posterity. I think they are just old cheap sensors and maybe they are defective or some previous version not supported by the current codebase.

Okay i just swapped out the MPU-6050 for another identical one direct from antistatic package and

xy-axis accelerometer measured no data
Klipper state: Shutdown
MEASURE_AXES_NOISE

So maybe just defective sensors :stuck_out_tongue:

Edit:
I tried two more sensors ( 4 total ) and none of them worked at all… So either something is very wrong with my config or most of these sensors are just bad… I don’t really know which. Ordered ADXL-345 :stuck_out_tongue_closed_eyes:

Edit:
Okay I have tried sooo many sensors and method… I just now switched it to use the I2C interface on my BTT Octopus Pro MB and it seemed to work at first but then started doing the same thing! It passes the Query and noise tests but then after about 10 samples on the resonance test it looses I2C connection and errors out…

Here is the log file if it is helpful to anyone…
klippy (8).log (2.1 MB)

This is the config I used for that:
[mpu9250]
i2c_mcu: mcu
i2c_bus: i2c1a

[resonance_tester]
accel_chip: mpu9250
probe_points:
180, 180, 20 # an example

I also tried changing the pullup resistors from 2.2k to 4.7k to no effect.

EDIT!!:

OMG It worked!!! Only took me all day and eventually using an RP2040 with very short jumper leads… I think the leads to RPI were too long… But even then not sure it would have worked. I did try with shorter leads at one point directly to the RPI and it didnt work, but maybe I was having some other issue at that point… Who knows :stuck_out_tongue:

I strongly suggest anyone trying to use the MPU-6050 get an RP2040 as your i2C bridge to klipper… Its only $5 and worth it… Or just use the ADXL345… This is just what I had today.

  pi@mainsailos:~/klipper $ ~/klipper/scripts/calibrate_shaper.py /tmp/resonances_x_*.csv -o /tmp/shaper_calibrate_x.png
  
  Fitted shaper 'zv' frequency = 91.2 Hz (vibrations = 18.9%, smoothing ~= 0.025)
  To avoid too much smoothing with 'zv', suggested max_accel <= 32400 mm/sec^2
  Fitted shaper 'mzv' frequency = 76.4 Hz (vibrations = 5.1%, smoothing ~= 0.037)
  To avoid too much smoothing with 'mzv', suggested max_accel <= 17200 mm/sec^2
  Fitted shaper 'ei' frequency = 89.6 Hz (vibrations = 3.0%, smoothing ~= 0.041)
  To avoid too much smoothing with 'ei', suggested max_accel <= 15000 mm/sec^2
  Fitted shaper '2hump_ei' frequency = 82.8 Hz (vibrations = 0.3%, smoothing ~= 0.079)
  To avoid too much smoothing with '2hump_ei', suggested max_accel <= 7600 mm/sec^2
  Fitted shaper '3hump_ei' frequency = 77.6 Hz (vibrations = 0.0%, smoothing ~= 0.136)
  To avoid too much smoothing with '3hump_ei', suggested max_accel <= 4400 mm/sec^2
  Recommended shaper is ei @ 89.6 Hz
  pi@mainsailos:~/klipper $ ~/klipper/scripts/calibrate_shaper.py /tmp/resonances_y_*.csv -o /tmp/shaper_calibrate_y.png
  Fitted shaper 'zv' frequency = 38.2 Hz (vibrations = 1.7%, smoothing ~= 0.109)
  To avoid too much smoothing with 'zv', suggested max_accel <= 5600 mm/sec^2
  Fitted shaper 'mzv' frequency = 38.4 Hz (vibrations = 0.0%, smoothing ~= 0.138)
  To avoid too much smoothing with 'mzv', suggested max_accel <= 4300 mm/sec^2
  Fitted shaper 'ei' frequency = 45.8 Hz (vibrations = 0.0%, smoothing ~= 0.154)
  To avoid too much smoothing with 'ei', suggested max_accel <= 3900 mm/sec^2
  Fitted shaper '2hump_ei' frequency = 57.2 Hz (vibrations = 0.0%, smoothing ~= 0.165)
  To avoid too much smoothing with '2hump_ei', suggested max_accel <= 3600 mm/sec^2
  Fitted shaper '3hump_ei' frequency = 69.0 Hz (vibrations = 0.0%, smoothing ~= 0.172)
  To avoid too much smoothing with '3hump_ei', suggested max_accel <= 3500 mm/sec^2

I had trouble with such jump wires too if they were too long.
Use a flexible shielded/twisted ethernet cable or a USB3 cable.
But nice that it works now!

I believe I have fixed a bug in the MPU-* handling code using the RPi <-I2C-> MPU sensors which makes them very unreliable and I would like to work with you to see if it fixes your problem and does not break anything else. I have tested it with all the equipment I have at home already.

Would you mind donating some of your time (and possibly sanity) so we can fix this for everyone?

My diagnosis of what you suffered is that the Raspberry Pi ran into the bug my github fork fixes (it should hopefully hit mainline soon).

The PR2040 Pico board has no pull-ups, and the ones built into the modules you have are typically 10K which is not small enough to support fast mode (400kbit/s) I2C reliably. This is why it worked only with an incredibly short cable w. the PR2040. To fix this add two resistors, one between 3.3V and SCL and one between 3.3V and SDA. I recommend 3.3kOhm (or 2K2). You can add them to the I2C module itself if you don’t want to add it to the Pi.

I would be very happy to hop on Discord and work with you.

My klipper fork with the fix is here:

I can try test it maybe? Just have tos we about installing your fork and connecting sensor back to the raspberry pi… I am Chester#6621 on discord.

1 Like

hi , i am mpu-6050 and original issue is fail .

but after analysing signal , the cause is simple , pullup not ok , and speed communication too slow

for working good

replace 2 pullup smd resistor with 1kohm absolutely

change speed transfert i2c to 1mhz absolutely

and add “ferrite filter round” on all cable rpi side if your cable is + to 1meter long !

i work fine with 1.5metre of simple wire “dupont”

but , is very good use soldering wire directly and not connector (bad contact in pin is possible cause to other error :slight_smile: )

i hope to solve !

mad’s