Robot Pi Shop

GP2Y0A21YK0F 10-80cm IR Distance Sensor

$5.99

Shipping calculated at checkout.

Quantity

Sharp GP2Y0A21YK0F IR Distance Sensor – 10–80cm Analog Output

The Sharp GP2Y0A21YK0F is an infrared distance measuring sensor designed for non-contact object detection and distance measurement from approximately 10 to 80cm.

The sensor combines an infrared emitting diode (IRED), position-sensitive detector (PSD), and signal-processing circuit in a compact module. It uses optical triangulation to produce an analog voltage that changes according to the distance of the detected object.

It is ideal for robotics, obstacle detection, proximity sensing, automation and interactive electronics projects.

Technical Specifications

  • Model: GP2Y0A21YK0F
  • Manufacturer: Sharp
  • Sensor Type: Infrared Distance Sensor
  • Measurement Method: Optical Triangulation
  • Detection Range: 10–80cm
  • Output Type: Analog Voltage
  • Recommended Supply Voltage: 4.5–5.5V DC
  • Typical Supply Voltage: 5V DC
  • Average Current Consumption: Approx. 30mA
  • Maximum Specified Average Current: 40mA
  • Typical Output at 80cm: Approx. 0.4V
  • Output Voltage Difference, 10–80cm: Approx. 1.9V Typical
  • Operating Temperature: -10°C to +60°C
  • Storage Temperature: -40°C to +70°C

How It Works

The GP2Y0A21YK0F emits infrared light toward the target.

Reflected infrared light is detected by the internal PSD sensor, and the position of the reflected beam is used to estimate the object's distance through triangulation.

The internal signal-processing circuit then generates an analog voltage corresponding to the measured distance.

This means the sensor does not simply provide an ON/OFF signal—the analog output can be read by a microcontroller's ADC to estimate distance.

Analog Output

The relationship between output voltage and distance is non-linear.

Generally:

  • Closer Object → Higher Output Voltage
  • Farther Object → Lower Output Voltage

At approximately 80cm, the typical output is around 0.4V.

For applications requiring accurate distance values, the output should be converted using the sensor's characteristic curve or calibrated experimentally.

Connections

The sensor uses three electrical connections:

  • VCC: 4.5–5.5V DC
  • GND: Ground
  • VO: Analog Voltage Output

Arduino Compatibility

The GP2Y0A21YK0F can be connected to an Arduino analog input.

Typical connection:

  • Sensor VCC → Arduino 5V
  • Sensor GND → Arduino GND
  • Sensor VO → Arduino Analog Input

The Arduino ADC can then measure the output voltage and convert it into an approximate distance.

ESP32 Compatibility

The sensor can also be used with an ESP32.

  • Power the sensor from an appropriate 5V supply.
  • Connect grounds together.
  • Connect the analog output to a suitable ESP32 ADC input.

The sensor's output should be checked against the permitted ADC input range of the particular ESP32 board being used.

Raspberry Pi Compatibility

A standard Raspberry Pi does not have a built-in analog-to-digital converter.

To use this sensor with Raspberry Pi, an external ADC is required, such as:

  • ADS1115
  • MCP3008
  • Other Compatible ADC Modules

Power Supply Recommendation

The GP2Y0A21YK0F can draw short current pulses during operation.

For stable operation, adding a capacitor of approximately 10µF or larger across VCC and GND close to the sensor is recommended.

Physical Specifications

  • Sensor Body: Approx. 29.5 × 13 × 13.5mm
  • Overall Assembly Size: Approx. 44.5 × 18.9 × 13.5mm
  • Approximate Weight: 3.5g
  • Connection: 3-Pin Connector

Applications

Ideal for:

  • Robot Obstacle Detection
  • Mobile Robots
  • Robot Vacuum Cleaners
  • Proximity Detection
  • Object Detection
  • Touchless Controls
  • Distance Measurement
  • Autonomous Robotics
  • Smart Devices
  • Interactive Systems
  • Automation Projects
  • Arduino Projects
  • ESP32 Projects
  • Raspberry Pi Projects with External ADC
  • Educational Projects
  • University Projects

Advantages

  • 10–80cm Useful Detection Range
  • Non-Contact Measurement
  • Analog Distance Output
  • Compact Size
  • Low Power Consumption
  • Easy Microcontroller Integration
  • Optical Triangulation Measurement
  • Suitable for Robotics and Automation

Important Notes

  • The specified measurement range is 10–80cm.
  • Objects closer than approximately 10cm are outside the specified measurement range and can produce misleading readings.
  • Output voltage is not linear with distance.
  • Calibration is recommended when accurate distance measurement is required.
  • Object color, surface properties, angle and environmental conditions can affect real-world measurements.
  • The sensor requires approximately 4.5–5.5V DC for normal operation.
  • This is an analog sensor, not an I²C, UART or digital distance sensor.
  • Raspberry Pi requires an external ADC to read the analog output.

Package Includes

1 × Sharp GP2Y0A21YK0F 10–80cm IR Distance Sensor