HardwareSerial vs HWDC benoetige Hilfe

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

'HardwareSerial&' != 'HWCDC'

@pmettemp
Evtl. solltest du einfach mal mehr Angaben machen:
Z.B. womit du versuchst zu kompilieren ?
IDE-Version, core-Version ?

Der Sketch kompiliert bei mir fehlerfrei auf Arduino IDE V1.8.19; core-Version 3.0.2

Steht doch oben "platform.ini"

Und was soll mir das sagen.

Ich tippe mal, da macht der TO einen Fehler, also muss er das mal richtig machen.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.