No video

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

  Рет қаралды 11,664

ResinChem Tech

ResinChem Tech

Күн бұрын

Пікірлер: 59
@MichaelHarto
@MichaelHarto Ай бұрын
oh my, what a beautiful shelf you got there behind you.
@Dorff_Meister
@Dorff_Meister 10 ай бұрын
Really useful overview given the limited IO on these uCs. Nice find and great explanation. Thanks!
@ResinChemTech
@ResinChemTech 10 ай бұрын
It's not something that will be used very often in most projects, but it is a nice component to have in your pocket should you need extra I/O. I was really surprised at how easy they were to code in ESPHome (and Arduino)... I expected that part to be a bit more complex, but once the port expander is defined, everything else works just like any other normal I/O pin. Now the really challenging part (for me) is creating that PCB! Thanks for commenting.
@mr.bianchirider8126
@mr.bianchirider8126 10 ай бұрын
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.
@ResinChemTech
@ResinChemTech 10 ай бұрын
Yeah... it was a "challenge"! I go into just a bit more detail in the written blog article, but those Dupont jumpers didn't want to stay put on the thin wires from the LEDs. Every time I tried to add a wire, I'd knock two or three others loose. I had to result to adding a little hot glue to each connection to keep it in place. Then there were multiple times, I'd get the pins reversed or just one breadboard hole off and the LEDs would light up in the wrong order. And reaching into that rat's nest of wires to move a jumper was no easy feat! Definitely not the optimal way to build a clock. But once I got the wiring correct, the Arduino code wasn't too bad in my case (it is actually Arduino code running the demo at the end). I skipped the A0/0 pin on each board and used pins 1-15 (from the Arduino side), so that lined up perfectly with minutes 1-15 in each of the four 15-minute segments. That made it easy to just loop from 1-15 in each segment to turn the LEDs on in order (or to calculate which LEDs to light up for minutes). Again, there's a bit more detail in the blog article. Thanks for watching... and as always, I appreciate the comment!
@WndSks
@WndSks 10 ай бұрын
These projects are nothing like the other smart home channels are doing, keep up the great work and electrical details!
@ResinChemTech
@ResinChemTech 10 ай бұрын
Thanks! I do like to focus on DIY smart home devices that don't need to rely on the Internet/cloud. And occasionally I run into a component like this one that might be useful for others that are doing their own DIY projects, so I try to show some examples of how it might be implemented, then the details on how to actually wire and use it. I rarely review any sort of commercial product (there are plenty of other channels that do that already)... unless I take a commercial product and try to find a way to make my own DIY version that is either lower cost or has more features. Thanks for watching... and taking time to leave a comment. I appreciate it!
@MaultierKojote
@MaultierKojote 10 ай бұрын
love your videos and the whole frankenstein approach to this clock. looking forward to your pcb. cheers mate
@ResinChemTech
@ResinChemTech 10 ай бұрын
Thanks! I had actually hoped I would have the PCB done and could show the completely built clock. But between actually doing the design and bench test, plus learning to use the PCB design software, I simply didn't have time. I had no idea going into it how much of a wiring mess it would turn out to be in the end! I hope to maybe do a follow up video down the road when I do get a PCB and finish off the 'real' clock. Thanks for watching and taking the time to leave a comment.
@Sekir80
@Sekir80 10 ай бұрын
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!
@ResinChemTech
@ResinChemTech 10 ай бұрын
You are most welcome! As I mentioned, this isn't necessarily the best design for a clock! I've built other clocks that use WS2812b LED strips (and therefore don't require the extra pins), but the goal here was to use individual LEDs as an example of using multiple port expanders. I like the look and function of this 'analog' version (other than my rushed and not-so-great paint job). If I ever get around to creating a PCB version, I'll probably start over with a new clock face. Good luck with your project and let me know how it turns out. And have a good 'time' building it!
@Sekir80
@Sekir80 10 ай бұрын
@@ResinChemTech For a tech demo using these expanders is quite well done! Of course it's easier to use WS2812, everything is just code, you can choose colors after building the clock, you can dim it easily, tons of advantages there. That's why I chose them. I found the same form factor as standard LEDs, 5mm, diffused. Good luck for the PCB version, that will look awesome! Good 'time', hehe, well done!
@rodneysmith1750
@rodneysmith1750 10 ай бұрын
@@ResinChemTech I am looking forward to the video about learning how to design and create your very own PCB, I might suggest PCBWay. I would also consider making a board for the clock back and connecting it with one or more IDC ribbon cables. the connectors are fairly easy with a vise or parallel jaw pliers.
@stevenbeebe35
@stevenbeebe35 9 ай бұрын
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.
@ResinChemTech
@ResinChemTech 9 ай бұрын
You are welcome! Yeah... I have heard of a lot of situations where people try to power external devices (most notably 5V LED strips) off the 5V pin of an MCU, particularly ESPs. They simply don't take into account the current draw and what the GPIO or other pin on the MCU or dev board is rated for. And yep... it might not happen right away... but eventually they end up damaging or destroying the board. That's why I try to stress in my videos when it is appropriate... or more importantly NOT appropriate... to provide power to an external component via the 5V or 3.3V pin from the MCU/dev board. And how to run power in parallel when necessary. But, alas, not everyone watches that portion of the video or opts to ignore it... then they post a comment or issue that their ESP8266/ESP32 quit working! Thanks for watching... and I greatly appreciate the kind comment.
@santosh5290
@santosh5290 5 ай бұрын
Excellent tutorial and smart project...
@ResinChemTech
@ResinChemTech 5 ай бұрын
Thank you! I appreciate it.
@pekagi-ehem.tivraction2894
@pekagi-ehem.tivraction2894 20 күн бұрын
Hi there, nice explanation! But let me suggest something: Hey there, fellow electronics enthusiast! I watched your awesome KZfaq 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
@MrBobtwang
@MrBobtwang 9 ай бұрын
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!
@ResinChemTech
@ResinChemTech 9 ай бұрын
You are welcome... and I'm glad if my video helped out, even if just a little. But don't feel bad. I don't know how many things I've fried due to not paying close enough attention to the pinout and doing something bone headed like reversing the polarity on the voltage leads. In fact, I'm working on a PCB version for this same clock and port expanders. The video will probably be released in a couple of weeks (still building) and I made a bone head move with this as well. I'll cover that in the video... but sneak peak, the LEDs are wired in backwards order from the way I intended. Thanks for watching and taking the time to leave a comment!
@santosh5290
@santosh5290 5 ай бұрын
Excellent video and explanation too
@samk2630
@samk2630 7 ай бұрын
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!
@ResinChemTech
@ResinChemTech 7 ай бұрын
Glad you found me! Yeah.. as I mentioned in the video, this isn't necessarily the best way to build a clock, but it was really just an example of how to use the port expanders. Funny thing, though... once I created a PCB and got rid of the breadboard, I really liked how the clock worked and have kept it on my desk. I have also built a couple of matrix clocks using WS2812b LED strips. These can also act as a scoreboard, countdown timer and a text display. I have a couple of videos covering them if you are interested.
@electronical_matrix
@electronical_matrix 8 ай бұрын
Great explenation
@ResinChemTech
@ResinChemTech 8 ай бұрын
Thanks! I appreciate the comment.
@rodneysmith1750
@rodneysmith1750 10 ай бұрын
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.
@ResinChemTech
@ResinChemTech 10 ай бұрын
Thanks... as always, I appreciate it! If you didn't catch it, when I showed the cabinet example and said it was "inspired" by a subscriber... that was you! I knew you were doing your project in a different manner, but it was your project that got me originally thinking about an example where a port expander might be used. So thanks for the inspiration on that. :) I do mention PWM briefly in the written version/blog article for this project. While I didn't test it, I suspect using these particular port expanders might have issues with PWM just do to the precise timing required. But maybe someone else has tried or used these (or similar) port expanders with PWM and can either confirm or deny that they cause issues.
@rodneysmith1750
@rodneysmith1750 10 ай бұрын
@@ResinChemTech That cabinet is done including power supplies, control, and wiring. I will be adding some RGB to the same setup for accents on the countertop and along the ceiling, the controller already has the D1 for the RGB controls mounted. That was my first with two D1s in the same box, kinda crowded...
@wagnerfontes2
@wagnerfontes2 4 ай бұрын
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.
@ResinChemTech
@ResinChemTech 4 ай бұрын
You are welcome. I'm glad you found the video helpful. I can certainly consider doing a video on an analog multiplexer, I'm just not sure when I might get around to it. I like to have a project or goal where I can demonstrate the use, so I'll have to find a good use case for myself. Thanks for watching!
@PersonXes
@PersonXes 8 ай бұрын
Very clear! Do you happen to know about any solution that allows to connect an extra UART based sensor?
@ResinChemTech
@ResinChemTech 8 ай бұрын
There are certainly options out there for expanding the number of UARTs on a device. A simple Google search for UART Port Expander will turn up multiple possibilities based on your particular MCU and needs.
@danman32
@danman32 10 ай бұрын
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
@ResinChemTech
@ResinChemTech 10 ай бұрын
Yep... as I mentioned near the start of the video, there are many, many different options for adding pins or expanding ports. But I just selected the MCP23017 as the one to show in this video... with the idea that if someone just beginning their journey with DIY electronics understood the concept of how to use an expander, then adopting to another IC or expander might be a bit easier. But I agree with you about the base address. There has been more than one occasion where I've wanted to use multiple I2C devices with the same controller (like a ToF sensor), but they don't have a way ( or at least not an easy straight-forward way without constructing some sort of interface and sending special commands) to change the I2C address. That was one thing I liked about the MCP23017... the three address pins made it very easy to change to any one of eight I2C addresses. But again, it is not the only option for something like this. Thanks for watching and taking time to leave a comment. I appreciate it.
@danman32
@danman32 10 ай бұрын
@@ResinChemTech the 9555 and the one on the relay board also have pins to change the address to one of possible 8, but all of them start at 0x20 so you're limited to 8 of any of them. I suppose one trick to go beyond 8 is to not use one of the addresses and use the A0-2 address pins as chip select pins. For example, tie A1,A2 to ground, and use A0 as chip select, never use 0x20 as that would always be in conflict when A0 is at ground (not selected) and vcc on specific chip to select as 0x21.
@hybrid.domotic
@hybrid.domotic 5 ай бұрын
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 .
@Tntdruid
@Tntdruid 10 ай бұрын
The Amazon link is sold out, any AliExpress links?
@ResinChemTech
@ResinChemTech 10 ай бұрын
Are you referring to the link for the MCP23017? I appreciate the heads-up but I did just recheck the link and I do show them in stock (at least in the US Amazon store). Of course you can do a simple search for 'MCP23017' on Amazon and see if other sellers might have them in stock. Or as you mentioned, check another site such as AliExpress. You might be able to find better pricing there, but with potentially longer shipping time. If you are seeing some other part that is sold out, please let me know. I try to check all my links the day before the video is published, but it is not unusual for an item to sell out after I publish (or simply become unavailable). Usually you can find the same item from other sellers listed on the same Amazon page that shows the sold out or discontinued item. But I appreciate the heads up. I try to update links if needed, but to be honest, it's nearly impossible to keep up with all the changes and sellers on Amazon.
@Tntdruid
@Tntdruid 10 ай бұрын
@@ResinChemTech yes the MCP,-
@MisterkeTube
@MisterkeTube 5 ай бұрын
Just wondering: can these things do PWM at a decent frequency? Ex. if you wanted to dim those minute-LEDs without changing the resistors ...
@ResinChemTech
@ResinChemTech 5 ай бұрын
I don't believe I mentioned in the video, but I do talk about PWM in the related written guide for this project ( resinchemtech.blogspot.com/2023/10/IO-expander.html ): "While PWM (pulse width modulation) is technically digital and is commonly used for things like controlling brightness of a light by quickly switching the signal on/off, it is unlikely that the MCP23017 would work well for PWM due to the precise nature of the timing required. But your mileage may vary."
@higorrezende59
@higorrezende59 4 ай бұрын
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
@infopourtous23
@infopourtous23 Ай бұрын
Hello. If i want to use pultiple transmeter(10 TX for exampl) and one receiver . How can i do that?
@ResinChemTech
@ResinChemTech Ай бұрын
I'm not sure if this particular port expander would work for UART/Serial communications due to precise timing required. I certainly didn't test the MCP23017 for serial TX. You might need to search for a multiplexer specifically made for UART communications. This is an example: amzn.to/4cRJJ9A but I have not tried or tested this particular module, so just consider it an example of something you might need to search for. There are very likely other options, so you could just try a search for "UART Multiplexer". Good luck with your project!
@plazmax
@plazmax 8 ай бұрын
Hello, I came across it while doing an internet search while working on a similar project. Your explanation is very nice and informative. I am trying to do it with a 5v 16 channel relay card and esp32 via the blynk application. If I add MCP23017 to the project, it seems like it will work. Thank you very much, it is appreciated.
@ResinChemTech
@ResinChemTech 8 ай бұрын
You are very welcome! In case you didn't catch it in the video description, I have a related blog article with a bit more information than I could present in the video. You may or may not find this helpful: resinchemtech.blogspot.com/2023/10/IO-expander.html As I mentioned in the video, it isn't necessarily the best way to build a clock but for me it was a good way to experiment with the port expanders. In addition, this project led me to developing my first custom PCB board (shown in a separate video) so that I could keep the clock without the breadboard mess. I actually really like the clock now that I have it mounted on a PCB, and it sits nicely on my desk. Thanks for watching. And best of luck with your project!
@deepdodiya1483
@deepdodiya1483 10 ай бұрын
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 ?
@ResinChemTech
@ResinChemTech 10 ай бұрын
MCP23017 has internal pull up resistors that are enabled by default when initially setting up the devices.
@deepdodiya1483
@deepdodiya1483 9 ай бұрын
can any issue when i connect pull up SCL and SDA with 10K ? Also I want to use all 16 GPIO as a Input pins with esp32 its right to connect directly or use any current limit resistor for each pins? @@ResinChemTech
@joshuaobelenusable
@joshuaobelenusable 10 ай бұрын
So for an ESP32, can this technique use both i2c busses for a total of 16 port expanders with 256 IO?
@ResinChemTech
@ResinChemTech 10 ай бұрын
Theoretically, yes I believe you can. I think how well it works will depend on the types of input/outputs you are using. For example, while PWM is technically an binary signal, I don't think these expanders would work very well for PWM output due to the precise timing required (although I have not tried a PWM signal with them). But yes, each I2C bus can have its own devices/addresses, so you could use the 8 available I2C addresses of the port expander on each of the two I2C busses on the ESP32 for a total of 16.
@Gitbizy
@Gitbizy 5 ай бұрын
How do I add multiple A/D ports to the ESP32? I want to be able to read ~5-10 analog voltages. Thanks in advance!
@ResinChemTech
@ResinChemTech 5 ай бұрын
Search for analog multiplexer. You should be able to find your answer there.
@don_cc123
@don_cc123 10 ай бұрын
Nice job explaining this chip. Any chance of publishing an STL file for the LCD bezel you created? I'm not a CAD guy and have been unable to find suitable bezels for my projects using both 2.8" and the larger 3.2" ILI9341 displays.
@ResinChemTech
@ResinChemTech 10 ай бұрын
Thanks. My thoughts on the .stl files was that if/when I get a PCB created, I'd create a Thingiverse project of for all the parts: bezel, stand, LED covers, etc. These might end up changing in the final version so I don't really want to put them out there now, as no one is going to build this particular "Franken-clock". But for the bezel, you definitely don't need anything as fancy as a CAD application. I just quickly did this in (free) Tinkercad: It is just a 2mm tall rectangle that measures 82 x 64 mm. Then a rectangular 'hole' that is 66 x 48 mm is centered over the initial rectangle and the two objects are "grouped" using the Tinkercad function. That leaves you with the frame you see in the video. It really is that easy and there is nothing fancy or difficult about creating it. I then simply super glued it to the front face of the clock. You could easily adapt this to both size displays by just altering the dimensions of the initial rectangle and the 'hole' that you insert into it. If you haven't tried Tinkercad, I'd highly recommend it as it is an easy to learn and easy to use solution for creating basic shapes for things like this or simple geometric shapes for controller enclosures, etc. without the steep learning curve of more sophisticated CAD-like applications.
@don_cc123
@don_cc123 10 ай бұрын
Thanks so much for the details, I will try to give it a go with Tinkercad! @@ResinChemTech
@northstar5405
@northstar5405 10 ай бұрын
Hello Mr. In the last couple of weeks I had an opportunity to purchase esp32 development board and w2812b LEDs and made it works per your basis instructions (I'm not techies guy) however, how do I able to use multiple LEDs strips on single esp32?, thank you
@hybrid.domotic
@hybrid.domotic 5 ай бұрын
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 .
@ResinChemTech
@ResinChemTech 5 ай бұрын
I haven't tried using the 74HC595 as a port expander. Nor have I tried using the MCP23017 for controlling relays with high voltage AC. So I really can't tell you if you would experience the same issue with the MCP23017 or not.
Forget WiFi! This Wireless Method is WAY Better?
12:14
GreatScott!
Рет қаралды 564 М.
Level Up Your WLED Projects: A Guide to adding Components (no code!)
43:37
а ты любишь париться?
00:41
KATYA KLON LIFE
Рет қаралды 3,6 МЛН
He bought this so I can drive too🥹😭 #tiktok #elsarca
00:22
Elsa Arca
Рет қаралды 9 МЛН
🩷🩵VS👿
00:38
ISSEI / いっせい
Рет қаралды 28 МЛН
Oh No! My Doll Fell In The Dirt🤧💩
00:17
ToolTastic
Рет қаралды 11 МЛН
Add more than 100 GPIO pins to your PICO!!!!
24:49
Making Stuff with Chris DeHut
Рет қаралды 10 М.
Interface ESP32 with the PCF8575 I/O Port Expander
16:58
DonskyTech
Рет қаралды 7 М.
An Improved Multi-sensor
29:40
ResinChem Tech
Рет қаралды 31 М.
WLED: Mastering Segments, Multi-pin & Multi-Controller Setups
29:53
ResinChem Tech
Рет қаралды 24 М.
Practical Guide to PCF8574: Adding Extra Pins for Arduino
16:46
Mario's Ideas
Рет қаралды 6 М.
MCP23017 GPIO Expander Demo PCB: Arduino Uno Relay Driver
9:46
Gadget Reboot
Рет қаралды 9 М.
Try these 16 Brilliant ESP32 projects!!!
11:18
ToP Projects Compilation
Рет қаралды 570 М.
CHEAP DIY BOOST GAUGE
43:58
upir
Рет қаралды 163 М.
Revolutionize Your ESP32 Projects with Live GPIO Pin Monitoring!
8:08
The Last Outpost Workshop
Рет қаралды 166 М.
а ты любишь париться?
00:41
KATYA KLON LIFE
Рет қаралды 3,6 МЛН