Home » Projects » Electronics Projects » Overcome NodeMCU Limitations with GPIO Expander

Overcome NodeMCU Limitations with GPIO Expander

GPIO Expander

You can add a GPIO expander to the NodeMCU for $2.

The other day, I was writing about NodeMCU GPIO pin limitations. Since then, I have uncovered an easy way to create many more GPIO pins for this device for only a couple of dollars. The solution is a PCF8574 IO Expansion Board I/O Expander available on EBay and elsewhere. I have ordered a few.

This type of expansion board uses the I2C bus, which is a two wire serial data bus. I2C or Inter-Integrated Circuit Bus. The I2C bus was originally designed for short data communications between chips on a circuit board. It is now mostly used for short distance serial communications between a microprocessor and a peripheral. It runs fairly fast and only needs two pins – one for clock, one for data. And, since it is addressable, you can daisy chain I2C peripherals on the same bus (same to pin connections) and set different addresses for each.

I2C GPIO Expander

In short, you can connect the GPIO expander to two pins on the NodeMCU. In turn, the GPIO expander will provide you with 8 additional GPIO. So, the net gain is six more pins. Although, if you are using some of the pins for input, you will also need another NodeMCU pin to read interrupts from the GPIO expander. These interrupts will tell your program when data is available to be read as an input (high or low).

If I daisy chain two of these expanders together, I will be able to get a net gain of 12 pins (16 – two wire I2C – two interrupts.) As far as I know, the NodeMCU Arduino core implements I2C in software, so I will have my choice of pins for I2C implementation.

This type of port expansion first became popular a few years ago for interfacing the LCD1602 display. This LCD display uses 8 bits of parallel data for writing to the display. In turn, this hogged 8 digital pins on the Arduino. As a result, several makers started providing a piggyback board from running this popular display on I2C rather than 8 Arduino pins.

Finally, if you want to roll your own, there are various I2C port expander integrated circuits available.

2 comments

  1. hehe, I picked up a couple of those as well. I’m trying to work out getting the two pins on the ESP-01 to work as i2c pins. Have you ever played with the ESP-05? They are touchy but I’ve been playing with micro-wiring the pins on the ICU on those – I want to get one to the point where I can make one programmable. While it doesn’t give you anything other than tx/rx pins I think they would be a great platform for a mini-web-server if you had no need to connect anything else to it.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.