0
\$\begingroup\$

I want to connect 4x4 keypad to nodemcu, but some of the pins on board are already in use. For LCD I have used I2C backpack, and have an extra lying around. Can it be used to connect keypad to nodemcu board?

From what I have read, a 8-pin I2C gpio extender can be used for keypad. But isn't the LCD backpack same as 8-pin extender? (Just having more number of pins).

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

4 x 4keypad needs 8 pins and the I2C back pack you have also have only "8 port pins" which you can use.

The remaining 8 pins are power, I2C address and interrupt pins.

enter image description here

enter image description here

In the image, the orange color goes to the keypad matrix, the purples ones are static (power, address config.), you connect it once and leave it and the green ones are the lines to be connected to Node MCU.

As @Michael mentioned, you can use same I2C lines for both LCD and Keypad backpack.. Just make sure that I2C addresses are unique.

A0, A1, A2 can be used to change the I2C address. Please read data sheet of PCF8574. Ask again if you are not sure still.

\$\endgroup\$
1
  • \$\begingroup\$ If by "backpack" the OP is referring to the common modules available on ebay/aliexpress/etc, they usually have the A0, A1 and A2 lines brought out to a set of solder pads just next to the bus connector. Simply put a dab of solder between one or more of the pairs of pads to change the address. \$\endgroup\$
    – Jules
    Commented Jul 15, 2018 at 12:02
0
\$\begingroup\$

An I2C backpack for a typical character type LCD interface can be either a 16-bit wide port expander or an 8-bit port expander. If an 8-bit expander is used then the LCD data bus interface is operated in the 4-bit mode on the D4 to D7 inputs. The other 4 port bits of the expander are used for the LCD interface control lines. A 16-bit expander can allow the LCD interface to operate in 8-bit wide mode using the full byte wide data interface. This can lead to quite an improvement in LCD update speed.

For your 4x4 keypad you will need at least an 8-bit port expander. There should be no reason that you can add the second expander to the design on the same I2C bus as the LCD backpack as long as you make sure that the I2C slave address of the backpack device and the keypad devices are different. The slave address is often selected by strapping pins on the port expander part.

\$\endgroup\$
4
  • \$\begingroup\$ I understand. The I2C backpack I have is 8-bit wide port expander (PCF8574T). But since it has 16 pins and the keypad has 8 pins, how should the keypad pins be connected to backpack? \$\endgroup\$
    – kryptxy
    Commented Mar 25, 2018 at 18:29
  • \$\begingroup\$ If the backpack is already connected to the LCD you have to use a separate 8-bit port expander to connect to the keypad. I do not recommend trying to share the LCD connections with the keypad. You can get additional PCF8574's premounted on small breakout boards from Amazon or eBay for just a couple of US dollars. \$\endgroup\$ Commented Mar 25, 2018 at 19:06
  • \$\begingroup\$ I have one more backpack apart from the one connected to LCD. But unable to figure out how 8 pins should fit the 16 pins of backpack. \$\endgroup\$
    – kryptxy
    Commented Mar 25, 2018 at 20:14
  • \$\begingroup\$ @kryptxy - the pins are designed to fit the pads on an LCD1602 board, so not all of them attach to the PCF8574. Some of them connect to the power input, to the preset resistor that controls contrast, and some aren't connected at all (these boards use the 8-bit HD44780 connection in 4-bit mode, so the 4 low order data pins are unused). Look up data on the LCD1602 module to find the pinout: there will be connections from the IO expander to the RS, R/W, E, DB4-DB7 pins and to one of the two backlight pins (the latter will probably go through a transistor so that it can provide enough power). \$\endgroup\$
    – Jules
    Commented Jul 15, 2018 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.