ESP32C3 to Mega2560

Please bear with me as this is my first post here. I am new to any type of coding, as well.

I am trying to use my little ESP32C3 as a proxy for communication between my Mega2560 and the software on my laptop. So far no luck no matter what I have tried, be it BLE, STA, or AP.

Preferably, I’d like to use it in AP mode. I can connect to it but not establish communication to the Mega2560 using UART.

I’ve tried the default port 80 and 2000. By default, the software looks for IP 192.168.1.80 or 81 on port 2000. I can manually enter IP and port.

This is the last attempt as AP. It pings well if anything.

TIA

#include <WiFi.h>
#include <WiFiClient.h>
#include <HardwareSerial.h>

// Replace with your network credentials
const char* ssid = "Test";
const char* password = "12345678";

// UART pins on the SEEED Xiao ESP32C3
#define UART0_RX_PIN D7   // GPIO pin for UART RX
#define UART0_TX_PIN D6   // GPIO pin for UART TX

WiFiServer server(2000); // Port for HTTP server


void setup() {
  Serial.begin(115200);   // Serial monitor for debugging
  Serial1.begin(115200, SERIAL_8N1, UART0_RX_PIN, UART0_TX_PIN);

  // Connect to Wi-Fi
  WiFi.softAP(ssid, password);  
  IPAddress IP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(IP);

  server.begin();
}

void loop() {
  WiFiClient client = server.available();

  if (client) {
    while (client.connected()) {
      while (client.available()) {
        char data = client.read();
        Serial1.write(data); // Forward data received from Wi-Fi client to UART

        // Echo data back to the client
        Serial.write(data); // Forward data received from UART to Serial monitor
        client.write(data); // Forward data received from UART back to Wi-Fi client
      }
    }
    client.stop();
  }

  if (Serial1.available()) {
    char data = Serial1.read();
    Serial.write(data);   // Forward data received from UART to Serial monitor
    client.write(data);   // Forward data received from UART to connected Wi-Fi clients
  }
}

A little update. I can see in the serial monitor a request from the Mega2560. So some sort of communication is established.

thanks for posting… I also would like to do this… hopefully we can figgure something out!