how to send serial data from arduino to esp8266

I want to make a project where data is sent from esp826-01 to Arduino Uno R3, I previously made it using the code below but failed.

For ESP8266-01

#include <SoftwareSerial.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

#define BAUD_RATE 9600

SoftwareSerial swSer(14, 12, false, 256);

// Replace with your network credentials
const char* ssid     = "farzain_2";
const char* password = "1999fzyc";

void setup() {
  Serial.begin(BAUD_RATE);
  swSer.begin(BAUD_RATE);

  WiFi.begin(ssid, password);
  while(WiFi.status() != WL_CONNECTED) {
    delay(500);
  }
}

void loop() {
  String IncomingString = "";
  boolean StringReady = false;
  
  while(swSer.available() > 0) {
    IncomingString = swSer.readString();
    StringReady = true;
    yield();
  }
  if(StringReady) {
    if(IncomingString == "on") {
      HTTPClient http;
      http.begin("https://if.farzain.com/add_uno.php?add=1");
      Serial.println("OK");
    }
  }


}

For Arduino UNO R3

#include <SoftwareSerial.h>
SoftwareSerial mySerial(1,0); //RX, TX

void setup() {
  Serial.begin(9600);

}

void loop() {
  Serial.write("ON");
  delay(1000);
  Serial.write("OFF");
  delay(1000);
}

how to fix it? thank you

esp8266-arduino.png

2a4cd732cfe83c3c9cb620466688f97b5a030442.png

how to post an image.

I want to make a project where data is sent from esp826-01 to Arduino Uno R3,

Your sketches show data sent from the Arduino to the ESP, so what are you actually trying to do.

#include <SoftwareSerial.h>
SoftwareSerial mySerial(1,0); //RX, TX

Why do you have software serial on the hardware serial pins of the Uno? You never call software serial in the sketch but if you did, it wouldn't work properly.

Regarding the ESP8266

SoftwareSerial swSer(14, 12, false, 256);

It would be preferable to use the hardware serial UART0 which is mapped to pins GPIO1 (TX) and GPIO3 (RX). on the ESP.

You should do some Google search on "Arduino serial communication with ESP 8266-01"

You might also consider the need for level shifting the Tx>Rx of the 5v uno to the 3.3v esp.

Your wiring diagram with Tx>Tx and Rx>Rx looks like it might be for downloading code to the esp and not for operating.

If you are new to Arduino and ESP8266 you might be better off with a complete esp8266 module with USB like the Wemos , Node MCU or Feather HUZZAH. They are much more simple to use than the -01 module.