lamaPLC: A0221AU / A02YYUW Waterproof Ultrasonic Distance Sensor with UART communication

A0221AU / A02YYUW Waterproof Ultrasonic Distance Sensor The ultrasonic sensor features a sealed, waterproof, dustproof probe, ideal for harsh, wet environments. All signal processing components are built into the module, enabling users to read distance directly via the Asynchronous Serial Interface. Operating at 9600 baud, the sensor can connect seamlessly to the main host or other MCUs, significantly reducing development time.

The DFRobot A02YYUW Waterproof Ultrasonic Sensor (SKU: SEN0311) is a durable distance sensor suitable for challenging or humid environments, thanks to its IP67 waterproof and dustproof ratings. It is commonly employed in DIY electronics, robotics, and industrial automation.

Key features include

  • Integrated Processing: All signal processing is performed internally, and the module outputs the final distance value directly via a UART (serial) interface. This simplifies the code required for microcontrollers such as Arduino or Raspberry Pi.
  • Automatic Mode: The “U” in the A02YYUW designation signifies it is the UART version operating in “Automatic Mode,” which continuously transmits data that can be read at any time without requiring a trigger signal.
  • Reliability: DFRobot states that its closed, separated probe design, combined with strong interference resistance, ensures stable, reliable data output even in smog- or dust-laden environments.

Specification

Accuracy±1 cm
Operating Voltage3.3 .. 5 V
Average Current<8 mA
Blind Zone Distance3 cm
Detecting Range(Flat object)3 .. 450 cm
OutputUART
Response Time100 ms
Operating Temperature-15 .. 60 ℃
Storage Temperature-25 .. 80 ℃
Reference Angle60º
Waterproof GradeIP67

If you'd like to support the development of the site with the price of a coffee — or a few — please do so here.

Here's a handy tip: you can quickly save this page as a PDF by clicking “export to PDF” in the menu on the right side of the screen.

2026/02/14 22:38

Arduino & A0221AU Unit

Pinout

ColorA0221AU UnitArduino PinNotes
red wireVccArduino 5VPower input (3.3 .. 5 V)
black wireGNDArduino GNDGND
yellow wireRxArduino Pin 11 (Not strictly needed if the sensor is in auto-output mode)Receive
white wireTxArduino Pin 10Transfer

Arduino Example Code

This code listens for the data packet, verifies the checksum, and calculates the distance in millimeters.

#include <SoftwareSerial.h>
 
// RX on Pin 10, TX on Pin 11
SoftwareSerial mySerial(10, 11); 
 
unsigned char data[4];
int distance;
 
void setup() {
  Serial.begin(115200);   // To PC
  mySerial.begin(9600);   // To Sensor
  Serial.println("A0221AU Sensor Initialized...");
}
 
void loop() {
  if (mySerial.available() > 0) {
    // Look for the header byte (0xFF)
    if (mySerial.read() == 0xFF) {
      data[0] = 0xFF;
      for (int i = 1; i < 4; i++) {
        data[i] = mySerial.read();
      }
 
      // Verify checksum: (data[0] + data[1] + data[2]) & 0x00FF
      byte checksum = (data[0] + data[1] + data[2]) & 0xFF;
 
      if (data[3] == checksum) {
        distance = (data[1] << 8) + data[2];
        Serial.print("Distance: ");
        Serial.print(distance);
        Serial.println(" mm");
      } else {
        Serial.println("Checksum Error");
      }
    }
  }
  delay(100); 
}

Implementation Tips

  • Blind Zone: These sensors typically have a blind spot of about 3cm to 25cm; readings within this range are inaccurate.
  • Baud Rate: Most A02 series sensors default to 9600 baud.
  • Power: These modules can be power-hungry during the ultrasonic pulse; if readings are unstable, add a 100 uF capacitor across the sensor's VCC and GND pins.

UART topics on lamaPLC




This page has been accessed for: Today: 8, Until now: 141