MCP23017 Port Expander and ESPHome: Add More I/O Pins to Your Project

preview_player
Показать описание
In this video, I'll take a look at using the MCP23017 16 port I/O expander with an ESP8266 (or ESP32) and ESPHome to add from 16 to 128 additional digital I/O pins to your project using just the 2-wire I2C bus from the ESP board. I'll cover the pin out, connections and limitations of the MCP23017, the ESPHome code and finally show how I use multiple port expanders to control 72 individual LEDs and three push buttons from a single ESP board to build a completely impractical clock!.

Chapter Links:
=============
00:00 Intro
01:26 ESP and MCP23017 Overview
03:57 Pinout and Limitations
06:29 ESPHome Component Mapping
07:28 Basic Bench Test
10:10 ESPHome Bench Test Config
11:29 Multiple expander wiring and ESPHome Config
13:07 A Crazy Clock Example with 75 I/O Pins
14:34 Building the Clock Face
16:16 Building the Clock Controller
18:44 Testing the Final Clock Build
19:36 Wrap Up And Other Ideas

Parts Used or Shown:
===================
You may not need all these parts, or may need additional parts, depending upon your particular project. This is just a list of what I used or showed in the video:

Other optional tools and items:
------------------------------

Some of these links may be Amazon affiliate links. Use of these links will not affect your pricing, but as an affiliate this channel may earn a small commission if you make a purchase. Any commission earned will go towards future projects and videos.

Addtional Information/Links:
===========================

If you'd like to help support this channel, or just say thanks, you can consider buying me a cup of coffee:

#esp8266 #esp32 #esphome
Рекомендации по теме
Комментарии
Автор

Awesome project! Indeed I want to see more of your videos!

PhG
Автор

Really useful overview given the limited IO on these uCs. Nice find and great explanation. Thanks!

Dorff_Meister
Автор

oh my, what a beautiful shelf you got there behind you.

MichaelHarto
Автор

I used a TCA9548A I2C multiplexer board to connect four BME280 sensors to a Wemos ESP8266. I nearly went cross eyed doing the Arduino IDE code and wiring. I cannot imagine doing this to a clock. Yet again, thank you for a great video.

mr.bianchirider
Автор

These projects are nothing like the other smart home channels are doing, keep up the great work and electrical details!

WndSks
Автор

love your videos and the whole frankenstein approach to this clock. looking forward to your pcb. cheers mate

MaultierKojote
Автор

What a nicely timed (see? :D) video! I'm about to build a clock which has 60 LEDs, very similar to yours! I'm not using port expanders, though, but I'm glad I learned something interesting today. Thank you!

Sekir
Автор

THANK YOU!!! Finally someone show an MCP23017 with an external power supply!!! THANK YOU. Yes, people show the typical 1 LED and switch powered off off the Raspberry or Arduino... Guess what happens one day when the student plugs in 8 or 9 LEDs and wonders why his Arduino or Raspberry fry like Kentucky Fried Chicken. THANK YOU.

stevenbeebe
Автор

Excellent tutorial and smart project...

santosh
Автор

Thank you for the video!
That's the first time I found a good explanation on how to expand ESP GPIOs and program them in ESPHome.

Would you consider making a video on multiplexing the analog inputs of an ESP and using that info in ESPHome?

You mentioned that possibility and I got quite interested.

wagnerfontes
Автор

Hi there, nice explanation! But let me suggest something:

Hey there, fellow electronics enthusiast!

I watched your awesome YouTube video about using the MCP23017 Port Expander with the ESP8266. Great stuff! I noticed that you mentioned the limit of using up to 8 MCP23017 chips due to the addressing, but I think I might have a cool idea to expand that even further.

Here's the thing: we can set the I2C address of each MCP23017, right? That gives us 8 possible addresses to work with. But what if we get a bit creative? Let's say we use another MCP23017 to control the address pins of the other MCP23017s dynamically. We could set up the controlling MCP23017 to switch between just two addresses for all the other chips.

Picture this: we've got our ESP8266 and a bunch of MCP23017 chips. We dedicate one MCP23017 as the "address controller." We wire up the address pins of the other MCP23017s to the outputs of this controller. Now, by toggling the outputs of the address controller, we can switch the addresses of the connected MCP23017s on the fly!

So, let's do the math. If we use two addresses and switch between them using the address controller, we can effectively double the number of MCP23017s we can use. That means instead of being limited to 8 chips, we could potentially use 16, 32, or even more! It's like having a whole army of I/O expanders at our command.

Of course, there are some practical limits to keep in mind. The I2C bus has a maximum capacitance it can handle, so we can't go too crazy with the number of devices. Plus, the more chips we add, the more complex the wiring and code will get. But still, it's a pretty neat trick to extend the capabilities of the MCP23017 beyond the standard 8-chip limit.

I thought this might be a fun and interesting addition to your video. Feel free to give it a try and see how far you can push the boundaries of the MCP23017. Who knows, maybe you'll end up controlling a massive array of I/O expanders and impress us all with your mad skills!

Keep up the fantastic work on your channel, and happy tinkering!

Cheers, Pekagi

pekagi-ehem.tivraction
Автор

Just stumbled upon your channel from the algorithm and I’m very pleased. Great content, clear and concise. Thank you for this.

You’ve given me an idea for a clock using WS2812 LEDs. Would only need 3 lines (GND 5v and data) to do something similar!

samk
Автор

Thanks for the video - very comprehensive. I've just spent several hours 'debugging' my code on a similar project only to casually glance at the pinout diagram of the MCP23017 in the top RH corner of your video. And there was me thinking that port A would be on pins 1 - 8 and port B would be on pins 21 - 28 .... I don't suppose I'm the only person who knew better than to RTFM. Doh!

MrBobtwang
Автор

Wow! I love the name Frankenclock, which looks like a lot of my projects. I have never used or so far needed a port expansion, but I may find a use case now that I have watched the video. As always, a great video was very well presented and produced.

My kitchen upper cabinet interior lighting (so far) consists of seven cabinets and I did use the Aqara Zigbee door switches, but they are all dimmable (PWM) and currently running at about 80% max brightness.

rodneysmith
Автор

Very clear! Do you happen to know about any solution that allows to connect an extra UART based sensor?

PersonXes
Автор

The Amazon link is sold out, any AliExpress links?

Tntdruid
Автор

Excellent tutorial Sir, but i have a question: i tried to expand Gpio pins using 74HC595 and i got noise problem, once switching on and off my roller shutter or my hair cutter !!! if use low voltage machines (12v ) no problem or no load also, and I found on the internet an article about noise problems using 220 v load on relays (the problem comes only with 74HC595
if I use the same relays with the main Gpio of my esp32 Gpio exp (13 or 14) everything is ok
so the question is: won't we get the same noise problem using the MCP23017? thank you Sir for replying .

hybrid.domotic
Автор

There are lots of models of port expanders. The APC old style display board for their PDUs use 9555. The relay boards use an 8 port expander.
It's a shame they all use 0x20 base addresses

danman
Автор

How to teach how to create 32 in and 32 output with mcp 23017 on esphome.
I copy your code and put it in Esphome plus any changes to the name of the problem and it doesn't work. does not compile

higorrezende
Автор

great and very useful but i have one question why SCL and SDA pins are not pull up its require to pull up this pins ?

deepdodiya