Component guide · Beginner · 4 min read
Sharp GP2Y0A21, GP2Y0A02, GP2Y0A41, GP2Y0A51, GP2Y0A710, GP2Y0D

and GP2Y0E03 IR Distance Sensors and Brackets
By Geekobot Learning Team · Updated 29 Oct 2026
On this page
Sharp IR distance sensors measure distance by triangulation: an IR spot hits the target and its position on a detector gives the range. The GP2Y0A21 covers 10 to 80 cm, the GP2Y0A02 20 to 150 cm, the GP2Y0A41 4 to 30 cm, the GP2Y0A51 2 to 15 cm and the GP2Y0A710 1 to 5.5 m. The GP2Y0D parts give a digital yes or no, and the GP2Y0E03 adds I2C.
Key specs at a glance
- Supply
- 4.5 to 5.5 V (GP2Y0E03 2.7 to 3.3 V)
- Output
- Analog voltage, falls with distance; digital (GP2Y0D); I2C (GP2Y0E03)
- Ranges
- 2-15, 4-30, 10-80, 20-150, 100-550 cm by model
- Update
- About 16 to 40 ms
- Current
- About 30 mA average, pulses higher
- Connector
- 3-pin JST PH
Models in this guide
These are alternatives. Pick the one that fits your project; you only need one.
Option 1Sharp GP2Y0A21YK0F IR Distance Sensor, 10-80 cm₹549
Option 2Sharp Microelectronics GP2Y0A02YK0F 20–150 cm Infrared Distance Sensor – Analog Output₹1,349
Option 3Sharp Microelectronics GP2Y0A02YK0F Distance Measuring Sensor Unit 20 to 150 cm – Analog Output₹526
Option 4Sharp Microelectronics GP2Y0A41SK0F 4–30 cm IR Distance Sensor with Cable₹536
Option 5Sharp Microelectronics GP2Y0A41SK0F Analog Output Distance Measurement Sensor₹899
Option 6Sharp Microelectronics GP2Y0A51SK0F 2cm~15cm Infrared Distance Sensor₹729
What the Sharp GP2Y0A IR distance sensors is
Sharp GP2Y0A IR distance sensors, such as the GP2Y0A21 (10 to 80 cm) and GP2Y0A02 (20 to 150 cm), output an analog voltage that falls as distance increases.
The output is not linear: voltage rises as the target comes closer, then falls again inside the minimum range. Mount the sensor so targets cannot get closer than its minimum distance.
Put a 10 to 100 uF capacitor across the sensor's supply; its pulsed current causes noise on other analog readings.
Sharp GP2Y0A IR distance sensors pinout
The pins on the Sharp GP2Y0A IR distance sensors and what each one does.
| Pin | Function |
|---|---|
| Vo | Analog output |
| GND | Ground |
| Vcc | 5 V |
- Vo
- Analog output
- GND
- Ground
- Vcc
- 5 V
Wiring the Sharp GP2Y0A IR distance sensors
Connect the Sharp GP2Y0A IR distance sensors like this.
| Sharp GP2Y0A IR distance sensors pin | Arduino Uno | ESP32 |
|---|---|---|
| Vcc (red) | 5 V | 5 V (VIN) |
| GND (black) | GND | GND |
| Vo (yellow) | A0 | GPIO 34 via 10 k / 20 k divider |
- Vcc (red)
- Arduino Uno:
- 5 V
- ESP32:
- 5 V (VIN)
- GND (black)
- Arduino Uno:
- GND
- ESP32:
- GND
- Vo (yellow)
- Arduino Uno:
- A0
- ESP32:
- GPIO 34 via 10 k / 20 k divider
Example code
Each model has its own curve; make your own fit from a few measured points for best accuracy.
void setup() { Serial.begin(115200); }
void loop() {
long s = 0;
for (int i = 0; i < 16; i++) s += analogRead(A0);
float v = s / 16.0 * 5.0 / 1023.0;
float cm = 27.86 * pow(v, -1.15); // approximate fit for GP2Y0A21, valid 10 to 80 cm
Serial.print(cm, 1); Serial.println(" cm");
delay(100);
}Setup and tuning
red to 5 V, black to GND, yellow to an analog pin.
add a 10 to 100 µF capacitor across power near the sensor to stop noise.
the output is non-linear; use a formula or lookup table to convert voltage to cm.
readings below the minimum distance give false values, so keep objects beyond it.
the output stays under about 3.1 V, but power the sensor from 5 V.
What you need
Shop this list18 of 19 found in our store · ₹11,719
Sharp GP2Y0A21YK0F IR Distance Sensor, 10-80 cm: the part this guide coversSharp GP2Y0A21YK0F IR Distance Sensor, 10-80 cm₹549
Sharp Microelectronics GP2Y0A02YK0F 20–150 cm Infrared Distance Sensor – Analog Output: another version this guide coversSharp Microelectronics GP2Y0A02YK0F 20–150 cm Infrared Distance Sensor – Analog Output₹1,349
Sharp Microelectronics GP2Y0A02YK0F Distance Measuring Sensor Unit 20 to 150 cm – Analog Output: another version this guide coversSharp Microelectronics GP2Y0A02YK0F Distance Measuring Sensor Unit 20 to 150 cm – Analog Output₹526
Sharp Microelectronics GP2Y0A41SK0F 4–30 cm IR Distance Sensor with Cable: another version this guide coversSharp Microelectronics GP2Y0A41SK0F 4–30 cm IR Distance Sensor with Cable₹536
Sharp Microelectronics GP2Y0A41SK0F Analog Output Distance Measurement Sensor: another version this guide coversSharp Microelectronics GP2Y0A41SK0F Analog Output Distance Measurement Sensor₹899
Sharp Microelectronics GP2Y0A51SK0F 2cm~15cm Infrared Distance Sensor: another version this guide coversSharp Microelectronics GP2Y0A51SK0F 2cm~15cm Infrared Distance Sensor₹729
Sharp Microelectronics GP2Y0A51SK0F Analog Distance Sensor, Analog Voltage Output, Range: 2–15 cm: another version this guide coversSharp Microelectronics GP2Y0A51SK0F Analog Distance Sensor, Analog Voltage Output, Range: 2–15 cm₹619
Sharp Microelectronics GP2Y0A710K0F 100–550cm Distance Sensor with Cable: another version this guide coversSharp Microelectronics GP2Y0A710K0F 100–550cm Distance Sensor with Cable₹419
Sharp Microelectronics GP2Y0D21YK0F Digital Distance Sensor, 1-bit Digital Output, Range: 13 cm: another version this guide coversSharp Microelectronics GP2Y0D21YK0F Digital Distance Sensor, 1-bit Digital Output, Range: 13 cm₹629
Sharp Microelectronics GP2Y0D810Z0F Distance Measuring Sensor – Digital Output, 100mm Range: another version this guide coversSharp Microelectronics GP2Y0D810Z0F Distance Measuring Sensor – Digital Output, 100mm Range₹2,649
Sharp Microelectronics GP2Y0E03 Distance Sensor, Analog + I²C Output, Range: 4–50 cm: another version this guide coversSharp Microelectronics GP2Y0E03 Distance Sensor, Analog + I²C Output, Range: 4–50 cm₹657
Sharp Microelectronics GP2Y0E03 IR Distance Sensor Module – I2C Output: another version this guide coversSharp Microelectronics GP2Y0E03 IR Distance Sensor Module – I2C Output₹749
Sharp Microelectronics GP2AP03VT00F Distance Sensor, I²C Digital Output, Range: 1 cm~30 cm: another version this guide coversSharp Microelectronics GP2AP03VT00F Distance Sensor, I²C Digital Output, Range: 1 cm~30 cm₹267
EasyMech Multi Bracket for Sharp Microelectronics Distance Sensors – Mild Steel, M3 Hardware, Parallel & Perpendicular Mounting: another version this guide coversEasyMech Multi Bracket for Sharp Microelectronics Distance Sensors – Mild Steel, M3 Hardware, Parallel & Perpendicular Mounting₹87
EasyMech Perpendicular Mounting Bracket for Sharp Microelectronics IR Sensors – MS Steel w/ Nylon Hardware: another version this guide coversEasyMech Perpendicular Mounting Bracket for Sharp Microelectronics IR Sensors – MS Steel w/ Nylon Hardware₹85- Uno R3 development board: the controller used in the wiring tableFind this part
ESP32-WROOM-32 38-pin development board: for Wi-Fi logging and dashboardsESP32-WROOM-32 38-Pin Development Board₹389
TowerPro SG90 micro servo: to sweep the sensor for a scanTowerPro SG90 9g Micro Servo (180°)₹442Closest match, check the specs
0.96 inch OLED display 128x64: to show readings without a computer0.96" OLED Display 128x64₹139Closest match, check the specs
Alternatives and when to choose them
- Sharp IR distance sensors: overview.
- VL53L0X ToF: digital, linear, small.
- HC-SR04 ultrasonic: wider beam.
Common mistakes to avoid
- Leaving out the capacitor.
- Objects inside the minimum range.
- Assuming linear output.
- Powering from 3.3 V.
Frequently asked questions
Why are my Sharp sensor readings noisy?
It draws current pulses; add a capacitor near the sensor and average readings.
How do I convert the voltage to distance?
Use the datasheet curve, a fitted formula or a lookup table.
Why does it read far when an object is very close?
Below the minimum range the voltage falls again, giving false readings.
Can I use it with ESP32?
Yes, power it from 5 V; the output stays below 3.3 V.
Does colour affect readings?
Less than simple IR sensors, but very dark or shiny surfaces still matter.
Parts for this guide
- ₹549View
- ₹1,349View
- ₹526View
- ₹536View
- ₹899View
- ₹729View
- ₹619View
- ₹419View
- ₹629View
- ₹2,649View
- ₹657View
- ₹749View
- ₹267View
EasyMech Multi Bracket for Sharp Microelectronics Distance Sensors – Mild Steel, M3 Hardware, Parallel & Perpendicular Mounting₹87View
EasyMech Perpendicular Mounting Bracket for Sharp Microelectronics IR Sensors – MS Steel w/ Nylon Hardware₹85View- ₹359View
- ₹389View
- ₹442View
- ₹139View
Keep learning
Sources
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

