Expand your GPIO! PCF8574 & MCP23008

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome to another vollog in this video we're going to take a look at an easy way of adding more gpios to your project because if you've been tinkering with electronics at some point sooner or later you're going to need more gpios than what's available from your microcontroller sometimes manufacturers do offer a higher pin count package with more gpios with approximately the same cpu inside but in the case of an esp32 module for example that's all you get and if you need more than that you're out of luck as far as options from the manufacturer and even if the manufacturer does offer a higher pin count option those are usually more expensive and given the current chip shortage that we're going through they might not be available for purchase i had such a need recently for a design of mine so i decided to do this video to show you an option that you can use for expanding the gpio capability of your circuit in my case it was the esp-32 thermostat valve controller circuit and you can find these on my tnd shop but this uh circuit makes use of pretty much all of the available gpio on the esp32 module so if i wanted for example to add some extra output channels i have no more available gpio luckily this problem is not new it has been around since the introduction of digital processors so there is a very convenient solution to our problem in the form of gpio expanders they can come in many shapes and sizes but the key feature is that they usually take a serial input which means a low pin count for the input and they provide a number of different outputs depending on the package so here is for example the data sheet for a very popular gpio expander chip this is the pcf 8574 and the datasheet is from nxp but this is manufactured by other companies as well and this is a big plus because there is a higher chance of finding these in stock if they come from multiple suppliers if we take a closer look at the block diagram we notice there is an i2c interface there are three pins for setting the address on the i2c bus and this way we could have up to eight of these chips on the same i2c bus each with its own address there are eight gpios at our disposal and we have some bonus features like the interrupt pin which could signal to our controller when there is a state change so we don't need to keep pulling the chip the chip will let us know when there is a change uh that is because the chip also provides input capability so by using just two pins for the i2c bus we get eight gpios in return which is pretty neat and this particular device can drive up to 10 milliamps per port with a maximum total of 80 milliamps per package but you can also parallel output ports together to drive more current to a single load if that is needed so it's maybe slightly less to what you would get with a typical microcontroller but still usable there are also variants of this chip that have a higher current drive capability up to 200 milliamps per package and they repurposed the interrupt pin as an address pin which expands the total number of devices on a single bus up to 64. so you will certainly find something that suits your needs in the available selection another popular option is the mcp23008 and this has similar functionality i2c or even higher speed spi input eight gpios three address pins up to eight devices on the same bus we have interrupt capability up to 125 milliamps total per package with up to 25 milliamps per pin so more than double of what was available on the previous chip now we have fairly similar specs and i could be using any one of these chips for my application the decision will probably come down to cost and availability for the particular package that i will end up using and also based on the results of the tests that i will be performing on these devices with these two options in mind i went ahead and designed an evaluation board in keycad because first of all i would like to evaluate how the firmware support is like for these chips and i also would like to confirm that there is no unexpected behavior because i will be using these to drive tracks that control some mains powered load and i want to make sure everything works as expected after finishing the kicad pcb design i ordered these boards from pcboa.com which are the official provider of printed circuit boards for the vlog channel and if you'd like to check out their services there will be a link in the description below pcbs turn out great same as always no quality issues with the boards from pcb way and let me explain uh what i have here because i have already assembled one of these we start with the two i2c expander chips that we would like to evaluate which are assembled on this pcb and on the output of these two chips we get a number of items we get leds for each of the eight outputs to signal their status we get the possibility to install some load resistors just to load the gpios and uh one of the outputs is also connected to a triac the same model of track that i will be using in my final application this pcb can help evalu evaluate these particular i2c expander chips but also the current draw into the triax that i am using with the help of the various jumpers available on this board and and here are a few tricks that you could use in your next pcb design like always use rounded corners on these evaluation boards because fr4 can be very sharp if you have those 90 degree corners it's much nicer to have these rounded corners because i'm going to be handling this board while testing it another quick tip is to add labels onto your evaluation boards and not only to evaluation boards but you really need more uh labels on evaluation boards specifically so that when you start testing your board all of the info is pretty much already available in front of you i use the kai blizzard plugin to generate these nice labels you can see here and uh it works really nice with kicad now for the firmware side of things uh it all depends on the platform you're writing code for i plan to use these with tesmota which already provides support for these gpio expanders the drivers are already integrated in the the firmware as long as you enable them with some config overrides so all i have to do is to compile tasmota with those config overrides to enable the drivers then configure the i2c port in test moda and they should be automatically detected now if you're using arduino all you have to do is to download the required library for these chips and start from the provided examples that's another nice thing about these chips which have been around for a long time they are quite popular so there are libraries already written to interface these over i2c and here are the two chips up and running with test mode as you can see i'm now getting 16 more gpios due to using these chips connected to e and esp32 i can control these just like any other output as if they were built into the sp 32 due to some magic happening behind the scenes however i am already noticing a difference between these chips in their output drive strength i'm pretty sure the difference in brightness for the status leds is visible on camera these are exactly the same leds through the same current limiting resistors and yet we get less brightness on the outputs of the pcf 8574 part so i'll have to investigate that further um maybe this is just a limitation of the chip because it can only drive 10 milliamps of output per pin even though these are high efficiency leds and they should light up just fine even with a couple of milliamps uh maybe there's some other issues that's preventing this particular chip of reaching its maximum output current capability but that's a topic for me to research separate from this video i hope this video was useful and you'll learn some things about i square c gpio expander chips and maybe this will help you use them in your next project as shown they are quite easy to implement the news only require a few pens and in return offer us a number of advantages same as all of my other projects this is an open source design there will be a link in the description below to a github repository where you can download the kicad project you can modify it and make your own if you found this video useful please consider hitting the like button or supporting the channel via patreon you can do that with as little as one dollar per month and you'll also get early access to the videos i'm publishing thank you for watching and i will be seeing you next time
Info
Channel: VoltLog
Views: 12,580
Rating: undefined out of 5
Keywords: Voltlog, PCF8574 GPIO Expander, MCP23008 GPIO Expander, I2C GPIO Expander, Tasmota GPIO Expander Config, Tasmota User Config Override, I2C GPIO Expander Evaluation Board, PCF8574 Evaluation Board, MCP23008 Evaluation Board, MCP23008 Tasmota Config, PCF8574 Tasmota Config
Id: LyRON_EK8Q4
Channel Id: undefined
Length: 9min 11sec (551 seconds)
Published: Tue Mar 15 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.