Sensor GP2Y0E03 and I2C communication

Hello guys,

I recently purchased a GP2Y0E03 distance sensor, it Works with I2C communication.

I have been having problems with programming that. I made the configuration for the I2C communication and try to read the distance information through the Serial, but nothing appers on the screen, even the "Serial.print("dist = ");
Im using this

#include <Wire.h>

void setup() {

void getData(byte *a, byte *b)

void loop() {

byte aa,bb;
float distance1=aa;
float distance2=bb;
float dist=analogRead(A0);
Serial.print("distance1 = ");


The pins connections that i made was:

Anyone know how to properly use this sensor?

I recently purchased a GP2Y0E03 distance sensor, it Works with I2C communication.

Interesting, the sensors I can find for "GP2Y0E03" doesn't have an I2C interface but simply an analog output. Please post a link to the sensor you are using!

Connecting that analog output to A0 and then setting that same pin as an output in the Arduino code produces a short circuit. This may have ruined the Arduino pin and the sensor.

Hello! thx for Reading
This is the sensor im using

The sensor has 3.3V I/O and the I/O pins will be damaged if exposed to 5V.

Post a wiring diagram (hand drawn, not Fritzing).

Did you obey the timing restrictions on Vdd, and 3.3V Vin(I/O), as described in the data sheet?

Yes, they are in 3.3V

Here I get all the details about GP2Y0E03 distance sensor, Arduino code, Datasheet etc.

Are you using an Arduino Uno or Nano board ? Those are 5V Arduino boards.
In Standby the sensor uses very little current and the internal pullup resistors (in the Arduino Uno) to 5V of SDA and SCL might damage the sensor.

When using a I2C device for the first time, run a I2C Scanner.

There are a number of weird things in the datasheet. This is not an easy sensor to interface.