ESP32-C6 + A02YYUW (A0221AU) ultrasonic sensor not returning valid readings in ESPHome

Hello community,

I’m trying to get a waterproof ultrasonic sensor working with ESPHome on an M5Stack Nano C6 (ESP32-C6).

Hardware:

  • M5Stack Nano C6
  • Waterproof ultrasonic sensor sold as A02YYUW UART
  • Marking on sensor: A0221AU
  • Connected via Grove connector

ESPHome configuration:

uart:
  id: a02_uart
  tx_pin: GPIO1
  rx_pin: GPIO2
  baud_rate: 9600

  debug:
    direction: RX
    dummy_receiver: true

sensor:
  - platform: a02yyuw
    uart_id: a02_uart
    name: "Waterput Afstand"

The sensor entity is created correctly but always remains: ‘unknown’

What I’ve already tested

1. Standard configuration

UART debug output:

00:00:00:00:00:00:00:00
00:00:00:01:00:00:00:00
00:00:00:00:00:00:00:00

No valid frames detected.

2. Logger disabled on serial

Based on some ESP32-C6 forum posts, I tried:

logger:
  baud_rate: 0

Result:

  • No change
  • Sensor still reports nan
  • UART still mostly shows zeros

3. Removed A02YYUW sensor component completely

To rule out ESPHome parsing issues, left only UART debug active.

Result:

Still no valid UART frames.

4. RX inversion

Tried:

rx_pin:
  number: GPIO2
  inverted: true

This changed the UART output dramatically.

Instead of all zeros, I started getting:

FF:F0:F0:F0:E0:F0...

However, these still don’t look like valid A02YYUW frames.

I never see repeating structures such as: “FF xx xx checksum” which is what the A02YYUW protocol documentation suggests.

5. Swapped RX/TX pins

Changed to:

tx_pin: GPIO2
rx_pin: GPIO1

Result:

No UART activity at all.

This suggests the original direction is probably correct.

Question

Has anyone successfully used an A0221AU / A02YYUW sensor with an ESP32-C6?

Could this be:

  1. A clone using a different UART protocol?
  2. An inverted signal output?
  3. A Grove pinout mismatch?
  4. A sensor hardware fault?
  5. Some ESP32-C6 UART compatibility issue?

Any ideas on additional tests would be appreciated.

What I also wanted to share is how the sensor is wired, vs. the pins of the M5Nano.
The connector is a ‘grove’, so can’t flip it in differently.

Thanks, I’ll log an issue.

Quite obviously..

As a consequence, highly probable.

Didn’t you suspect anything from non matching colors?

You can re-arrange the wires by lifting those plastic clips and pulling wires out.

Indeed, that was the issue. I did notice the mismatch of the colors, but it’s the first time I’m using any of this hardware so was not going to immediately pull out any wires :wink: Got it working! Next step is making it operational in the watertank.

You are lucky!
Many circuits would have been fried by that.