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

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 มิ.ย. 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
  • แนวปฏิบัติและการใช้ชีวิต

ความคิดเห็น • 56

  • @DevonsWorkshop
    @DevonsWorkshop ปีที่แล้ว +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 3 ปีที่แล้ว +1

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

  • @aryansatpathy2404
    @aryansatpathy2404 3 ปีที่แล้ว +1

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

  • @jackyre477
    @jackyre477 5 ปีที่แล้ว +1

    Awesome, thanks for explaining! :D

  • @croll_uk
    @croll_uk 2 ปีที่แล้ว

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

  • @muaddibinho
    @muaddibinho 4 ปีที่แล้ว +1

    Damn this was good. Subscription added!

  • @pruch04
    @pruch04 2 ปีที่แล้ว

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

  • @Bradiant
    @Bradiant 3 ปีที่แล้ว +1

    That's some great quality video.

  • @abdulkarim.jamal.kanaan
    @abdulkarim.jamal.kanaan 4 ปีที่แล้ว +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?

  • @deanhuff123
    @deanhuff123 3 ปีที่แล้ว

    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 :)

  • @Al-pr5dk
    @Al-pr5dk 4 ปีที่แล้ว

    Exactly what I was looking for. Thanks!

  • @MattRose30000
    @MattRose30000 4 ปีที่แล้ว +3

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

  • @_teknq
    @_teknq 3 ปีที่แล้ว +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?

  • @oleksandrkosarevskyy882
    @oleksandrkosarevskyy882 5 ปีที่แล้ว

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

  • @rccowboys
    @rccowboys 3 ปีที่แล้ว +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.

  • @YoucefYazid
    @YoucefYazid 5 วันที่ผ่านมา

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

  • @JeroenUE
    @JeroenUE 3 ปีที่แล้ว

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

  • @jenniferw8963
    @jenniferw8963 ปีที่แล้ว

    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.

  • @dfmayes
    @dfmayes ปีที่แล้ว +1

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

  • @burhanuddinbhiwaniwala618
    @burhanuddinbhiwaniwala618 2 ปีที่แล้ว

    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

  • @furkanalperyildiz3729
    @furkanalperyildiz3729 10 หลายเดือนก่อน

    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 9 หลายเดือนก่อน

    What about esp32 running micropython? Thanks.

  • @roystervi
    @roystervi 2 ปีที่แล้ว

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

  • @tinware
    @tinware 3 ปีที่แล้ว

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

  • @djsbriscoe
    @djsbriscoe 3 ปีที่แล้ว

    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.

    • @makersdigest4752
      @makersdigest4752  3 ปีที่แล้ว

      I will put this on the list, good topic.

  • @Snugggg
    @Snugggg 2 ปีที่แล้ว

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

  • @samuelhutagalung3357
    @samuelhutagalung3357 3 ปีที่แล้ว

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

    • @makersdigest4752
      @makersdigest4752  3 ปีที่แล้ว

      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!

  • @powerralley
    @powerralley 3 ปีที่แล้ว +1

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

  • @chadpriddle00
    @chadpriddle00 2 ปีที่แล้ว

    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 2 ปีที่แล้ว

      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)?

  • @stevenbeebe35
    @stevenbeebe35 ปีที่แล้ว

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

  • @milslion863
    @milslion863 3 ปีที่แล้ว

    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  3 ปีที่แล้ว +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 3 ปีที่แล้ว

      @@makersdigest4752 Thanks!Yes that help.

  • @user-bw6uh9em4v
    @user-bw6uh9em4v 3 ปีที่แล้ว

    is this possible to use as analog input?

    • @makersdigest4752
      @makersdigest4752  3 ปีที่แล้ว

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

  • @tiny-starship
    @tiny-starship 5 ปีที่แล้ว +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  5 ปีที่แล้ว

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

    • @falseee4445
      @falseee4445 4 ปีที่แล้ว +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 3 ปีที่แล้ว

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

    • @atom6_
      @atom6_ 3 ปีที่แล้ว

      @@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
    @platinumphonesandcomputers 3 ปีที่แล้ว

    a like for the intro

  • @newtitojff
    @newtitojff ปีที่แล้ว +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
    @eugeniostreliaevfilho8904 4 ปีที่แล้ว

    very nice. pitty you stoped making videos

    • @makersdigest4752
      @makersdigest4752  4 ปีที่แล้ว +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 หลายเดือนก่อน

    No longer works. Adafruit made changes to the library.

  • @mikesfarmmikesfarm3977
    @mikesfarmmikesfarm3977 2 ปีที่แล้ว +6

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