Fill out above information andin all cases attach yourklippy.logfile (use zip to compress it, if too big). Pasting yourprinter.cfgis not needed Be sure to check our “Knowledge Base” Category first. Most relevant items, e.g. error messages, are covered there
Describe your issue:
Trying to use some buttons and leds with klipper. They are attached to my RPi via I2C by a MCP23017-Chip. Functionality is tested with a simple python-script, so the hardware works, but not within klipper. I defined a additional mcu i2c_rpi in my printer.cfg. But how do I access the buttons and leds now?
The example configuration in config/sample-raspberry-pi.cfg is very poor explained and I don´t know how to access the buttons and leds now:
# Example 3:Using a pin on another gpiochip connected to the RPi
# (in this case on an MCP23017)
[fan]
pin: host:gpiochip2/gpio7
Where do I define the I2C-address and the speed. How do I set led states and read buttons now from within klipper?
Any help would be appreciated
No that was not my intention.
But no problem. I will write a small python script which reacts to the button presses and than I will send a macro to the printer queue.
This should work either.
While it is true that Klipper cannot directly address this chip, it seems that the Linux Kernel can.
This means that this chip should simply appear as another gpiochipN where N is the number as assigned by the Kernel.
Thus, Klipper should be able to transparently access the GPIOs connected there without having to know where they come from.
The command gpiodetect should list the available GPIO chips as detected by the Linux kernel and if it appears there you should be able to do something like:
Thanks for your help and efforts, not to give up!
Your comment brought me to the solution:
I activated i2C over raspi-config and than i2cdetect -y 1 shows the address (which was 0x20 in my case). But gpiodetect showed only the “normal” GPIO ports from the raspberry pi, not the mcp:
To make the MCP23017 visible and usable with gpiodetect it is neccessary to load the dedicated driver overlay for this chip so the kernel can handle it as a GPIO. This has to be done by adding the overlay into /boot/config.txt:
dtoverlay=mcp23017,addr=0x20,noints=1
Only activating i2C over raspi-config is not enough to use the chip as GPIO!
Now gpiodetect shows: