I am wondering can we connect directly Lego EV3 infrared sensor to Raspberry Pi 3 via I2C? I tried to cut cable from one side, and connect wires on SDL, SCL, GND and 3.3V pins on Raspberry Pi (3, 5, 6 and 1 pin, respective), but i2cdetect -y 1 shows that there is nothing on I2C bus. When I tried to connect sensor to 5V pin (with 5V ground wire from sensor on GND pin of Raspberry), raspberry failed to boot. :) Is this means that this sensor can not be directly connected or I am doing something wrong?

  • Could you link to the sensor specs? Why do you think it is I2C? – joan Apr 25 '17 at 8:48
  • All Lego Sensors have an I2C interface @joan – mystery Apr 25 '17 at 8:51

Yes, it is possible. I would have advised you to get female sensor sockets to not have to cut your wire, though.

However, go through the typical steps regarding I2C devices on the RasPi, like enabling kernel support if you haven't already.


enter image description here

This is a picture of a similiar setup. Ignore the blue wire, you don't have that one.

Be VERY CAREFUL about the cables inside, they might not be what they look like (colouring)

5V         -->     green 
SCL        -->     yellow
SDA        -->     blue
GND        -->     red

If that does not work, I suggest adding Pullup-Resistors(to 5V) to both, the SDA and SCL lines, of at least 10k value.

Another thing to mention is that the LEGO devices only support the classic Register-style communication. A typical read operation looks like this:

i2c_start(<address>, <write mode>); i2c_write(<register address to read from>); i2c_restart(<address>, <read mode>); i2c_read(<number of bytes to read>); i2c_stop();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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