1
\$\begingroup\$

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
  Wire.begin();
  Serial.begin(19200);

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

  // Read the sift bit register from the module, used in calculating range
  Wire.beginTransmission(ADDRESS);    
  Wire.write(SHIFT);
  Wire.endTransmission();

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

void loop()
{
  // Request and read the 2 address bytes from the GP2Y0E02B
  Wire.beginTransmission(ADDRESS);
  Wire.write(DISTANCE_REG);
  Wire.endTransmission();

  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 ");
  Serial.print(distance);
  Serial.println("CM");

  delay(50);
}
\$\endgroup\$
10
  • 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\$ Commented 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
    Commented Sep 3, 2016 at 8:17
  • \$\begingroup\$ It says on the datasheet : robotgear.com.au/Cache/Files/Files/199_gp2y0e02b_e.pdf \$\endgroup\$ Commented Sep 3, 2016 at 8:23
  • 1
    \$\begingroup\$ On the schematic the I2C interface pins are not connected (NC). \$\endgroup\$ Commented 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\$ Commented Sep 3, 2016 at 9:14

1 Answer 1

2
\$\begingroup\$

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

\$\endgroup\$

Your Answer

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

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