I have one question . I want to try out a sensor called E18-D50NK, which is a infrared proximity sensor, for obstacle avoidance. More details and information about this sensor can be found here :


It says that the sensor is for arduino, and I also want to try it on a Raspberry Pi. My question is how can I set it up, and what kind of python program would I need to read information from it.

It says that the red wire connects to the voltage which in this case is 4.5 to 5, which the raspberry pi can supply. The green wire connects to GND (ground), and the yellow :connect with single chip microcomputer,output TTL level to microcomputer. And that I am not very sure how and where to connect it.

If anyone knows how to wire up this sensor, and how to write a python program in order to read its information and data, please post and explain below. Thank You !

One other thing is that I think this sensor has analog output, which means that I will need an analog to digital converter, and that is not a problem because I have one, running via I2C.

1 Answer 1


The documentation is appalling.

My best guess from looking at example Arduino code is that the output is an open collector digital signal.

So connect a Pi ground to sensor ground, a Pi 5V pin to sensor power and any gpio to the yellow wire.

Enable the internal pull-up on the chosen gpio to 3V3.

Being an open collector output means the output line is never driven high, it will normally float to the pull-up voltage of 3V3 and read 1. When an obstacle is detected the line will be driven low and will then read 0.

  • Thank You for the answer, so all I need to do is set the output of the GPIO that the sensor is connected to HIGH, and see whether it gives me 1 or 0 ? Jun 19, 2015 at 21:23
  • @ViktorRaspberry You should set the gpio as an input and enable the internal pull-up to 3V3. The library you use will have a method to do that. Then the gpio will read as 1 if no obstacle is detected and read as 0 if an obstacle is detected.
    – joan
    Jun 19, 2015 at 21:27

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.