Introduction: Infrared Radar With Arduino

About: I am an electrical engineer graduated at Budapest University of Technology and Economics. Besides my work I also like to do simple DIY electrical projects at home and I decided to share these projects with the…

In this small project I would like to show you how can you create a simple Radar at Home with Arduino. There are many similar projects on the internet, but they are all using an ultrasonic sensor to measure the distance. In this project I use an infrared sensor for distance measurement.

My goal is to create a very simple and cheap LIDAR system with it and implement a mapping device.

Supplies

  • Arduino (I used a Maple Mini)

  • Sharp distance sensor (I used Sharp GP2Y0A02YK0F)

  • Micro Servo (9g)

  • Breadboard, wires

  • Optional: 4.7k Resistor, 100nF Capacitor

Step 1: Ultrasonic VS Infrared Sensor

The main difference between ultrasonic and infrared distance sensors is that the ultrasonic sensor measures distance in wider range. Therefore it is not able to precisely locate the position of an obstacle. It means that it measures the distance of the closest object which is located inside a ~ +-30° angle range.

Of course, it doesn’t mean that the Sharp sensor is better. Sometimes this property can be very useful (e.g. used by drones to measure height from ground). The right choice is totally depending on the requirements of your project.

Step 2: Schematic

It is very simple to make the connection between parts. Select a PWM Output and an Analog Input on your Arduino board and connect the Servo and Sharp distance sensors to those pins. I used the following pins for this purpose:

  • PA0: Analog input for Sharp distance sensor
  • PA9: PWM Output for Servo

Sometimes the Sharp IR Sensor can have noisy output, therefore you have to put a simple Low Pass Filter on it. I used a 4.7k resistor and a 100nF capacitor to reduce the noise on the analog pin. Besides that I also filtered the measured value in the code by reading it multiple times and calculating the average.

Step 3: Sensor Characteristic

Unfortunately the used infrared distance sensor has non-linear characteristic. It means that to get the distance, it is not enough to multiply the measured ADC value with a constant value and adding another constant value to it.

Although the datasheet of the sensor provides the characteristic, I prefer to measure it by myself in the specific project (it could depend on the used voltage). For this, I made pairs from the measured ADC Value and distance for every 10 cm. (My sensor was able to measure correct distance from 12 cm).

I used these pairs in the code to get the correct distance with Linear Interpolation.

You will find a simple Arduino code at the end of document, to measure ADC Value during characteristic measurement.

Step 4: Serial Communication

I used serial communication to send the measured angle-distance values to the PC. Since I have to send multiple bytes and different type of messages, I designed a simple communication protocol.

This procotol makes able to define different message types in a generic way. In this project I used 2 message types:

  • Parameters: Used to send parameters to PC Application, defined on Arduino like maximum distance and number of obstacles in a round.
  • Obstacle: Used to send a detected obstacle. It is identified by angle of the servo and measured distance. The x-y position will be calculated by PC application.

Step 5: Qt Application

To communicate with Arduino and draw the measured points like a radar I made a PC Application in Qt (C++). It receives some parameters (defined on Arduino) and the measured distance points.

You can download the application and its source code also.

Step 6: Arduino Source Code

You can customize some paremeters at the top of the code with macros.

Note, that if you change the characteristic of the Sharp distance sensor, you have to modify distAdcMap[] array values!

  • InfraRadar.c: Code of radar. Copy and paste it into your Arduino project.
  • InfraRadarMeasurement.c: Code for characteristic measurement. Copy and paste it into your Arduino project. Use Serial Console to check ADC Values.