Message Body:
Hello everyone,
I’m encountering a compilation error when trying to declare an external BOOL variable in OpenPLC and use it in my Arduino sketch for an ESP32-S2 project. Here are the details:
Context:
Hardware: ESP32-S2.
Software: OpenPLC Editor + Arduino IDE (with ESP32 library 3.2.0).
Goal: Declare a connect (BOOL) variable in OpenPLC and manipulate it via the Arduino sketch (e.g., read/write via Serial).
Problem:
The compilation fails with the following errors:
implicit declaration of function '__GET_GLOBAL_CONNECT'
assignment to 'IEC_BOOL*' from 'int' makes pointer from integer without a cast
Affected files:
POUS.c: Error related to
__INIT_EXTERNAL(BOOL, CONNECT, ...) (
bug.jpg).
Arduino sketch: Issue with Serial reading to set
connect (
bug4.jpg).
OpenPLC (Variable Declaration):
VAR_EXTERNAL connect : BOOL; // Déclaré comme externe ([bug3.jpg](bug3.jpg)) END_VAR
Arduino Sketch (Extrait) :
//////////////////////////////// sketch section ////////////////////////////////
String input = "";
void sketch_setup()
{
Serial.begin(115200);
Serial.println("Ready to receive open/close...");
}
void sketch_loop()
{
while (Serial.available()) {
char c = Serial.read();
if (c == '\n' || c == '\r') {
if (input == "open") {
connect = true; // OpenPLC uses 1/0 for BOOL
Serial.println("connect = TRUE");
} else if (input == "close") {
connect = false;
Serial.println("connect = FALSE");
}
input = "";
} else {
input += c;
}
}
}
Questions:
How can I correctly declare an external variable in OpenPLC so it’s accessible in the Arduino sketch (ESP32-S2)?
Are there any known limitations with ESP32-S2 and OpenPLC?
Thank you in advance for your help!