Same-day dispatch before 2 PM · Free delivery over ₹999 · GST invoices Get the appPrices incl. GST
Geekobot
Snap & SendNEWGeeko AIWhere's myOrder
Log in
Products
  • Projects
    • Component guidesHow parts work, with code you can run
    • Learning pathsFrom your first LED to your first robot
    • Workshops & eventsOnline sessions for makers and classes
    • ElectrolarkFree guided builds, simulator and certificates
    • Students & teachersStudent discount and classroom help
    • CommunityShare builds and ask other makers
    • CalculatorsOhm's law, LED resistor, 555 and 100+ more
    • Circuit builderWire parts and run the circuit, powered by Electrolark
    • Geeko AIAsk what to buy or how to wire it
    • Snap & SendPhotograph a part or list, we find it
    • Part finderAnswer a few questions, get the right part
    • Compatibility checkWill these two parts work together?
    • Compare partsSpecs side by side
    • Business & bulk ordersGST invoices, credit and volume prices
    • Request a quotationSend your list, get a quote
    • Classroom kitsPer-student kits and lab bundles
    • Gift cardsFor students, teams and events
  • Atal Tinkering Lab
BOM to cart
Geekobot

Components, kits and know-how for makers, students, engineers, labs and businesses across India.

Ask Geeko AIOrders, parts and projects, any timeEmail supportReply within 1 working dayGet the Geekobot appAdd it to your home screen, free

Follow us

Shop

  • Boards & SBCs
  • Sensors & Modules
  • IoT & Wireless
  • Drone & FPV
  • 3D Printing
  • Filaments & Resins
  • Motors & Drivers
  • Power & Batteries
  • Semiconductors
  • Passive
  • Displays & LEDs
  • Switches & Relays
  • Wires & Cables
  • Prototyping
  • Tools & Test
  • Robotics
  • STEM Kits
  • Atal Tinkering Lab
  • Mechanical Parts
  • Audio

Orders

  • Track your order
  • Help & support
  • Shipping and delivery
  • Refunds and cancellation
  • Contact us

Learn

  • Projects
  • Geeko AI project assistant
  • Learning paths
  • Guides
  • Calculators
  • Electrolark: free guided builds

Part tools

  • Part finder
  • Compare parts
  • Will it work with my board?

Institutions

  • Classroom kits
  • Atal Tinkering Lab
  • Students & teachers
  • Workshops & Events

Business

  • Business & education
  • Request a quotation
  • BOM bulk upload
  • Quick order by SKU

Company

  • About Geekobot
  • Community
  • Gift cards
  • Terms & conditions
  • Privacy policy
  • Product directory
  • Sitemap

© 2026 Geekobot, a trade name of OLatus Systems Private Limited. All rights reserved.

20, 1st Floor, Neeladri Complex, 10th Cross, Sampige Rd, 2nd Main, Malleshwaram, Bengaluru, Karnataka 560003 · GSTIN 29AACCO0462F1ZM

+91 91810 15607 · connect@geekobot.in · Monday to Saturday, 10 AM to 2 PM IST

UPI · CARDS · NETBANKING · GST INVOICES

ShopProjectsGeeko AIGuides
Compare 0 parts →
Log in

Shop by category

Shop all components
  • Boards & SBCs1,910 products
    • Alternative Single Board Computers
    • Arduino Ecosystem
    • FPGA & Logic Boards
    • Microcontroller & Wireless Boards
    View all
  • Sensors & Modules4,701 products
    • Biomedical & Heart Rate
    • Current, Voltage & Power
    • Force, Weight & Pressure
    • Gas, Weather & Environmental
    View all
  • IoT & Wireless2,314 products
    • RF Modules
    • RFID & NFC
    • Antennas & RF Accessories
    • Cameras & Smart Vision
    View all
  • Drone & FPV3,558 products
    • Flight Control & Navigation
    • FPV Video & Optics
    • Frames & Structural Parts
    • Motors & Propulsion
    View all
  • 3D Printing2,204 products
    • 3D Printers
    • 3D Scanners & Digitizers
    • Laser Engravers & Cutters
    • Material Management & Upgrades
    View all
  • Filaments & Resins1,472 products
    • Filaments
    • Photopolymer Resins
    View all
  • Motors & Drivers463 products
    • BLDC Motor Drivers
    • DC & Geared Motors
    • DC Motor Drivers
    • Linear Actuators & Solenoids
    View all
  • Power & Batteries557 products
    • Battery Holders & Connectors
    • Breadboard Power
    • Chargers & BMS
    • DC-DC Converters
    View all
  • Semiconductors295 products
    • Diodes & Rectifiers
    • Interface & RF Encoder ICs
    • Logic ICs (74xx)
    • Logic ICs (CD4000)
    View all
  • Passive67 products
    • Capacitors
    • Circuit Protection
    • Crystals & Oscillators
    • Inductors
    View all
  • Displays & LEDs572 products
    • 7-Segment & Dot Matrix
    • Addressable LEDs
    • Character LCDs
    • Graphic LCDs
    View all
  • Switches & Relays184 products
    • Keypads & Touch
    • Push Buttons & Tactile
    • Relay Modules
    • Relays
    View all
  • Wires & Cables233 products
    • Board-to-Wire Connectors
    • Crimp & Splice
    • Headers & Dupont
    • Heat Shrink & Sleeving
    View all
  • Prototyping101 products
    • Breadboards
    • Interface Modules
    • PCBs & Perfboards
    View all
  • Tools & Test717 products
    • Bench Power Supplies
    • Hand Tools
    • Measuring Tools
    • Meters & Testers
    View all
  • Robotics180 products
    • Humanoid & Legged Robots
    • Robot Chassis & Platforms
    • Robotic Arms & Grippers
    • Wheels & Casters
    View all
  • STEM Kits268 products
    • Arduino Learning Kits
    • Coding & IoT Kits
    • Early Coding (Ages 3-8)
    • Invention Kits
    View all
  • Atal Tinkering Lab196 products
    • Package 1: Electronics, Robotics, IoT and Sensors
    • Package 2: Rapid Prototyping Tools
    • Package 3: Mechanical, Electrical and Measurement Tools
    • Package 4: Power Supply, Accessories and Safety Equipment
    View all
  • Mechanical Parts212 products
    • Bearings
    • Brackets & Mounts
    • Couplers
    • Fasteners & Standoffs
    View all
  • Audio109 products
    • Amplifier Modules
    • Buzzers & Sirens
    • Speakers
    View all
  1. Home
  2. ›Guides
  3. ›Sensors
  4. ›Sharp GP2Y0A21, GP2Y0A02, GP2Y0A41, GP2Y0A51, GP2Y0A710

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

I'm using
Wiring, code and the Run it panels follow your board.
On this page
Short answerWhat the Sharp GP2Y0A IR distance sensors isSharp GP2Y0A IR distance sensors pinoutWiring the Sharp GP2Y0A IR distance sensorsExample codeSetup and tuningWhat you needAlternatives and when to choose themCommon mistakesFAQsParts and next steps
Short answer

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
01

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.

02

Sharp GP2Y0A IR distance sensors pinout

The pins on the Sharp GP2Y0A IR distance sensors and what each one does.

PinFunction
VoAnalog output
GNDGround
Vcc5 V
PinFunction
Vo
Analog output
GND
Ground
Vcc
5 V
03

Wiring the Sharp GP2Y0A IR distance sensors

Connect the Sharp GP2Y0A IR distance sensors like this.

Sharp GP2Y0A IR distance sensors pinArduino UnoESP32
Vcc (red)5 V5 V (VIN)
GND (black)GNDGND
Vo (yellow)A0GPIO 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
04

Example code

Each model has its own curve; make your own fit from a few measured points for best accuracy.

GP2Y0A21 distance in cm (curve fit) · Arduino C++Verify & upload in Electrolark
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);
}
05

Setup and tuning

Wiring

red to 5 V, black to GND, yellow to an analog pin.

Capacitor

add a 10 to 100 µF capacitor across power near the sensor to stop noise.

Conversion

the output is non-linear; use a formula or lookup table to convert voltage to cm.

Range

readings below the minimum distance give false values, so keep objects beyond it.

3.3 V boards

the output stays under about 3.1 V, but power the sensor from 5 V.

06

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
07

Alternatives and when to choose them

  • ✓Sharp IR distance sensors: overview.
  • ✓VL53L0X ToF: digital, linear, small.
  • ✓HC-SR04 ultrasonic: wider beam.
08

Common mistakes to avoid

  • !Leaving out the capacitor.
  • !Objects inside the minimum range.
  • !Assuming linear output.
  • !Powering from 3.3 V.
09

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

  • Sharp GP2Y0A21YK0F IR Distance Sensor, 10-80 cm
    ₹549View
  • Sharp Microelectronics GP2Y0A02YK0F 20–150 cm Infrared Distance Sensor – Analog Output
    ₹1,349View
  • Sharp Microelectronics GP2Y0A02YK0F Distance Measuring Sensor Unit 20 to 150 cm – Analog Output
    ₹526View
  • Sharp Microelectronics GP2Y0A41SK0F 4–30 cm IR Distance Sensor with Cable
    ₹536View
  • Sharp Microelectronics GP2Y0A41SK0F Analog Output Distance Measurement Sensor
    ₹899View
  • Sharp Microelectronics GP2Y0A51SK0F 2cm~15cm Infrared Distance Sensor
    ₹729View
  • Sharp Microelectronics GP2Y0A51SK0F Analog Distance Sensor, Analog Voltage Output, Range: 2–15 cm
    ₹619View
  • Sharp Microelectronics GP2Y0A710K0F 100–550cm Distance Sensor with Cable
    ₹419View
  • Sharp Microelectronics GP2Y0D21YK0F Digital Distance Sensor, 1-bit Digital Output, Range: 13 cm
    ₹629View
  • Sharp Microelectronics GP2Y0D810Z0F Distance Measuring Sensor – Digital Output, 100mm Range
    ₹2,649View
  • Sharp Microelectronics GP2Y0E03 Distance Sensor, Analog + I²C Output, Range: 4–50 cm
    ₹657View
  • Sharp Microelectronics GP2Y0E03 IR Distance Sensor Module – I2C Output
    ₹749View
  • Sharp Microelectronics GP2AP03VT00F Distance Sensor, I²C Digital Output, Range: 1 cm~30 cm
    ₹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
  • Uno R3 Development Board (No Cable)
    ₹359View
  • ESP32-WROOM-32 38-Pin Development Board
    ₹389View
  • TowerPro SG90 9g Micro Servo (180°)
    ₹442View
  • 0.96" OLED Display 128x64
    ₹139View
Shop Infrared, ToF & LiDAR Distance Sensors

Keep learning

Component guideBeginnerSharp IR Distance SensorsSharp IR distance sensors measure distance by triangulation and output an analog voltage that falls as the distance grows.3 min read · SensorsComponent guideIntermediateVL53L0X and VL53L1X Laser Distance SensorsThe VL53L0X and VL53L1X are tiny time-of-flight sensors from ST.3 min read · SensorsComponent guideBeginnerHC-SR04 Ultrasonic SensorThe HC-SR04 measures distance from about 2 cm to 4 m by sending a 40 kHz ultrasonic pulse and timing the echo.3 min read · Sensors

Sources

  • Sharp GP2Y0A21YK0F and GP2Y0A02YK0F datasheets

Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

On this page
Short answerWhat the Sharp GP2Y0A IR distance sensors isSharp GP2Y0A IR distance sensors pinoutWiring the Sharp GP2Y0A IR distance sensorsExample codeSetup and tuningWhat you needAlternatives and when to choose themCommon mistakesFAQsParts and next steps
Need a hand?Ask Geeko AI which part fits your project, or talk to the Geekobot team.Ask Geeko AIHelp & support

Parts for this guide8 items · ₹5,626

Sharp GP2Y0A21YK0F IR Distance Sensor, 10-80 cm · Sharp Microelectronics GP2Y0A02YK0F 20–150 cm Infrared Distance Sensor – Analog Output · Sharp Microelectronics GP2Y0A02YK0F Distance Measuring Sensor Unit 20 to 150 cm – Analog Output · Sharp Microelectronics GP2Y0A41SK0F 4–30 cm IR Distance Sensor with Cable · Sharp Microelectronics GP2Y0A41SK0F Analog Output Distance Measurement Sensor · Sharp Microelectronics GP2Y0A51SK0F 2cm~15cm Infrared Distance Sensor · Sharp Microelectronics GP2Y0A51SK0F Analog Distance Sensor, Analog Voltage Output, Range: 2–15 cm · Sharp Microelectronics GP2Y0A710K0F 100–550cm Distance Sensor with Cable

Run itChange the inputs and watch the output

GP2Y0A21: 10 to 80 cm. Closer than 10 cm the voltage falls again and the reading is wrong.

Serial monitor115200 baud
24.8 cm

A simulation of the sketch above, so you know what to expect. Real readings vary with your parts and wiring.

Ask the Community

Ask a question