Hallo,
ich verwende ein ESP32C3 supermini siehe
hier meine platform.ini
board = lolin_c3_mini
Und versuche folgenden Code zu kompilieren
#include "HardwareSerial.h"
// Global variable for serial interface
HardwareSerial& mySerial = Serial; // You can replace Serial with Serial1, Serial2, etc., if available
// Function declarations
void initializeSerial(HardwareSerial& serial, long baudRate);
void writeMessage(HardwareSerial& serial, const char* message);
void setup() {
// Initialize the global serial communication
initializeSerial(mySerial, 115200);
// Write a message using the global serial variable
writeMessage(mySerial, "Hello from function!");
}
void loop() {
// Do nothing here
}
// Function definitions
void initializeSerial(HardwareSerial& serial, long baudRate) {
// Initialize the provided serial interface at the given baud rate
serial.begin(baudRate);
// Give the serial connection time to initialize
delay(1000);
}
void writeMessage(HardwareSerial& serial, const char* message) {
// Print the message to the provided serial monitor
serial.println(message);
}
allerdings bekomme ich folgenden Fehler
error: invalid initialization of reference of type 'HardwareSerial&' from expression of type 'HWCDC'
HardwareSerial& mySerial = Serial; // You can replace Serial with Serial1, Serial2, etc., if available