Hizem Mariem
Hello everyone,
I’m facing an issue when migrating an HMI project between two hardware configurations in OpenPLC, even though the code works perfectly in Arduino IDE. Here are the details:

Working Setup (Functional):

  • Board: ESP32-WROOM
  • Display: OLED
  • Library: U8g2
  • Environment: OpenPLC Editor
  • Result: 100% functional

New Setup (Problematic):

  • Board: ESP32-S2
  • Display: TFT 1.14" (ST7789)
  • Library: Adafruit TFT (Adafruit_ST7789)
  • Environment: OpenPLC Editor
  • Result: Fails to work

Observed Issue:

The same code works perfectly in:
  1. ESP32-WROOM + OLED under OpenPLC
  2. ESP32-S2 + TFT under Arduino IDE
...but fails on ESP32-S2 + TFT under OpenPLC.

Technical Details:

  • All required libraries are properly installed
  • Wiring has been verified and tested under Arduino IDE (functional)

Questions:

What could explain this incompatibility with OpenPLC on ESP32-S2 + Adafruit TFT, when everything works under Arduino IDE?

Additional Notes:

  • The issue seems related to OpenPLC’s configuration rather than the code itself
  • Hardware components are confirmed functional (tested in Arduino IDE)
  • OpenPLC compilation succeeds, but the display doesn’t behave as expected
Thank you in advance for your insights!
Reply 0 0
thiagoralves
Hard to tell without seeing your project and your code. I would recommend starting with something very simple and then grow from there.
Reply 0 0
Hizem Mariem
I've created a minimal test case for the ESP32-S2 with TFT display that works in Arduino IDE but fails in OpenPLC.

Minimal Test Code (Fails in OpenPLC's Arduino Extension but works in Arduino IDE):

#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ST7789.h>

// Custom SPI pin configuration for ESP32-S2
#define TFT_CS    34
#define TFT_RST   3
#define TFT_DC    6
#define TFT_SCK   36
#define TFT_MOSI  35

Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCK, TFT_RST);

void sketch_setup() {
  Serial.begin(115200);
  
  // Initialize display
  if(!tft.init(135, 240)) {
    Serial.println("TFT init failed!");
    while(1);
  }
  
  tft.setRotation(3);
  tft.fillScreen(ST77XX_BLACK);
  
  // Backlight control
  pinMode(1, OUTPUT);
  digitalWrite(1, HIGH);
  
  // Simple text display
  tft.setTextSize(2);
  tft.setTextColor(ST77XX_GREEN);
  tft.setCursor(20, 40);
  tft.println("Test Message");
}

void sketch_loop() {
  // Empty
}
 
Reply 0 0
Hizem Mariem
After debugging, I've discovered the ESP32-S2 enters a watchdog reset loop when using the TFT display with OpenPLC's Arduino extension. Here's the complete analysis:
The serial debug output shows continuous TG1WDT_SYS_RST watchdog resets:
entry 0x4004a15c
E (237) esp_core_dump_flash: Core dump data check failed:
Calculated checksum='d718d77e'
Image checksum='ffffffff'
ESP-ROM:esp32s2-rc4-20191025
Build:Oct 25 2019
rst:0x8 (TG1WDT_SYS_RST),boot:0x9 (SPI_FAST_FLASH_BOOT)
Saved PC:0x40028afc
SPIWP:0xee
mode:DIO, clock div:1
load:0x3ffe5110,len:0x1270
load:0x4004a000,len:0x4
load:0x4004a004,len:0xa04
load:0x4004e000,len:0x3540
 
Reply 0 0
thiagoralves
First thing that comes to mind is the usage of pins on the Arduino Extension that are reserved for the PLC runtime. Make sure all pins you're addressing on the Arduino Extension are not on the IO Config list on the upload dialog. Also, you haven't shared your actual PLC program, so I don't know if there are other things on the PLC side that could be conflicting.
Reply 0 0
Hizem Mariem
Thank you for your quick response. Here are the additional details you requested:

1. PLC Program Confirmation:

  • Program0 is just a simple LED blink (no I/O conflicts possible)
  • IO Configuration: Only GPIO2 used (LED) - all other pins unassigne
2. Pin Usage Clarification:
// CS:34, RST:3, DC:6, SCK:36, MOSI:35

3. New Test with I2C Display:

Same watchdog reset occurs with I2C OLED:
#include <U8g2lib.h>
U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0, 9, 8, U8X8_PIN_NONE);

void sketch_setup() {
  u8g2.begin(); // Triggers same WDT reset
}
 

Specific Question:

  1. Runtime GPIO Configuration:
    • Is there a way to modify the ESP32-S2 runtime pin mapping?
    • Our custom board requires specific GPIOs for display (34,35,36 etc.)
Capture d’écran 2025-07-10 163620.jpg
Reply 0 0
thiagoralves
Is there a way to modify the ESP32-S2 runtime pin mapping?
Yes, on the IO Config tab inside the upload dialog. Pins defined there will conflict with the Arduino Extension even if you don't use them in the PLC program.
Reply 0 0
Hizem Mariem
Thank you for your ongoing assistance. After extensive testing, I’ve identified a hardware-specific compatibility issue with OpenPLC on our custom ESP32-S2 PCB. Here’s a summary of the findings:

Key Observations:

  1. Custom PCB Behavior:
    • ❌ OpenPLC Code:
      • Immediate watchdog reset loops (TG1WDT_SYS_RST) on upload.
      • Occurs even with minimal programs (e.g., LED blink).
      • No issues with the same OpenPLC code on ESP32-WROOM (same wiring/logic).
    • ✅ Arduino IDE Code:
      • Flawless operation (identical hardware).

Critical Questions:

  1. Arduino vs. OpenPLC Differences:
    • Why does the same ESP32-S2 board work perfectly with Arduino IDE but fail with OpenPLC?
      • Potential causes: SPI/I2C driver conflicts, memory allocation, or watchdog thresholds.
  2. Workarounds:
    • Are there known firmware patches for ESP32-S2 support?
 
Thank you for your expertise!
Reply 0 0
thiagoralves
First, make sure you’re running the latest version of the editor (file -> check for updates). If the problem persists, then something is broken with the support for this particular board. It could be anything, a null pointer deference in the runtime code, request for pins that don’t exist, etc…
Reply 0 0
Write a reply...
Reply