Component guide · Intermediate · 4 min read
DYP A21 (3-500 cm) and A22 (2-300 cm) Obstacle Avoidance Ultrasonic Sensors

UART, PWM, RS485, CAN, I2C and Switch
By Geekobot Learning Team · Updated 29 Oct 2026
On this page
The DYP A21 and A22 are waterproof ultrasonic sensors designed for obstacle avoidance on robots, AGVs and lawn mowers. Their very short blind zone (2 to 3 cm) and wide beam catch obstacles close to the robot. The A21 reaches 500 cm and the A22 300 cm. They come in UART, PWM, RS485, CAN, I2C and switch versions so they fit microcontrollers and industrial controllers alike.
Key specs at a glance
- Range
- 3 to 500 cm (A21), 2 to 300 cm (A22)
- Blind zone
- About 2 to 3 cm
- Beam
- Wide, for obstacle detection
- Output
- UART (U, T), PWM (M), RS485 (4), CAN (CA), I2C (C), switch (GD)
- Supply
- 3.3 to 5 V TTL, wider for RS485 and CAN
- Protection
- IP67
Models in this guide
These are alternatives. Pick the one that fits your project; you only need one.
Option 1DYP-A21AYYUW-V1.0 UART Auto Ultrasonic Obstacle Avoidance Sensor (Object Range 3 ~ 500cm)₹2,039
Option 2DYP-A21AYYTW-V1.0 UART Ultrasonic Obstacle Avoidance Sensor (3-500cm Range)₹2,099
Option 3DYP-A21AYY4W-V1.0 RS485 Ultrasonic Obstacle Avoidance Sensor (Object Range 3-500cm)₹2,619
Option 4DYP-A21AYYGDW-V1.0 TTL Switch Ultrasonic Obstacle Avoidance Sensor Object Range 3–500 cm₹2,829
Option 5DYP-A21AYYCAW-V1.0 CAN Ultrasonic Obstacle Avoidance Sensor (Object Range 3~500cm)₹2,897
Option 6DYP-A21AYYMW-V1.0 PWM Ultrasonic Obstacle Avoidance Sensor (Object Range 3-500cm)₹1,909
What the DYP A21 and A22 obstacle avoidance ultrasonic sensors is
The DYP A21 and A22 are waterproof ultrasonic sensors with a very short blind zone and wide beam, made for obstacle avoidance on robots and AGVs.
Several sensors on one robot can interfere. Use controlled (T), RS485 or CAN versions and trigger them one after another.
The I2C version (A22YYCW) lets several sensors share two wires with different addresses.
DYP A21 and A22 obstacle avoidance ultrasonic sensors pinout
The pins on the DYP A21 and A22 obstacle avoidance ultrasonic sensors and what each one does.
| Pin | Function |
|---|---|
| Red | VCC |
| Black | GND |
| Yellow | RX / SCL / CAN-H / A |
| White | TX / SDA / CAN-L / B |
- Red
- VCC
- Black
- GND
- Yellow
- RX / SCL / CAN-H / A
- White
- TX / SDA / CAN-L / B
Wiring the DYP A21 and A22 obstacle avoidance ultrasonic sensors
Connect the DYP A21 and A22 obstacle avoidance ultrasonic sensors like this.
| DYP A21 and A22 obstacle avoidance ultrasonic sensors pin | Arduino Uno | ESP32 |
|---|---|---|
| Red (VCC) | 5 V | 3.3 or 5 V (check model) |
| Black (GND) | GND | GND |
| Yellow (RX / trigger) | D11 | GPIO 17 |
| White (TX) | D10 (SoftwareSerial RX) | GPIO 16 |
- Red (VCC)
- Arduino Uno:
- 5 V
- ESP32:
- 3.3 or 5 V (check model)
- Black (GND)
- Arduino Uno:
- GND
- ESP32:
- GND
- Yellow (RX / trigger)
- Arduino Uno:
- D11
- ESP32:
- GPIO 17
- White (TX)
- Arduino Uno:
- D10 (SoftwareSerial RX)
- ESP32:
- GPIO 16
Example code
A minimal sketch to check the part works.
// DYP UART frame: 0xFF, distance high, distance low, checksum ((0xFF + H + L) & 0xFF), distance in mm
const int TRIG = 17; // "controlled" (T) models: pull RX low or send a byte to trigger; "auto" (U) models stream
void setup() {
Serial.begin(115200);
Serial2.begin(9600, SERIAL_8N1, 16, TRIG);
}
void loop() {
Serial2.write(0x55); // trigger for controlled models; ignored by auto models
delay(100);
while (Serial2.available() >= 4) {
if (Serial2.read() != 0xFF) continue;
uint8_t h = Serial2.read(), l = Serial2.read(), sum = Serial2.read();
if (((0xFF + h + l) & 0xFF) == sum) {
Serial.print((h << 8) | l); Serial.println(" mm");
}
}
}Setup and tuning
place them at bumper height across the front of the robot.
trigger several sensors in turn, not all at once.
choose UART, PWM, RS485, CAN, I2C or switch versions to suit your controller.
set a stop distance that allows for the robot's speed and braking.
angle the sensor slightly up if the wide beam sees the floor.
What you need
Shop this list16 of 17 found in our store · ₹25,845
DYP-A21AYYUW-V1.0 UART Auto Ultrasonic Obstacle Avoidance Sensor (Object Range 3 ~ 500cm): the part this guide coversDYP-A21AYYUW-V1.0 UART Auto Ultrasonic Obstacle Avoidance Sensor (Object Range 3 ~ 500cm)₹2,039
DYP-A21AYYTW-V1.0 UART Ultrasonic Obstacle Avoidance Sensor (3-500cm Range): another version this guide coversDYP-A21AYYTW-V1.0 UART Ultrasonic Obstacle Avoidance Sensor (3-500cm Range)₹2,099
DYP-A21AYY4W-V1.0 RS485 Ultrasonic Obstacle Avoidance Sensor (Object Range 3-500cm): another version this guide coversDYP-A21AYY4W-V1.0 RS485 Ultrasonic Obstacle Avoidance Sensor (Object Range 3-500cm)₹2,619
DYP-A21AYYGDW-V1.0 TTL Switch Ultrasonic Obstacle Avoidance Sensor Object Range 3–500 cm: another version this guide coversDYP-A21AYYGDW-V1.0 TTL Switch Ultrasonic Obstacle Avoidance Sensor Object Range 3–500 cm₹2,829
DYP-A21AYYCAW-V1.0 CAN Ultrasonic Obstacle Avoidance Sensor (Object Range 3~500cm): another version this guide coversDYP-A21AYYCAW-V1.0 CAN Ultrasonic Obstacle Avoidance Sensor (Object Range 3~500cm)₹2,897
DYP-A21AYYMW-V1.0 PWM Ultrasonic Obstacle Avoidance Sensor (Object Range 3-500cm): another version this guide coversDYP-A21AYYMW-V1.0 PWM Ultrasonic Obstacle Avoidance Sensor (Object Range 3-500cm)₹1,909
DYP-A22YYUW-V1.0 UART Auto Ultrasonic Obstacle Avoidance Sensor (Object Range 2-300cm): another version this guide coversDYP-A22YYUW-V1.0 UART Auto Ultrasonic Obstacle Avoidance Sensor (Object Range 2-300cm)₹2,029
DYP-A22YYTW-V1.0 UART Ultrasonic Obstacle Avoidance Sensor Module – 2-300cm Range: another version this guide coversDYP-A22YYTW-V1.0 UART Ultrasonic Obstacle Avoidance Sensor Module – 2-300cm Range₹2,229
DYP-A22YY4W-V1.0 RS485 Ultrasonic Obstacle Avoidance Sensor (Object Range 2-300cm): another version this guide coversDYP-A22YY4W-V1.0 RS485 Ultrasonic Obstacle Avoidance Sensor (Object Range 2-300cm)₹2,099
DYP-A22YYMW-V1.0 PWM Ultrasonic Obstacle Avoidance Sensor Module (2-300cm Range): another version this guide coversDYP-A22YYMW-V1.0 PWM Ultrasonic Obstacle Avoidance Sensor Module (2-300cm Range)₹1,969
DYP-A22YYCW-V1.0 IIC Ultrasonic Obstacle Avoidance Sensor Object Range 2–300cm: another version this guide coversDYP-A22YYCW-V1.0 IIC Ultrasonic Obstacle Avoidance Sensor Object Range 2–300cm₹1,229
DYP A22YYGDW-V1.0 Switch Ultrasonic Obstacle Avoidance Sensor Module – 2–300cm Range: another version this guide coversDYP A22YYGDW-V1.0 Switch Ultrasonic Obstacle Avoidance Sensor Module – 2–300cm Range₹1,339
ESP32-WROOM-32 38-pin development board: for Wi-Fi logging and dashboardsESP32-WROOM-32 38-Pin Development Board₹389- Uno R3 development board: the controller used in the wiring tableFind this part
MAX485 RS-485 to TTL module: to read RS485 versions from a microcontrollerMAX485 RS-485 to TTL Module₹28
USB to RS485 converter adapter: to test RS485 versions from a PCUSB to RS485 Converter Adapter₹74
HC-SR04 ultrasonic range finder: the classic low-cost ultrasonic sensorHC-SR04 Ultrasonic Range Finder Sensor Module for Arduino₹69Closest match, check the specs
Alternatives and when to choose them
- DYP A01 family: narrower beam, longer range.
- HC-SR04: indoor robots.
- Multi-zone ToF: optical alternative.
Common mistakes to avoid
- Firing several sensors at once, causing crosstalk.
- Mounting so the wide beam hits the floor.
- Using TTL wiring on long, noisy cable runs.
- Setting a stop distance shorter than the braking distance.
Frequently asked questions
Why use A21 or A22 instead of an HC-SR04?
They are waterproof, robust and see obstacles as close as 2 to 3 cm.
Can I use several sensors on one robot?
Yes, but trigger them in turn so they do not hear each other.
Which interface is best for a long robot?
RS485 or CAN handle long cables and noisy motors best.
Why does the sensor see the floor?
The wide beam can catch the ground; tilt it up slightly.
Can they work outdoors in rain?
Yes. They are sealed for outdoor use.
Parts for this guide
Keep learning
Sources
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

