BL0942 metering IC

Has anyone manged to get BL0942 metering IC configured with esphome?

I did enable some debug and it always return “Serial not available”

void BL0940::loop() {
  DataPacket buffer;
  if (!this->available()) {
    ESP_LOGW(TAG, "Serial not available");
    return;
  }
  if (read_array((uint8_t *) &buffer, sizeof(buffer))) {
    if (validate_checksum(&buffer)) {
      received_package_(&buffer);
    }
  } else {
    ESP_LOGW(TAG, "Junk on wire. Throwing away partial message");
    while (read() >= 0)
      ;
  }
}

I enabled uart as below

uart:
  id: uart_bus
  tx_pin: 1
  rx_pin: 3
  baud_rate: 9600
  debug:
    direction: BOTH
    dummy_receiver: true
    after:
      delimiter: "\n"
    sequence:
      - lambda: UARTDebug::log_hex(direction, bytes, ':');

I can see that 50:AA is written
[D][uart_debug:114]: >>> 50:AA

If this gets merged, in the next release of esphome :slight_smile:

@mateine is this merged? I tried but it says Platform not found: 'sensor.bl0942'.

Got it working by adding below.

external_components:
  - source:
      type: git
      url: https://github.com/esphome/esphome
      ref: dev
    components: [bl0942]

Merged but not released yet. It should be out in the next EspHome version.
Btw, I didn’t know about external_components, thanks for sharing!

I just ordered two Aubess Smart Switch 16A with Power Monitoring. Seems to be BL0942.
I never used ESPHome before. How did you flash it?

Flashed via serial (soldered some cables to the chip) and this esphome port ESPHome - LibreTuya