I have a IR proximity sensor with 4 wires sticking out, I know which the GND and V+ but I cant figure out which the SDA and SCL wires are (even from looking at the datasheet). Any ideas what the Blue and Yellow ones represent, from the schematic / image below and code:

enter image description here enter image description here

  Arduino GP2Y0E02B example code
  Gets range from GP2Y0E02B and prints it to the serial monitor.

  By James Henderson 2014

#include <Wire.h>

int distance = 0;                // Stores the calculated distance 
byte high, low = 0;              // High and low byte of distance
int shift = 0;                   // Value in shift bit register

#define ADDRESS       0x80 >> 1  // Arduino uses 7 bit addressing so we shift address right one bit
#define DISTANCE_REG  0x5E
#define SHIFT         0x35

void setup()
  // Start comms

  delay(50);  // Delay so everything can power up

  // Read the sift bit register from the module, used in calculating range

  Wire.requestFrom(ADDRESS, 1);
  while(Wire.available() == 0);
  shift = Wire.read();

void loop()
  // Request and read the 2 address bytes from the GP2Y0E02B

  Wire.requestFrom(ADDRESS, 2);

  while(Wire.available() < 2);

  high = Wire.read();
  low = Wire.read();

  distance = (high * 16 + low)/16/(int)pow(2,shift); // Calculate the range in CM

  Serial.print("Distance is ");

  • 1
    \$\begingroup\$ Why do you think it's I2C? It looks to me like you get Vout proportional to distance, which you'd normally read into an ADC. \$\endgroup\$ Sep 3, 2016 at 8:14
  • 1
    \$\begingroup\$ How do you know this mystery device is even supposed to have SDA and SCL connections? \$\endgroup\$
    – Majenko
    Sep 3, 2016 at 8:17
  • \$\begingroup\$ It says on the datasheet : robotgear.com.au/Cache/Files/Files/199_gp2y0e02b_e.pdf \$\endgroup\$
    – condo1234
    Sep 3, 2016 at 8:23
  • 1
    \$\begingroup\$ On the schematic the I2C interface pins are not connected (NC). \$\endgroup\$ Sep 3, 2016 at 9:11
  • 2
    \$\begingroup\$ But the schematic in the datasheet does not match with the one in your question. Page 2. of datasheet tells you that pin No3 is SDA and pin No4 is SCL. \$\endgroup\$ Sep 3, 2016 at 9:14

1 Answer 1


From the comments: Problem found - use the correct datasheet, this one for the analog output GP2Y0E02A and this for the I2C output GP2Y0E02B.

From the GP2Y0E02B datasheet, here is the pinout of the 4-way connector, showing SDA (pin 3) and SCL (pin 4) (as Bence Kaulics kindly explained in earlier comments). I have marked pin 1, as the drawing is quite blurry:

pinout of Sharp sensor GP2Y0E02B


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.