GPIO16 is always HIGH

I need advice on the very strange behavior of GPIO16. I try to build new firmware for the new Meshtastic schematic where the TXEN of the LoRa (I use EBYTE E22-900M30S module) is connected to the GPIO16 of my ESP32 WROOM-32 DevKit board. I have noticed that this pin is used for several boards as RESET_OLED and in SerialPlugin for RXD2. Even if I do not use SerialPlugin I have tried to reassign RXD2 to another pin. The device is working but became very hot in a short time, I measured and noticed that TXEN (GPIO16) is always high. I have double-checked all the code of firmware and could not see why it is happening.

In code, these pins (RXEN/TXEN) are set to LOW as OUTPUT: Meshtastic-device/SX126xInterface.cpp at e9f01de051b28c4d45e589f08102d73b48823025 · meshtastic/Meshtastic-device · GitHub
but why is TXEN (GPIO16) is always HIGH?

I have noticed this comment in SerialPlugin: Meshtastic-device/SerialPlugin.cpp at e9f01de051b28c4d45e589f08102d73b48823025 · meshtastic/Meshtastic-device · GitHub

As I understand it’s just initialized with pinMode(txPin, OUTPUT); as it happens in SX126xInterface.cpp.

There is no short or pull-up. Somewhere in the firmware set GPIO16 to HIGH. What could it be?

Without seeing what you’re doing, first thing that comes to mind is to to check what is causing a drain on the pin. If there is no short, the device shouldn’t get warm.

Do you have a schematic to show what you’ve put together?

I get high on GPIO16 even on this schematic (notice that GPIO16 not connected): Meshtastic-DIY/Mesh_Ebyte_E22-XXXM30S.pdf at main · NanoVHF/Meshtastic-DIY · GitHub

On a new schematic LoRa TXEN connected to the GPIO16.

And it’s detected on 38- and 30-pins versions of the WROOM-32 DevKits. I suspect that GPIO16 could be high even on TBEAMs.

GPIO16 is used as chip enable for the PSRAM!
You might need to edit the arduino espressif32 sdkconfig.h and recompile. Get a platformio dev environment running, then compile the code to pull all required files. Then edit the file:
~/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/config/sdkconfig.h

you can use this schematic for reference, regarding the PSRAM:

However I strongly suggest that you choose another GPIO since PSRAM might come in handy at some point in time.

1 Like

@PlumRugOfDoom, thank you for your help!

I use VS Code with PlatformIO on Windows 10. I tried to modify CONFIG_D0WD_PSRAM_CS_IO value in

  • ~/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/config/sdkconfig.h and
  • ~/.platformio/packages/framework-arduinoespressif32/tools/sdk/sdkconfig

without any changes. I clear the .pio/libdeps and .pio/build all the time, but GPIO16 is still HIGH.

I even tried to override CONFIG_D0WD_PSRAM_CS_IO value in platformio.ini:

; Meshtastic DIY v1b new Schematic based on ESP32-WROOM-32 & SX1262/SX1268 modules
[env:meshtastic-diy-v2]
extends = esp32_base
board = esp32doit-devkit-v1
build_flags =
  ${esp32_base.build_flags}
  -D DIY_V2
  -D EBYTE_E22
  -D CONFIG_D0WD_PSRAM_CS_IO=32
  -D CONFIG_D0WD_PSRAM_CLK_IO=33

No changes.

Of course, I will use different pin, but I want to clarify this issue for myself.

I am not sure if you also need to do something regarding UART2

Name No. Type Function
IO16 27  I/O  GPIO16, HS1_DATA4, U2RXD, EMAC_CLK_OUT

GPIO16 also has an internal pullup, not sure if you need to disable it as well.