Page 1 of 1

Sharing input/output GPIO without frying anything

Posted: Fri Jun 16, 2023 6:47 am
by hertugen
Hello experts.

Newbie here. I have this little project, which I'm working on - it features an ESP32-WROVER, as well as a e-ink display.
It wakes up, updates the screen every hour, then goes back to sleep.
Image

My problem is that I would like to add an interrupt-based, freely programmable button or maybe even a 5-point joystick, which should "do something", like show the next/previous page, but all usable pins seems to have been taken and since the chip contains FSRAM, fewer are available than usual. Datasheet can be found here: https://www.espressif.com/sites/default ... eet_en.pdf

Is it possible to hijack pins, used for the screen? Since the software controls, when a screen is drawn, I thought about configuring pins as inputs per default and change to output when the screen updates. Is this the "usual way"? I mean, it won't potentially cause short circuits or anything, if the screen updates and the button is pressed at the same time? If so, which pin would you use? Can I just use TDX0/RXD0 freely, as long as the chip isn't flashed?

If I go for a 5-way joystick, what would you recommend? Some kind of multiplexer, so that I only need one GPIO?

General recommendations, hints and do's and don'ts would be really appreciated.

Re: Sharing input/output GPIO without frying anything

Posted: Fri Jun 16, 2023 8:43 am
by ESP_Sprite
Are you using SENSOR_VP/SENSOR_VN for anything? Those can be (input-only) GPIOs. You might be able to use the datalines to the EPD as well if the EPD doesn't drive or ground them when it's sleeping; if you're afraid of the buttons shorting the lines if you're sending data, you can add some small resistors (1K or so) between the buttons and the data lines.

Re: Sharing input/output GPIO without frying anything

Posted: Sat Jun 17, 2023 8:54 pm
by hertugen
Hello ESP_Sprite

I'm not using SENSOR_VP/VN for anything anymore - thank you for pointing that out.
Also, yes I'm afraid to have a short circuit, so I might go for for your solution at some point, but I've decided to go for the simple solution without the 5-way joystick and just a simple button, so using the available pins should be quite adequate.

Thank you for your assistance.

Re: Sharing input/output GPIO without frying anything

Posted: Mon Jun 19, 2023 7:58 pm
by MicroController
You could connect buttons to the data lines and GND via e.g. 5-10kOhm resistors. This protects against frying anything and should allow to switch the GPIOs to output for display data to input (with pull-up enabled) to read the button states. This may even provide enough headroom to not corrupt the data sent to the display if a button is pressed during transmission.

Re: Sharing input/output GPIO without frying anything

Posted: Tue Jun 20, 2023 5:24 am
by boarchuz
Conveniently, SVN and SVP are ADC pins, so you could also use one or both to handle all 5 inputs using ADC reads and carefully-sized resistors.