Raspberry Pi Distance with a Sharp IR Sensor

When planning a tech talk with some folks on IoT development, we had to come up with several sensors to demo in order to feed a backend server module. An obvious choice was a PIR motion sensor, which is very straightforward and easy to build. Someone suggested a distance sensor, and having previously worked with a Sharp IR distance sensor (2Y0A02) on an Arduino it seemed like a perfect win.

So, we committed to building this sensor using the Raspberry Pi as our platform.  As we started the development process, we discovered when looking at the datasheets for the Raspberry Pi and the Sharp sensor there was something we overlooked.

The Sharp IR sensor outputs an analog signal, whereas the Raspberry Pi GPIO pins are digital. So in order to build a Raspberry Pi Distance device we have to overcome this. 

Building a Raspberry Pi PIR sensor prototype

A PIR (Passive Infrared) Motion Sensor is one of the easier sensors to work with and is very straightforward to connect to a Raspberry Pi. The motion detector sensor itself has a sensitivity wheel that you can use to adjust motion sensitivity.

The IR sensor is typically encased in a “dome” which is actually has tiny “bubbles” that serve to scatter the beam to increase the motion detection range into a conical shape, rather than a simple straight-ish line.

For most applications and uses, this is definitely desired. If you think about a motion detector, you don’t want to detect motion in a narrow path – you typically want it to cover a wider area. The domes accomplish this purpose.

Let’s build the prototype.

Continue reading “Building a Raspberry Pi PIR sensor prototype”