Klipper Secondary MCU Arduino Uno MP6050 I2C CONFIG

Basic Information:

Printer Model: Ender 3
MCU / Printerboard: Creality 1.1.4

Describe your issue:

I want to add secondary mcu: arduino uno, and connect mp6050 to it and do resonance test.

According to guide:

Optional: Enabling I2C

Make sure the Linux I2C driver is enabled by running sudo raspi-config and enabling I2C under the “Interfacing options” menu. If planning to use I2C for the MPU accelerometer, it is also required to set the baud rate to 400000 by: adding/uncommenting dtparam=i2c_arm=on,i2c_arm_baudrate=400000 in /boot/config.txt (or /boot/firmware/config.txt in some distros).

What i should do if im using PC as klipper host?
Cant find any config.txt file. Im on UbuntuDDE Linux.
And raspi-config is not avaiable because im on PC.

First of all you need a I2C port. Usually PCs do not have those.
You can get them as USB to I2C adapters.

But I do not know if someone already use this combination.

Adruino Uno will be connected to MP6050
I need only klipper to speak with Uno as secondary mcu and read data from MP6050
I just dont know how to configure it.

You might have a look here ADXL345 invalid ID error.
I guess acaz2000 used a similar setup.

Good luck, hcet14

Well i did mistake in my post, not need to config anything in I2C its done automatically.
Got some problems, followed:

but in my case i just needed to change in .config

CONFIG_WANT_GPIO_BITBANGING=n
CONFIG_WANT_DISPLAYS=n
CONFIG_WANT_LIS2DW=n
CONFIG_HAVE_GPIO_ADC=n
CONFIG_HAVE_GPIO_HARD_PWM=n
CONFIG_INLINE_STEPPER_HACK=n

Nothing else done here, it compilled nice.
Gonna flash now.

All works fine.
ACCELEROMETER_QUERY
Show Values Nicely.

I have a similar setup: Klipper installed on a laptop, an MPU-6050 accelerometer connected to an Arduino (Nano)… but I don’t know how to make it work!
I add in my printer.conf :

[mcu nano]
serial: /dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0

[mpu9250]
i2c_mcu: nano

[resonance_tester]
accel_chip: mpu9250
probe_points:
0, 0, 20 # it’s a delta!
Could you share your printer.config?

Another question (:pray:): I installed into Arduino nano a sketch writed by myself but perhaps this procedure is not correct… I see sameone flashes Arduino using
cd ~/klipper
make clean
make menuconfig

…I’m confusing…
Thanks for any help and HAVE a NICE PRINTS

Your Uno should be on specified USB port(i use USB3.0), dont change it u need to attach it to specific USB port in your PC, like printer also.

U have attached it wrong(by-id) not works well.
Probably u have printer attached wrong, and this way uno(nano in your case) will be same wrong setup.

First setup your printer right.
I use UbuntuDDE.

So to check device look:
plug in printer(always in same usb port)

sudo dmesg | grep usb

your printer should be present
in my case its:
usb 5-1.4: ch341-uart converter now attached to ttyUSB0

then u do:

ls /dev/serial/by-path/*

in my case its:
/dev/serial/by-path/pci-0000:05:00.0-usb-0:1.2:1.2 /dev/serial/by-path/pci-0000:05:00.0-usb-0:1.4:1.0-port0

and i have in my printer.cfg:

[mcu]
serial: /dev/serial/by-path/pci-0000:05:00.0-usb-0:1.4:1.0-port0

start from there your printer.cfg file should look similiar to this.

Your printer in this case will be attached to same usb port always.
Then u do same thing for your arduino.

I made arduino_uno.cfg file and added to printer.cfg
[include arduino_uno.cfg]

and file looks like this:

[mcu nano]
serial: /dev/serial/by-path/pci-0000:05:00.0-usb-0:1.3:1.0-port0

[mpu9250]
i2c_mcu: nano

[resonance_tester]
accel_chip: mpu9250
probe_points:
117.5, 117.5, 20(thats my center of bed your can be different)

If u have problems with flashing i will post u solution, but setup things like i told u first.
Sorry for late answer. I will check it more often to help u a bit with this.

Before flashing do sketch to test your accelerometer.

I got on arduino uno connected to MP6050(for sketch and also for klipper):
VCC to +5V
GND to GND
SCL to SCL
SDA to SDA

Dont know how it should be connected on nano u should check it under ArduinoIDE
and do proper sketch first. Make it working there will be easier.

U got your system running ?

After some days and (… and some Arduino), I’m not able to have a good result!
This is my procedure:
-At first I load a sketch to test if the MS6050 works fine: all ok!

  • then, I run Kiauh, option 4 (Advanced) and then option 1 (build only): I set Arduino nano (328p) and save it
  • Before flashing, I change .config :
    CONFIG_WANT_GPIO_BITBANGING=n
    CONFIG_WANT_DISPLAYS=n
    CONFIG_WANT_LIS2DW=n
    CONFIG_HAVE_GPIO_ADC=n
    CONFIG_HAVE_GPIO_HARD_PWM=n
    CONFIG_INLINE_STEPPER_HACK=n
  • after that, I flash Arduino, reboot it and… nothing works!
    Apparently, Arduino lost the boot loader (Infact when I trie to load another sketch, Arduino doesn’t respond, so I have to restore 3 Nano :worried:)
    Probably I made a mistake but…where?

If u flashed it sucessfully, dont worry about it and attach it to klipper.
U cant use it in ArduinoIDE anymore, u can use it in klipper only now.

U can flash it ofc, but u need another arduino or spi programmer to use it in ArduinoIDE.

Try it in Klipper, thats what u wanted right?

Also u have all connections to PC like i told u before?

…mmmm…when I saw Arduino didn’t load the bootloader, I didn’t test it, because I thought an error in flashing! this evening (…and night!) I retry and :crossed_fingers:,
Thanks!!!

If its not working in ArduinoIDE its good sign, go for it :smiley:
Just read my previous post about connection to pc and configure it in linux.

…unfortunately, it doesn’t work with Klipper either!

I sent the command
ls /dev/serial/by-id/*

…and it shows me:
/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0
/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0

The first line refers to Arduino, the second to the Trigorilla board; so I set my printer.config:

[mcu]
serial: /dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0

and then

[mcu nano]
serial: /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0

[mpu9250]
i2c_mcu: nano

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

Restarting Klipper, I get

mcu ‘nano’: Unable to connect
Once the underlying issue is corrected, use the
“FIRMWARE_RESTART” command to reset the firmware, reload the
config, and restart the host software.
Error configuring printer

Man is that really hard to scroll post and read what i wrote?

I did wrote:

Your Uno should be on specified USB port(i use USB3.0), dont change it u need to attach it to specific USB port in your PC, like printer also.

U have attached it wrong(by-id) not works well.
Probably u have printer attached wrong, and this way uno(nano in your case) will be same wrong setup.

First setup your printer right.
I use UbuntuDDE.

So to check device look:
plug in printer(always in same usb port)

sudo dmesg | grep usb

your printer should be present
in my case its:
usb 5-1.4: ch341-uart converter now attached to ttyUSB0

then u do:

ls /dev/serial/by-path/*

in my case its:
/dev/serial/by-path/pci-0000:05:00.0-usb-0:1.2:1.2 /dev/serial/by-path/pci-0000:05:00.0-usb-0:1.4:1.0-port0

and i have in my printer.cfg:

[mcu]
serial: /dev/serial/by-path/pci-0000:05:00.0-usb-0:1.4:1.0-port0

start from there your printer.cfg file should look similiar to this.

Your printer in this case will be attached to same usb port always.

U CHECK IF KLIPPER CONNECTS TO PRINTER FIRST.

THEN U DO THE SAME PROCESS FOR ARDUINO.
IN A DIFFERENT USB PORT OBVIOUSLY.

I made arduino_uno.cfg file and added to printer.cfg
[include arduino_uno.cfg]

and file looks like this:

[mcu nano]
serial: /dev/serial/by-path/pci-0000:05:00.0-usb-0:1.3:1.0-port0

[mpu9250]
i2c_mcu: nano

[resonance_tester]
accel_chip: mpu9250
probe_points:
117.5, 117.5, 20(thats my center of bed your can be different)

No, the USB has never been changed.
I did this:

  1. I removed all USB devices and ran:

ls /dev/serial/by-path/*
ls: cannot access ‘/dev/serial/by-path/*’: no such file or directory

  1. I connected the printer:

ls /dev/serial/by-path/*
/dev/serial/by-path/pci-0000:00:12.0-usb-0:1:1.0-port0

  1. I entered in printer.config

[mcu]
serial: /dev/serial/by-path/pci-0000:00:12.0-usb-0:1:1.0-port0

I tested the printer, everything’s okay

  1. I inserted Arduino, without moving the printer’s USB cable:
    ls /dev/serial/by-path/*
    /dev/serial/by-path/pci-0000:00:12.0-usb-0:1:1.0-port0 /dev/serial/by-path/pci-0000:00:12.0-usb-0:3:1.0-port0

I entered in
[mcu nano]
serial: /dev/serial/by-path/pci-0000:00:12.0-usb-0:3:1.0-port0

and the error returns…

A doubt (maybe it’s not important…): I connected the 6050 power supply to 3V, but I saw a schematic where it was connected to 5V."

Ok, at least your printer works good, it should be no problems with connection now.
Remove printer from PC.
Now that usb port is only for printer.

Connect only arduino in different usb port.

ls /dev/serial/by-path/*

You get any output?

In my case i have:

/dev/serial/by-path/pci-0000:00:14.0-usb-0:1:1.2 /dev/serial/by-path/pci-0000:00:14.0-usb-0:2:1.0-port0

and my config looks like:

[mcu nano]
serial: /dev/serial/by-path/pci-0000:00:14.0-usb-0:2:1.0-port0

[mpu9250]
i2c_mcu: nano

[resonance_tester]
accel_chip: mpu9250
probe_points:
117.5, 117.5, 20

Please please please!

There is a feature in the editor to prevent code to be shredded due to the text format.

For all code snippets use Preformatet text (Crtl + e) feature of the editor here.

Format

1 Like

Here are enough users helping others!
Like in other forums there are some rules to follow.

2 Likes

I solved my problem! My Arduino nano was not able to comunicate at 250000 baud, but only at 115200… so I put “baud: 115200” into my mcu nano config and now klipper recognizes it.
It is strange because I had loaded some sketches setting 250000 baud and they worked (for example, serial monitor in ArduinoIDE works fine with this Arduino if I set 250000 baud)
Thanks!

1 Like