# Raspberry Pi GPI pins and encoders

**URL:** <https://discourse.zynthian.org/t/raspberry-pi-gpi-pins-and-encoders/7180>\
**Category:** Building Zynthian\
**Created:** [August 10, 2022, 10:35am UTC](https://discourse.zynthian.org/t/raspberry-pi-gpi-pins-and-encoders/7180 "2022-08-10T10:35:52Z")\
**Posts on this page:** 20\
**Page:** 6

<div class="post-metadata">

**Author:** ![Lanfranco](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/lanfranco/32/8094_2.png) [@Lanfranco](https://discourse.zynthian.org/u/Lanfranco)\
**Post date:** [May 2, 2023, 2:30pm UTC](https://discourse.zynthian.org/t/raspberry-pi-gpi-pins-and-encoders/7180/102 "2023-05-02T14:30:09Z")

</div>

I built a minimal Zynthian with a Raspberry P3 B+ and I have to connect the 4 encoders… [Zynthian minimal....😉 - #3 by Lanfranco](https://discourse.zynthian.org/t/zynthian-minimal/7980/3)  
I found an MPC23008 chip in the drawer… so I do with this, as I did in the Zynthian I’m using now.  
Thanks again for the speed of your replies.

---

<div class="post-metadata">

**Author:** ![riban](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/riban/32/2331_2.png) [@riban](https://discourse.zynthian.org/u/riban)\
**Post date:** [May 2, 2023, 2:44pm UTC](https://discourse.zynthian.org/t/raspberry-pi-gpi-pins-and-encoders/7180/103 "2023-05-02T14:44:32Z")

</div>

Or you could connect the encoders directly!

---

<div class="post-metadata">

**Author:** ![Lanfranco](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/lanfranco/32/8094_2.png) [@Lanfranco](https://discourse.zynthian.org/u/Lanfranco)\
**Post date:** [May 2, 2023, 2:48pm UTC](https://discourse.zynthian.org/t/raspberry-pi-gpi-pins-and-encoders/7180/104 "2023-05-02T14:48:34Z")

</div>

I tried but also with gpio readall, but I can’t connect the encoders. I connected the 4 switches and they work.  
To find the pins can I ground one pin at a time?  
I would have liked to make do but unfortunately I can’t…

---

<div class="post-metadata">

**Author:** ![riban](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/riban/32/2331_2.png) [@riban](https://discourse.zynthian.org/u/riban)\
**Post date:** [May 2, 2023, 3:03pm UTC](https://discourse.zynthian.org/t/raspberry-pi-gpi-pins-and-encoders/7180/105 "2023-05-02T15:03:19Z")

</div>

To use encoders directly connected you must find 12 spare GPI pins, i.e. not Tx, Rx, I2C or I2S. Then assy these pins in webconf wiring.

---

<div class="post-metadata">

**Author:** ![Lanfranco](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/lanfranco/32/8094_2.png) [@Lanfranco](https://discourse.zynthian.org/u/Lanfranco)\
**Post date:** [May 2, 2023, 3:12pm UTC](https://discourse.zynthian.org/t/raspberry-pi-gpi-pins-and-encoders/7180/106 "2023-05-02T15:12:31Z")

</div>

I did this on the Raspberry p4 with few problems… but on the P3 it gives me absurd values on the gpio readall…  
The switches (which work fine) are connected to the physical pins 37,33,31,36  
Which according to the scheme are the GPIOs: 26,13,6,16  
While to work, on Webconf I wrote the GPIO pins (thanks to gpio readall)23,27,22,25…

This Raspberry pi3 B+ is the first board I bought years ago… I’ve done many projects with it… Could it be that some pins don’t work anymore?

---

<div class="post-metadata">

**Author:** ![Lanfranco](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/lanfranco/32/8094_2.png) [@Lanfranco](https://discourse.zynthian.org/u/Lanfranco)\
**Post date:** [May 11, 2023, 12:14pm UTC](https://discourse.zynthian.org/t/raspberry-pi-gpi-pins-and-encoders/7180/107 "2023-05-11T12:14:24Z")

</div>

I still need you… (What a bummer!!!)  
So I connected the 4 encoders to the integrated MPC…  
 ![wiring](https://discourse.zynthian.org/uploads/default/original/2X/2/218340ac499c72cb66eb8b016e0220f7222c334e.png)

The IC is seen but the 4 encoders don’t work…  
 ![Immagine](https://discourse.zynthian.org/uploads/default/original/2X/a/a39ca269ff9fcc88b2bac89fcb455c6a9a8a7ec0.jpeg)

---

<div class="post-metadata">

**Author:** ![jofemodo](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/jofemodo/32/2_2.png) [@jofemodo](https://discourse.zynthian.org/u/jofemodo)\
**Post date:** [May 11, 2023, 12:42pm UTC](https://discourse.zynthian.org/t/raspberry-pi-gpi-pins-and-encoders/7180/108 "2023-05-11T12:42:41Z")

</div>

I’m not sure that MCP23008 works for encoders. It’s possible that code doesn’t support this config, sorry. MCP23008 was used for switches only in the V1, but it was replaced by MCP23017 when encoders were also moved out of GPIO. You should use a MCP23017 that is well tested and supported for encoders & switches.

Regards

---

<div class="post-metadata">

**Author:** ![Lanfranco](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/lanfranco/32/8094_2.png) [@Lanfranco](https://discourse.zynthian.org/u/Lanfranco)\
**Post date:** [May 11, 2023, 12:44pm UTC](https://discourse.zynthian.org/t/raspberry-pi-gpi-pins-and-encoders/7180/109 "2023-05-11T12:44:06Z")

</div>

Many thanks Jofemodo. 😉

---

<div class="post-metadata">

**Author:** ![Keeze101](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/keeze101/32/21_2.png) [@Keeze101](https://discourse.zynthian.org/u/Keeze101)\
**Post date:** [May 11, 2023, 1:12pm UTC](https://discourse.zynthian.org/t/raspberry-pi-gpi-pins-and-encoders/7180/110 "2023-05-11T13:12:19Z")

</div>

> [@jofemodo](#):
>
> MCP23008 works for encoders

Oh yes it does. Where even was a special preset in the code known as prototype-kees in the beginning, which was based on the 23008.

---

<div class="post-metadata">

**Author:** ![jofemodo](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/jofemodo/32/2_2.png) [@jofemodo](https://discourse.zynthian.org/u/jofemodo)\
**Post date:** [May 11, 2023, 2:58pm UTC](https://discourse.zynthian.org/t/raspberry-pi-gpi-pins-and-encoders/7180/111 "2023-05-11T14:58:56Z")

</div>

Are you really sure? Perhaps if you config the MCP23008 like a MCP23017 and you don’t use the second bank. I never tried…

---

<div class="post-metadata">

**Author:** ![Lanfranco](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/lanfranco/32/8094_2.png) [@Lanfranco](https://discourse.zynthian.org/u/Lanfranco)\
**Post date:** [May 11, 2023, 3:24pm UTC](https://discourse.zynthian.org/t/raspberry-pi-gpi-pins-and-encoders/7180/112 "2023-05-11T15:24:31Z")

</div>

… but Jofemodo, in my first homebuilt Zynthian, I mounted this IC and it works from the first start up…

 ![1660465735714](https://discourse.zynthian.org/uploads/default/original/2X/f/fcd6a2fceee24f74085214677e0a3a47323899a4.jpeg)

---

<div class="post-metadata">

**Author:** ![jofemodo](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/jofemodo/32/2_2.png) [@jofemodo](https://discourse.zynthian.org/u/jofemodo)\
**Post date:** [May 11, 2023, 3:36pm UTC](https://discourse.zynthian.org/t/raspberry-pi-gpi-pins-and-encoders/7180/113 "2023-05-11T15:36:55Z")

</div>

OK. Then, most probably, zyncore lib is managing the chip as a MCP23017, using only the first bank.

---

<div class="post-metadata">

**Author:** ![Lanfranco](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/lanfranco/32/8094_2.png) [@Lanfranco](https://discourse.zynthian.org/u/Lanfranco)\
**Post date:** [May 11, 2023, 6:04pm UTC](https://discourse.zynthian.org/t/raspberry-pi-gpi-pins-and-encoders/7180/114 "2023-05-11T18:04:18Z")

</div>

I solved… this P3 B+ raspberry I had used for a thousand projects and probably there are some pins that don’t work… I swapped it with a P3 B+ that I used for Kodi which is even more recent… now it works all with the encoders connected directly to the GPIO… The damaged one for Kodi is fine…  
Thank you

---

<div class="post-metadata">

**Author:** ![Keeze101](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/keeze101/32/21_2.png) [@Keeze101](https://discourse.zynthian.org/u/Keeze101)\
**Post date:** [May 11, 2023, 7:06pm UTC](https://discourse.zynthian.org/t/raspberry-pi-gpi-pins-and-encoders/7180/115 "2023-05-11T19:06:57Z")

</div>

> [@Success Cases](https://discourse.zynthian.org/t/success-cases/41/12):
>
> Here are my pics of my Zynthian-from-scratch… The LCD is one I had laying around and thus the wiring needed some work. [Check…](https://discourse.zynthian.org/t/failed-starting-software-solved/) Now, build an nice enclosure and see if it fits next to my other homemade synths… Shown on the right: Mutable Instruments Shruthi, Xaviers excelent PreenFM2 and a Midibox Seq4 hardware sequencer innocent Cheers, Kees

😉

---

<div class="post-metadata">

**Author:** ![Lanfranco](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/lanfranco/32/8094_2.png) [@Lanfranco](https://discourse.zynthian.org/u/Lanfranco)\
**Post date:** [May 12, 2023, 6:17am UTC](https://discourse.zynthian.org/t/raspberry-pi-gpi-pins-and-encoders/7180/116 "2023-05-12T06:17:57Z")

</div>

> [@Success Cases](https://discourse.zynthian.org/t/success-cases/41/12):
>
> Now, build an nice enclosure

3D printer?.. But I think you use wood which is much nicer 💓

 ![1683872409448](https://discourse.zynthian.org/uploads/default/original/2X/9/9f9775f01fa7ec44a71c718571f02548ce7496ce.jpeg)

---

<div class="post-metadata">

**Author:** ![Lanfranco](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/lanfranco/32/8094_2.png) [@Lanfranco](https://discourse.zynthian.org/u/Lanfranco)\
**Post date:** [June 7, 2023, 5:18am UTC](https://discourse.zynthian.org/t/raspberry-pi-gpi-pins-and-encoders/7180/117 "2023-06-07T05:18:59Z")

</div>

A friend gave me this chip already packaged (MCP23017)… I need confirmation …  
PA0… PA7 = 100… 107  
PB0… PB7 = 108… 115  
… and the three switches ON?  
Many thanks

 ![mcp](https://discourse.zynthian.org/uploads/default/original/2X/6/649d8af1b4980eb5046d813c2b435a6be95c21e7.jpeg)

---

<div class="post-metadata">

**Author:** ![riban](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/riban/32/2331_2.png) [@riban](https://discourse.zynthian.org/u/riban)\
**Post date:** [June 7, 2023, 5:29am UTC](https://discourse.zynthian.org/t/raspberry-pi-gpi-pins-and-encoders/7180/118 "2023-06-07T05:29:00Z")

</div>

The DIP switches always confuse me. They often have an “ON” indication that when the switch is pushed that way, disconnects the circuit. You can either test the switch with a multimeter or simply connect the device to the I2C bus and detect its address when the switches are in any / each position. I would do that. I gives confirmation the chip is accessible on the I2C address you want to use.

PA0-PA7 are the GPI on port A so will be the first 8 pins configured in webconf. Similarly PB0-PB7 are the GPI on port B hence the next 8 pins configured in webconf. The V4 config assigns these to GPI 100-115 but you can configure in the Hardware-\>Wiring page of webconf.

---

<div class="post-metadata">

**Author:** ![Lanfranco](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/lanfranco/32/8094_2.png) [@Lanfranco](https://discourse.zynthian.org/u/Lanfranco)\
**Post date:** [June 7, 2023, 7:24am UTC](https://discourse.zynthian.org/t/raspberry-pi-gpi-pins-and-encoders/7180/119 "2023-06-07T07:24:23Z")

</div>

Perfect @riban.  
Many thanks

---

<div class="post-metadata">

**Author:** ![Lanfranco](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/lanfranco/32/8094_2.png) [@Lanfranco](https://discourse.zynthian.org/u/Lanfranco)\
**Post date:** [June 9, 2023, 2:09pm UTC](https://discourse.zynthian.org/t/raspberry-pi-gpi-pins-and-encoders/7180/120 "2023-06-09T14:09:20Z")

</div>

**HELP!!!**  
The MCP doesn’t work! I am attaching the links and Webconf settings.  
Thanks to anyone who helps me…

 ![mcp wiring](https://discourse.zynthian.org/uploads/default/original/2X/9/9b463ac654de6c60f3937c85f34278f2e6a34f70.jpeg)  
 ![wiring p4](https://discourse.zynthian.org/uploads/default/original/2X/7/752c14f8f7dc3306af9b666dbd4a7679867f5cff.jpeg)

---

<div class="post-metadata">

**Author:** ![riban](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/riban/32/2331_2.png) [@riban](https://discourse.zynthian.org/u/riban)\
**Post date:** [June 9, 2023, 2:14pm UTC](https://discourse.zynthian.org/t/raspberry-pi-gpi-pins-and-encoders/7180/121 "2023-06-09T14:14:09Z")

</div>

You have written INT1-4. What are they?

Definitely had to be 3.3V, not 5V else you may damage the Raspberry Pi.

[Previous page](https://discourse.zynthian.org/t/raspberry-pi-gpi-pins-and-encoders/7180.md?page=5)

[Next page](https://discourse.zynthian.org/t/raspberry-pi-gpi-pins-and-encoders/7180.md?page=7)
