Using simple sound on board that is running out of pins


I’m using T-RGB board from Lilygo T-RGB – LILYGO® for my project. I’d like to connect it to a simple piezo-speaker to produce simple sounds (also I don’t think I will need any amplifier). And the question is how to make it happen on the particular board.
The problem is, that it is not having any free pins available. Most of them are used by the display, last 2 (8 and 48) are used by the touch sensor. There is however unused I2C connector (through Grove) which also uses 8 and 48 pins, which raises some hopes.
The way I understand it, I will need I2C expander like this one PCF8574 GM electronic | elektronické součástky, komponenty and connect the piezo-speaker to that. I will then control the pins through for instance the TwoWire library.
It sounds bit convoluted though. Do you happen to see, guys, some more elegant solution, possibly without the extra board?

I don’t know this board at all, but on the boards I do have, I2C is an alternate function, so the I2C pins can be used as normal GPIO pins. If you have a data sheet for the board, there might be some information that explains how to use the pins as GPIO?

Just a thought.


Hey Norm, it’s a good point. Unfortunately the I2C on that system is used by touch control and I cannot give up that.
So far it seems to me I’ll just need to use the I2C expander board…

I wonder if you could use a shift register to go between the GPIO pins and the display? You would only need three input pins (plus VCC and GND) and would get 8 pins coming out which could go to the display? Like an extender for GPIO pins.

An Arduino example is here

Alternatively, does your display not work with I2C? That would require the I2C pins plus VCC and GND, but if it’s using the non-I2C variant, which it sounds like, does it operate in 4 bit mode as well as 8 bit? That would save you 4 pins. I have a few of those 16x2 displays and I can configure them for 4 or 8 bit communications.

Might help?


I had to learn what the shift register is :wink:, but in the end it still does not look like an option: The display comes with the board and is using SPI interface and most of he GPIO pins (all apart those 2 for I2C & touch screen). It would be very difficult / impossible to reconfigure it. Also, it would not save me from the need to have an external thing connected - the IC performing the shift.
The more I learn about the problem, the more it looks like I can’t avoid the I2C expander. Maybe it’s not a bad thing, maybe those extra pins could become handy later on.

1 Like

Oh well, we tried! Good luck with the extender, hope it works.


i2c is serial so you can add multiple modules with different addresses,

here is an i2c DAC