How to connect the MCP23017 GPIO Expander to an Arduino and Raspberry Pi

Sdílet
Vložit
  • čas přidán 5. 07. 2024
  • In this episode, we take a look at the MCP23017 GPIO Expander IC. With this IC, we can add 16 GPIO pins to the existing GPIO pins on an Arduino, Raspberry Pi, or any micro controller that has an i2c bus. They can be "stacked" for up to 128 additional GPIO pins! Bring on the LED's!
    In this video we cover:
    ► Physical connection of the MCP23017 to a Raspberry Pi
    ► Code examples for the Raspberry PI in Python
    ► Physical connection of the MCP23017 to an Arduino UNO
    ► Code examples for the Arduino
    As promised, all the code used in this video is on Github!
    github.com/makersdigest/T05-M...
    Parts that were used in this video:
    ● MCP23017 IC: amzn.to/2SZzJCp
    ● Arduino: amzn.to/2QgREHv
    ● Rapsberry Pi Kit: amzn.to/2Piy7kn
    ● Jumper Wires: amzn.to/2PkWxcX
    ● Breadboard: amzn.to/2QikbMQ
    Now go get creative! Share what you have made with me. I can be found at
    ● Facebook: / makersdigest
    ● Instagram: / makersdigest
    ● Twitter: / makersdigest
    ● Patreon: / makersdige
    If you liked this video, please consider subscribing. You can enable notifications for new videos when they are posted!
    See ya next time!
    #arduino #raspberrypi #makers
  • Jak na to + styl

Komentáře • 56

  • @DevonsWorkshop
    @DevonsWorkshop Před rokem +2

    Working on a 16 step switch project. Each key has an embedded led. For 16 switches I actually need 32 gpio. Your video helped me to figure out how to work with this chip properly with a Pi Pico. Very helpful video! Thank you.

  • @samk2630
    @samk2630 Před 3 lety +1

    Happy to stumble across your channel. Clear and concise, thank you!

  • @aryansatpathy2404
    @aryansatpathy2404 Před 3 lety +1

    This is soo helpful, I couldn't find any proper explanation anywhere else
    Helped me for my project

  • @croll_uk
    @croll_uk Před 2 lety

    Tip: Check the Red & Blue lines on the power rails for any breaks that indicate power termination. Nice video, subbed :D

  • @abdulkarim.jamal.kanaan
    @abdulkarim.jamal.kanaan Před 4 lety +1

    thank you very helpful video. one question, if modify the speed of i2c on raspberry, what the maximum number of chips we can use?

  • @jackyre477
    @jackyre477 Před 5 lety +1

    Awesome, thanks for explaining! :D

  • @MattRose30000
    @MattRose30000 Před 4 lety +3

    Are the indicator LEDs at the left just wired between VCC and ground? Do I not need a resistor?

  • @_teknq
    @_teknq Před 3 lety +1

    I am somewhat new to using the Raspberry Pi (3 B+) and I would like to expand my GPIO as shown in this video. I already have a 20x4 LCD display using pin 3 (SDA.1) and pin 5 (SCL.1). Can pin 27 (SDA.0) and pin 28 (SCL.0) be used instead to setup the expansion board while the LCD display is still connected to pin3 and pin 5?

  • @muaddibinho
    @muaddibinho Před 4 lety +1

    Damn this was good. Subscription added!

  • @Bradiant
    @Bradiant Před 3 lety +1

    That's some great quality video.

  • @pruch04
    @pruch04 Před 2 lety

    thanks dude!!!, you saved my life, get my like

  • @rccowboys
    @rccowboys Před 3 lety +1

    I really need to know how I can chain these together in a RPI3B+. Also How many can be chained together? Are the bandwidth considerations? I am trying to figure out a way to hook up about 20 stepper motors and a camera with a few sensors also. BTW awesome channel. Thank in advance for your reply.

  • @deanhuff123
    @deanhuff123 Před 3 lety

    Very helpful. I’m attempting to revive the old diamond rio MP3 player parallel interface so I can get some new music on my 23 year old MP3 player :)

  • @JeroenUE
    @JeroenUE Před 3 lety

    Nice explaining!! How can I use this in Domoticz?

  • @jenniferw8963
    @jenniferw8963 Před rokem

    Have you measured how many microseconds it takes for digitalRead() and digitalWrite() using these 16 GPIO pins via I2C compard to the pins which come on the microcontroller? Just wondering how much slower it is. Hopefully it doesn't take more than say 100 microseconds.

  • @Al-pr5dk
    @Al-pr5dk Před 4 lety

    Exactly what I was looking for. Thanks!

  • @roystervi
    @roystervi Před 2 lety

    hi is it possible to have the Arduino and Raspberry Pi connected to the same ic2 line at the same time?

  • @tinware
    @tinware Před 3 lety

    Do you know similar chips that work in USB 2.0 instead of i2c?

  • @burhanuddinbhiwaniwala618

    Wat if the power cuts... Can we save the status of th pins of MCP23017 in the eeprom of arduino so that it regains its last state before the power cut

  • @YoucefYazid
    @YoucefYazid Před měsícem

    Hello, At first thanks for informations, just i want to ask why we use R 1K to reset pin?

  • @Snugggg
    @Snugggg Před 2 lety

    I'm very very new to this but can someone broadly explain the difference between this and a shift register?

  • @oleksandrkosarevskyy882

    Hello. Thanx. Take the like. It works for me.

  • @dfmayes
    @dfmayes Před rokem +1

    I wouldn't recommend hooking up with power applied. Connect, check, then apply power.

  • @furkanalperyildiz3729
    @furkanalperyildiz3729 Před 11 měsíci

    I have a problem, can anybody help me ? I have a mcp2307 and raspberry pi4 which is commmunicate with i2c protocol. When I set logic high one mcp pin all pin goes high. Have you any idea on this issue?

  • @qozia1370
    @qozia1370 Před 10 měsíci

    What about esp32 running micropython? Thanks.

  • @djsbriscoe
    @djsbriscoe Před 3 lety

    Can you do a video on how to use this to control 1 or 2 i2c modules (say an I2C LCD to start with) using the arduino. For instance, how would you read from an I2C module and write to an I2C LCD through the MCP23017 (or MCP23S17 for SPI). Thanks.

  • @samuelhutagalung3357
    @samuelhutagalung3357 Před 3 lety

    are the 5v and gnd pin really must be all connected? or just for 9 and 10 pin.

    • @makersdigest4752
      @makersdigest4752  Před 3 lety

      It really depends on the grounds, pin 15,16,17 are the hardware address pins. I set them all to low to get a specific I2C address. But you can look at the datasheet on how to set specific addresses in case you are chaining more than one of these together. But personally, I like to set them all to low for single IC applications because it is stable.
      For the 5v on reset, I am going to say yes on that one for this application because that's the way I have always done it, and it works. I am sure there are other things you can do with that pin as it is a "reset", but would have to dig into the datasheet deeper than I have to figure it out. Otherwise, give it a try and see if it works!

  • @chadpriddle00
    @chadpriddle00 Před 2 lety

    I am using the Adafruit librabry and got my Python running. Is there a way to initiate the mcp() so that when I read the pins it says 1/0 not True/False?

    • @gamecoder3833
      @gamecoder3833 Před 2 lety

      you can always define a small function to convert T/F to 1/0, tho calling it everytime can get annnoying....
      maybe make the function name really small like b2b (boolean to binary)?

  • @powerralley
    @powerralley Před 3 lety +1

    Can someone briefly explain why a resistor is needed for the reset pin? Why can't it take the 3.3 straight?

  • @stevenbeebe35
    @stevenbeebe35 Před rokem

    He never said what resistor to use with the LED. Anyone have an answer to this? Thank You.

  • @milslion863
    @milslion863 Před 3 lety

    Hi. Sorry the stupid question... i can connect 4 mcp23017 to a Arduino Nano?? is for manage 64 reed switch (for a chess board). Thanks for your time.

    • @makersdigest4752
      @makersdigest4752  Před 3 lety +2

      MilS Lion I believe you can have 8 of those IC’s on one I2C bus. You will need to configure the address pins on each one to have a separate address in order for that to work. Check the data sheet on how to do that. In a nutshell, all the SDA pins connect together, as well as SCL pins. Then address correctly.
      Hope that helps!

    • @milslion863
      @milslion863 Před 3 lety

      @@makersdigest4752 Thanks!Yes that help.

  • @user-bw6uh9em4v
    @user-bw6uh9em4v Před 3 lety

    is this possible to use as analog input?

    • @makersdigest4752
      @makersdigest4752  Před 3 lety

      ぱんぷきん hi there, no. Check the mcp3008 video here for analog inputs. This IC is only digital input

  • @tiny-starship
    @tiny-starship Před 5 lety +1

    What luck. I just got 5x MCP21017's in the mail today and was looking for a guide on how to hook them up!

    • @makersdigest4752
      @makersdigest4752  Před 5 lety

      Tiny Starship awesome! Let me know if you have any questions, or if I can help.

    • @falseee4445
      @falseee4445 Před 4 lety +1

      @@makersdigest4752 hello, if we have 2 mcp 21017 then for the code will it be 0 to 32 and not 0 to 16?

    • @MGort-bb8op
      @MGort-bb8op Před 3 lety

      @@falseee4445 Do you have the answer to that question? I`am realy curious..

    • @atom6_
      @atom6_ Před 3 lety

      @@MGort-bb8op The 2nd mcp should be set up with a different i2c address, you will get another 0 to 15 ports available. See arduino.stackexchange.com/questions/30862/how-to-use-different-device-address-for-mcp23017-so-i-can-use-multiple-chips

  • @platinumphonesandcomputers

    a like for the intro

  • @newtitojff
    @newtitojff Před rokem +1

    I think I have fake ebay MCP's , that's the second tutorial I follow that does not work, Already bought MCP from Mouser :(

  • @eugeniostreliaevfilho8904

    very nice. pitty you stoped making videos

    • @makersdigest4752
      @makersdigest4752  Před 4 lety +1

      Eugenio Streliaev Filho thank you! I’ve stopped temporarily on this channel because I have been busy making videos over on Element14 Presents. I have plenty more scheduled for this channel and will hopefully get back to it sometime soon!
      Check out Element14 Presents for some different types of builds. Lots of other great folks making there also!

  • @josephtannenbaum8696
    @josephtannenbaum8696 Před 2 měsíci

    No longer works. Adafruit made changes to the library.

  • @mikesfarmmikesfarm3977
    @mikesfarmmikesfarm3977 Před 2 lety +6

    Sorry for comment, but do not teach new people to wire things up with power applied.