Missing external component sensor

I have been trying to create a MT6701 (i2c version) . My config yaml validates, the compile works, it installs, but I see no indication that the code is ever activated. I have 4 sensors; the MT6701, a pulse meter, and temperature and humidity sensors from a DHT.
Looking at the esp log I see the dump of the configs for the pulse meter and the DHT sensors, I also see various messages from those same sensors. What I dont see is anything from the MT6701.
It is like the code is never called.

t
external_components:
  - source:
      type: local
      path: my_components


i2c:
  - id: i2c_mt6701
    scl: GPIO21
    sda: GPIO22
    scan: false
    frequency: 100kHz

# Enable logging         
logger:    
  level: VERY_VERBOSE              


sensor:
  - platform: mt6701
    i2c_id: i2c_mt6701
    address: 0x06
    wind_direction_degrees:
      name: Wind Direction
      id: wind_direction
      force_update: true
    update_interval: 2s

  - platform: pulse_meter
    device_class: 
      wind_speed
    state_class: 
      measurement
    pin:
      number: GPIO14
      mode: INPUT_PULLUP
    unit_of_measurement: 'km/h'
    name: windspeed
    icon: 'mdi:weather-windy'
    internal_filter: 13us
    timeout: 10s
    filters:
    - lambda: >-
        if (x < 1) return {};
        return x * 0.119 -0.967;

  - platform: dht
    pin: GPIO18
    model: rht03
    temperature:
      name: "Temperature"
    humidity:
      name: "Humidity"
    update_interval: 30s

sensor.py

import esphome.codegen as cg
from esphome.components import i2c, sensor
import esphome.config_validation as cv
from esphome.const import (
    CONF_ID,
    CONF_PIN,
    CONF_WIND_DIRECTION_DEGREES,
    ICON_SIGN_DIRECTION,
    ICON_WEATHER_WINDY,
    STATE_CLASS_MEASUREMENT,
    UNIT_DEGREES,
    CONF_NAME,

)

AUTO_LOAD = [
    "sensor",
]
CODEOWNERS = ["@esphome/core"]
DEPENDENCIES = ["i2c"]

mt6701_ns = cg.esphome_ns.namespace("mt6701")
MT6701Component = mt6701_ns.class_("MT6701Component", sensor.Sensor,  cg.PollingComponent, i2c.I2CDevice)
CONFIG_SCHEMA = (
        cv.Schema(
        {
            cv.GenerateID(): cv.declare_id(MT6701Component),
            cv.Required(CONF_WIND_DIRECTION_DEGREES): sensor.sensor_schema(
                unit_of_measurement=UNIT_DEGREES,
                accuracy_decimals=1,
                icon=ICON_SIGN_DIRECTION,
                state_class=STATE_CLASS_MEASUREMENT,
                ),
        }
  ).extend(cv.polling_component_schema("2s"))
   .extend(i2c.i2c_device_schema(default_address=0x06))
 
)

async def to_code_base(config):
    var = cg.new_Pvariable(config[CONF_ID])
    await cg.register_component(var, config)
    await i2c.register_i2c_device(var, config)

    sens = await sensor.new_sensor(config[CONF_WIND_DIRECTION_DEGREES])
    cg.add(var.set_wind_direction_degrees_sensor(sens))
    return var
[14:30:04][C][logger:177]: Logger:
[14:30:04][C][logger:178]:   Max Level: VERY_VERBOSE
[14:30:04][C][logger:179]:   Initial Level: VERY_VERBOSE
[14:30:04][C][logger:181]:   Log Baud Rate: 115200
[14:30:04][C][logger:182]:   Hardware UART: UART0
[14:30:04][C][i2c.arduino:071]: I2C Bus:
[14:30:04][C][i2c.arduino:072]:   SDA Pin: GPIO22
[14:30:04][C][i2c.arduino:073]:   SCL Pin: GPIO21
[14:30:04][C][i2c.arduino:074]:   Frequency: 100000 Hz
[14:30:04][C][i2c.arduino:086]:   Recovery: bus successfully recovered
[14:30:04][C][pulse_meter:110]: Pulse Meter 'windspeed'
[14:30:04][C][pulse_meter:110]:   Device Class: 'wind_speed'
[14:30:04][C][pulse_meter:110]:   State Class: 'measurement'
[14:30:04][C][pulse_meter:110]:   Unit of Measurement: 'km/h'
[14:30:04][C][pulse_meter:110]:   Accuracy Decimals: 2
[14:30:04][C][pulse_meter:110]:   Icon: 'mdi:weather-windy'
[14:30:04][C][pulse_meter:111]:   Pin: GPIO14
[14:30:04][C][pulse_meter:113]:   Filtering rising edges less than 13 µs apart
[14:30:04][C][pulse_meter:118]:   Assuming 0 pulses/min after not receiving a pulse for 10s
[14:30:04][C][dht:017]: DHT:
[14:30:04][C][dht:018]:   Pin: GPIO18
[14:30:04][C][dht:024]:   Model: DHT22 (or equivalent)
[14:30:04][C][dht:026]:   Internal Pull-up: ON
[14:30:04][C][dht:028]:   Update Interval: 30.0s
[14:30:04][C][dht:030]:   Temperature 'Temperature'
[14:30:04][C][dht:030]:     Device Class: 'temperature'
[14:30:04][C][dht:030]:     State Class: 'measurement'
[14:30:04][C][dht:030]:     Unit of Measurement: '°C'
[14:30:04][C][dht:030]:     Accuracy Decimals: 1
[14:30:04][C][dht:031]:   Humidity 'Humidity'
[14:30:04][C][dht:031]:     Device Class: 'humidity'
[14:30:04][C][dht:031]:     State Class: 'measurement'
[14:30:04][C][dht:031]:     Unit of Measurement: '%'
[14:30:04][C][dht:031]:     Accuracy Decimals: 0
[14:30:04][C][mdns:116]: mDNS:
[14:30:04][C][mdns:117]:   Hostname: esphome-web-a7f148
[14:30:04][V][mdns:118]:   Services:
[14:30:04][V][mdns:120]:   - _esphomelib, _tcp, 6053
[14:30:04][V][mdns:122]:     TXT: friendly_name = ESPHome Web a7f148
[14:30:04][V][mdns:122]:     TXT: version = 2025.4.2
[14:30:04][V][mdns:122]:     TXT: mac = d4d4dae4cd2c
[14:30:04][V][mdns:122]:     TXT: platform = ESP32
[14:30:04][V][mdns:122]:     TXT: board = esp32dev
[14:30:04][V][mdns:122]:     TXT: network = wifi
[14:30:04][C][esphome.ota:073]: Over-The-Air updates:
[14:30:04][C][esphome.ota:074]:   Address: 10.0.0.89:3232
[14:30:04][C][esphome.ota:075]:   Version: 2
[14:30:04][C][safe_mode:018]: Safe Mode:
[14:30:04][C][safe_mode:020]:   Boot considered successful after 60 seconds
[14:30:04][C][safe_mode:021]:   Invoke after 10 boot attempts
[14:30:04][C][safe_mode:023]:   Remain in safe mode for 300 seconds
[14:30:04][C][api:140]: API Server:
[14:30:04][C][api:141]:   Address: 10.0.0.89:6053
[14:30:04][C][api:145]:   Using noise encryption: NO
[14:30:05][V][pulse_meter:079]: New pulse, delta: 2491099 µs, count: 1, width: 2491099.00000 µs
[14:30:05][V][sensor:043]: 'windspeed': Received new state 24.085754
[14:30:05][VV][sensor.filter:014]: Filter(0x3ffb2a60)::input(24.085754)
[14:30:05][VV][sensor.filter:286]: LambdaFilter(0x3ffb2a60)::new_value(24.085754) -> 1.899205
[14:30:05][VV][sensor.filter:021]: Filter(0x3ffb2a60)::output(1.899205) -> SENSOR
[14:30:05][D][sensor:094]: 'windspeed': Sending state 1.89920 km/h with 2 decimals of accuracy
[14:30:05][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
[14:30:05]  key: 1726592700
[14:30:05]  state: 1.8992
[14:30:05]  missing_state: NO
[14:30:05]}
[14:30:05][W][component:239]: Component pulse_meter.sensor took a long time for an operation (59 ms).
[14:30:05][W][component:240]: Components should block for at most 30 ms.
[14:30:06][VV][dht:191]: Data: Hum=0b0000001111100111, Temp=0b0000000010001111, Checksum=0b01111001
[14:30:06][D][dht:049]: Got Temperature=14.3°C Humidity=99.9%
[14:30:06][V][sensor:043]: 'Temperature': Received new state 14.300000
[14:30:06][D][sensor:094]: 'Temperature': Sending state 14.30000 °C with 1 decimals of accuracy
[14:30:06][VV][api.service:140]: send_sensor_state_response: SensorStateResponse 

Where’s the log from the compile?

When working on something like this I also check the generated code (that is what cg is supposed to do).

Here is the compile log (after doing a clean). You can see the mt6701.cpp file is compiled. I am at a total loss as to what the issue is.

INFO ESPHome 2025.4.2
INFO Reading configuration /config/esphome/esphome-web-a7f148.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing esphome-web-a7f148 (board: esp32dev; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Dependency Graph
|-- WiFi @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- Update @ 2.0.0
|-- Wire @ 2.0.0
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/api/api_connection.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/api/api_frame_helper.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/api/api_pb2.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/api/api_pb2_service.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/api/api_server.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/api/list_entities.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/api/proto.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/api/subscribe_state.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/api/user_services.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/dht/dht.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/esp32/core.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/esp32/gpio.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/esp32/preferences.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/esphome/ota/ota_esphome.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/i2c/i2c.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/i2c/i2c_bus_arduino.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/i2c/i2c_bus_esp_idf.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/logger/logger.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/logger/logger_esp32.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/logger/logger_esp8266.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/logger/logger_host.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/logger/logger_libretiny.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/logger/logger_rp2040.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/md5/md5.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/mdns/mdns_component.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/mdns/mdns_esp32.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/mdns/mdns_esp8266.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/mdns/mdns_host.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/mdns/mdns_libretiny.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/mdns/mdns_rp2040.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/mt6701/mt6701.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/network/util.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/ota/ota_backend.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/ota/ota_backend_arduino_esp32.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/ota/ota_backend_arduino_esp8266.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/ota/ota_backend_arduino_libretiny.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/ota/ota_backend_arduino_rp2040.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/ota/ota_backend_esp_idf.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/pulse_meter/pulse_meter_sensor.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/safe_mode/safe_mode.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/sensor/automation.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/sensor/filter.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/sensor/sensor.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/socket/bsd_sockets_impl.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/socket/lwip_raw_tcp_impl.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/socket/lwip_sockets_impl.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/socket/socket.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/wifi/wifi_component.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/wifi/wifi_component_esp32_arduino.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/wifi/wifi_component_esp8266.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/wifi/wifi_component_esp_idf.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/wifi/wifi_component_libretiny.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/components/wifi/wifi_component_pico_w.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/core/application.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/core/color.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/core/component.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/core/component_iterator.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/core/controller.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/core/entity_base.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/core/helpers.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/core/log.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/core/ring_buffer.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/core/scheduler.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/core/string_ref.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/core/time.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/esphome/core/util.cpp.o
Compiling .pioenvs/esphome-web-a7f148/src/main.cpp.o
Building .pioenvs/esphome-web-a7f148/bootloader.bin
Creating esp32 image...
Successfully created esp32 image.
Generating partitions .pioenvs/esphome-web-a7f148/partitions.bin
Compiling .pioenvs/esphome-web-a7f148/lib64d/WiFi/WiFi.cpp.o
Compiling .pioenvs/esphome-web-a7f148/lib64d/WiFi/WiFiAP.cpp.o
Compiling .pioenvs/esphome-web-a7f148/lib64d/WiFi/WiFiClient.cpp.o
Compiling .pioenvs/esphome-web-a7f148/lib64d/WiFi/WiFiGeneric.cpp.o
Compiling .pioenvs/esphome-web-a7f148/lib64d/WiFi/WiFiMulti.cpp.o
Compiling .pioenvs/esphome-web-a7f148/lib64d/WiFi/WiFiSTA.cpp.o
Compiling .pioenvs/esphome-web-a7f148/lib64d/WiFi/WiFiScan.cpp.o
Compiling .pioenvs/esphome-web-a7f148/lib64d/WiFi/WiFiServer.cpp.o
Compiling .pioenvs/esphome-web-a7f148/lib64d/WiFi/WiFiUdp.cpp.o
Compiling .pioenvs/esphome-web-a7f148/lib915/ESPmDNS/ESPmDNS.cpp.o
Compiling .pioenvs/esphome-web-a7f148/libbc6/Update/HttpsOTAUpdate.cpp.o
Compiling .pioenvs/esphome-web-a7f148/libbc6/Update/Updater.cpp.o
Compiling .pioenvs/esphome-web-a7f148/lib4fc/Wire/Wire.cpp.o
Archiving .pioenvs/esphome-web-a7f148/lib64d/libWiFi.a
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/Esp.cpp.o
Archiving .pioenvs/esphome-web-a7f148/lib915/libESPmDNS.a
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/FirmwareMSC.cpp.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/FunctionalInterrupt.cpp.o
Archiving .pioenvs/esphome-web-a7f148/libbc6/libUpdate.a
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/HWCDC.cpp.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/HardwareSerial.cpp.o
Archiving .pioenvs/esphome-web-a7f148/lib4fc/libWire.a
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/IPAddress.cpp.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/IPv6Address.cpp.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/MD5Builder.cpp.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/Print.cpp.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/Stream.cpp.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/StreamString.cpp.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/Tone.cpp.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/USB.cpp.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/USBCDC.cpp.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/USBMSC.cpp.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/WMath.cpp.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/WString.cpp.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/base64.cpp.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/cbuf.cpp.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/esp32-hal-adc.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/esp32-hal-bt.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/esp32-hal-cpu.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/esp32-hal-dac.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/esp32-hal-gpio.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/esp32-hal-i2c-slave.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/esp32-hal-i2c.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/esp32-hal-ledc.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/esp32-hal-matrix.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/esp32-hal-misc.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/esp32-hal-psram.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/esp32-hal-rgb-led.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/esp32-hal-rmt.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/esp32-hal-sigmadelta.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/esp32-hal-spi.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/esp32-hal-time.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/esp32-hal-timer.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/esp32-hal-tinyusb.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/esp32-hal-touch.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/esp32-hal-uart.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/firmware_msc_fat.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/libb64/cdecode.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/libb64/cencode.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/main.cpp.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/stdlib_noniso.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/wiring_pulse.c.o
Compiling .pioenvs/esphome-web-a7f148/FrameworkArduino/wiring_shift.c.o
Archiving .pioenvs/esphome-web-a7f148/libFrameworkArduino.a
Linking .pioenvs/esphome-web-a7f148/firmware.elf
RAM:   [=         ]  12.4% (used 40648 bytes from 327680 bytes)
Flash: [=====     ]  46.4% (used 851993 bytes from 1835008 bytes)
Building .pioenvs/esphome-web-a7f148/firmware.bin
Creating esp32 image...
Successfully created esp32 image.
esp32_create_combined_bin([".pioenvs/esphome-web-a7f148/firmware.bin"], [".pioenvs/esphome-web-a7f148/firmware.elf"])
SHA digest in image updated
Wrote 0xe16a0 bytes to file /data/build/esphome-web-a7f148/.pioenvs/esphome-web-a7f148/firmware.factory.bin, ready to flash to offset 0x0
esp32_copy_ota_bin([".pioenvs/esphome-web-a7f148/firmware.bin"], [".pioenvs/esphome-web-a7f148/firmware.elf"])
======================== [SUCCESS] Took 110.52 seconds ========================
INFO Successfully compiled program.
INFO Connecting to 10.0.0.89 port 3232...
INFO Connected to 10.0.0.89
INFO Uploading /data/build/esphome-web-a7f148/.pioenvs/esphome-web-a7f148/firmware.bin (857760 bytes)
Uploading: [============================================================] 100% Done...

Where’s the C++ code?

Here is the code.
mt6701.h

#pragma once

#include <utility>

#include "esphome/core/component.h"
#include "esphome/components/sensor/sensor.h"
#include "esphome/components/i2c/i2c.h"

namespace esphome {
namespace mt6701{

class MT6701Component : public PollingComponent, public i2c::I2CDevice {
 public:

    void setup() override;
    void dump_config() override;
    void update() override;
    float get_setup_priority() const { return setup_priority::DATA; }

    void set_wind_direction_degrees_sensor(sensor::Sensor *wind_direction_degrees_sensor) {wind_direction_degrees_sensor_ = wind_direction_degrees_sensor; }

  protected:
    sensor::Sensor *wind_direction_degrees_sensor_{nullptr};
};

}

}


mt6701.cpp

#include "mt6701.h"
#include "esphome/core/log.h"
#include "esphome/core/hal.h"

namespace esphome {
namespace mt6701 {

static const uint8_t MT6701_DEFAULT_ADDRESS			=	0x06;
static const uint8_t MT6701_OK						=	0;
static const uint8_t MT6701_ERR_GENERAL				=	1;
static const uint8_t MT6701_ERR_HANDLER_NULL		=		2;
static const uint8_t MT6701_ERR_CONFIG_UNAVAILABLE	=	3;
static const uint8_t MT6701_ERR_IO					=	4;
static const uint8_t MT6701_ERR_OUT_OF_RANGE		=		5;
static const uint8_t MT6701_ERR_UNINITITIALIZED		=	6;
static const uint8_t MT6701_REG_ANGLE0				=	0x04;
static const uint8_t MT6701_REG_ANGLE6				=	0x03;
static const uint8_t MT6701_REG_ANGLE0_POS			=	2;
static const uint8_t MT6701_REG_ANGLE6_POS			=	0;
static const uint8_t MT6701_REG_ANGLE0_MASK			=	(0x3F << MT6701_REG_ANGLE0_POS);
static const uint8_t MT6701_REG_ANGLE6_MASK				(0xFF << MT6701_REG_ANGLE6_POS);

static const char *const TAG = "mt6701";

void MT6701Component::setup() {
    ESP_LOGCONFIG(TAG, "Setting up MT6701...");
    uint8_t data;
    if (this->read_byte(MT6701_REG_ANGLE6, &data, 1) != i2c::ERROR_OK) {
      ESP_LOGE(TAG, "Communication with wmt6701 failed!");
  //    this->mark_failed();
  //    return;
    }
  ESP_LOGV(TAG, "mt6701 initialization"); 
}

void MT6701Component::update() {
    // Enable sensor
    uint8_t reg0, reg1;
    reg0  = MT6701_REG_ANGLE6;
    reg1 = MT6701_REG_ANGLE0;

    ESP_LOGV(TAG, "Sending conversion request...");
    uint8_t data[2];
    uint8_t data1[2];
//    if (this->read_byte(reg0) != i2c::ERROR_OK) {
//        this->status_set_warning("mt6701 read failed");
//        return;
//    }

    uint16_t angle_u16;
       if (!this->read_byte(reg0 ,data, 0)) {
      ESP_LOGW(TAG, "Error reading register0.");
      this->status_set_warning();
      return;
    
    }

   if (!this->read_byte(reg1 ,data1, 1)) {
      ESP_LOGW(TAG, "Error reading register1.");
      this->status_set_warning();
      return;
    }


 
    //   this->status_set_warning();
    angle_u16  = (uint16_t)data[0] >> MT6701_REG_ANGLE0_POS;
    ESP_LOGD(TAG, "Got angle=%.2d", angle_u16);

    angle_u16 |= (uint16_t)data1[0] << (8-MT6701_REG_ANGLE0_POS);


    ESP_LOGD(TAG, "Got angle=%.2f", angle_u16);
        if (this->wind_direction_degrees_sensor_ != nullptr)
        this->wind_direction_degrees_sensor_->publish_state(angle_u16);

       // this->status_clear_warning();
}
void MT6701Component::dump_config() {
  ESP_LOGCONFIG(TAG, "MT6701:");
  LOG_I2C_DEVICE(this);
  if (this->is_failed()) {
    ESP_LOGE(TAG, "Communication with MT6701 failed!");
  }
  LOG_SENSOR("  ", "wind Direction", this->wind_direction_degrees_sensor_);
}

}
}


sensor.py

import esphome.codegen as cg
from esphome.components import i2c, sensor
import esphome.config_validation as cv
from esphome.const import (
    CONF_ID,
    CONF_PIN,
    CONF_WIND_DIRECTION_DEGREES,
    ICON_SIGN_DIRECTION,
    ICON_WEATHER_WINDY,
    STATE_CLASS_MEASUREMENT,
    UNIT_DEGREES,
    CONF_NAME,

)

AUTO_LOAD = [
    "sensor",
]
CODEOWNERS = ["@esphome/core"]
DEPENDENCIES = ["i2c"]

mt6701_ns = cg.esphome_ns.namespace("mt6701")
MT6701Component = mt6701_ns.class_("MT6701Component", sensor.Sensor,  cg.PollingComponent, i2c.I2CDevice)
CONFIG_SCHEMA = (
        cv.Schema(
        {
            cv.GenerateID(): cv.declare_id(MT6701Component),
            cv.Required(CONF_WIND_DIRECTION_DEGREES): sensor.sensor_schema(
                unit_of_measurement=UNIT_DEGREES,
                accuracy_decimals=1,
                icon=ICON_SIGN_DIRECTION,
                state_class=STATE_CLASS_MEASUREMENT,
                ),
        }
  ).extend(cv.polling_component_schema("2s"))
   .extend(i2c.i2c_device_schema(default_address=0x06))
 
)

async def to_code_base(config):
    var = cg.new_Pvariable(config[CONF_ID])
    await cg.register_component(var, config)
    await i2c.register_i2c_device(var, config)

    sens = await sensor.new_sensor(config[CONF_WIND_DIRECTION_DEGREES])
    cg.add(var.set_wind_direction_degrees_sensor(sens))
    return var

My guess is that there’s an issue with the I2C setup. Your component depends on an active I2C component; if that, for some reason, fails to set up properly your component won’t get initialized.

Try setting scan: true

Ignore that, the solution is much simpler.

This:

async def to_code_base(config):

should be:

async def to_code(config):

Now I see the log messages generated by the component:

[20:26:19][I][logger:171]: Log initialized
[20:26:19][I][app:029]: Running through setup()...
[20:26:19][V][app:030]: Sorting components by setup priority...
[20:26:19][I][i2c.arduino:218]: Performing I2C bus recovery
[20:26:19][   160][I][esp32-hal-i2c.c:75] i2cInit(): Initialising I2C Master: sda=4 scl=3 freq=100000
[20:26:19][C][mt6701:026]: Setting up MT6701...
[20:26:19][VV][i2c.arduino:176]: 0x06 TX 03
[20:26:19][VV][i2c.arduino:202]: TX failed: not acknowledged: 2
[20:26:19][V][mt6701:033]: mt6701 initialization
1 Like

Arrggh, I knew it had to be something simple. I had originally tried to model the MT6701 on a BMP280 which has a base componeent and then an i2c and spi components. I kept getting errors about ambigous definitions, so I decided to just do the I2C version…except I missed that to_code_base when I converted the code to a single component! Thank you, thank you!

As a side note the i2c scan fails on the mt6701 because it uses a reserved address of 0x06 and the scan starts above the reserved addresses at 0x08.