I need help moving an anemometer arduino script to HA YAML

I have made an anemometer. I have it working on an arduino uno and I get readings in the serial monitor on Arduino IDE.

What I would like to do is add the anemometer to the weather station that I currently have working in HA. This means that I need to change from using the Arduino UNO coding to YAML for HA. I am using a Wemos D1 as the controller in the Weather Station.

I am using a electric motor connected to a 3d printed anemometer that generates a current when the wind blows.

This is the Arduino coding.
Only two pins used

Positive to A0 on the UNO
Ground to GND on the UNO


int ledPin = 9;

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

void loop() {
 int sensorValue = analogRead(A0);

 //Map 0-1023 to discrete 0-50-100...250 values for LED
 analogWrite(ledPin, sensorValue * (51.0 / 1023.0) * 50);
 
 if(sensorValue > 0){
    Serial.println(sensorValue);
    Serial.print(" ");
 }
}

My current Weather Station YAML looks like this

esphome:
  name: mainweatherstation
  platform: ESP8266
  board: d1

wifi:
  ssid: "my ssid"
  password: "my password"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Mainweatherstation"
    password: "DlafFcP9W8ct"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: "my password"

ota:
  password: "my password"
i2c:
  sda: D14
  scl: D15
  scan: True
  id: bus_a
  
sensor:
  - platform: dht
    model: dht11
    pin: D7
    temperature:
      name: "Weather Station Temperature"
    humidity:
      name: "Weather Station Humidity"
    update_interval: 5s

  - platform: bmp085
    pressure:
      name: "Outside Pressure"
    temperature:
      name: "Weather Station Temperature Main"
    update_interval: 5s

I would greatly appreciate any assistant.

Connect the anemometer motor/generator to a voltage divider and sense the voltage with the ADC, https://esphome.io/components/sensor/adc.html set the voltage divider resistors to output 3.3v at your maximum motor/generator voltage. https://ohmslawcalculator.com/voltage-divider-calculator

Then use a calibrate linear filter to map voltages to wind speed. https://esphome.io/components/sensor/index.html?highlight=filters#calibrate-linear

Thanks for your help. I will follow what you have said and report back.