How to Use Rangefinder for Arduino? – In-Depth Guide with FAQs

People often ask, how to use a rangefinder for Arduino?

Let’s find out!

How to Use Rangefinder for Arduino?

Ultrasonic range finders are used to determine distance. They’re very useful for finding objects and detecting movement. They work better in the dark than in the light. This particular rangefinder measure distances from 2cm to 400cm with an accuracy of +/- 3mm.

How do rangefinders work?

In this article, we will show you how to make 3 different range finder circuits. The first range finds circuit is easy to set-up, up and has pretty good accuracy. The other 2 are a bit more complicated but are more accurate because it factors in temperature and humidity. Before we get into that though, let’s talk about how the rangefinder measures distance.

Download and install Python 3.6.4. Click on download python.exe. Save the file to your desktop. Open the file and run it. Follow the instructions until you reach step 4. Then follow the instructions until you reach the end.

The Speed of Sound

Ultrasonic range finders use pulses of sound waves to determine distances. These devices emit a pulse of sound and wait for it to bounce off objects before determining the distance.

Distance Speed * Time

The time variable is divided into two halves because we only care about the distance traveled by the sound wave. The speed variable is calculated using the formula speed distance/time.

The speed of sound in the air depends on temperature and humidity. At 20 degrees Celsius and 50 percent humidity, sound travels at about 343 meters per second.

The temperature has the biggest impact on the speed of sound, followed by humidity.

Note: If you want to know a complete guide about rangefinder click HERE.

How the Ultrasonic Range Finder Measures Distance

The ultrasonic range finder uses two transducers to send out sound waves. A transmitter sends out the sound wave while a receiver receives the reflected sound wave. An IC called MAX3232 controls the transmitting transducer while another IC called LM324 amplifies the received sound wave.

This project uses an ultrasonic sensor to measure the distance between two objects. A pin connects the sensor to the Arduino. When the sensor detects something, it generates an ultrasonic pulse.

The Arduino receives this pulse and measures how long it takes to return. Based on these measurements, it calculates the distance between the two objects.

To measure distance using ultrasound, you must first transmit a high-voltage pulse into the air. This pulse travels outwards and bounces off objects around you. When the pulse reaches your target, it reflects the sensor.

The sensor then measures the time it takes for the pulse to bounce back to the sensor. Based on the speed of sound (340 m/s), you can calculate how far away your target is by multiplying the time it took for the pulse to travel to the target by 340.

We can calculate the distance by using the formula of distance. In our case, we know the speed of sound (in meters per second) and the time (in seconds). So we can use the following equation to calculate the distance (d): dst.

Note: If you want to know How to Use SLR Magic Rangefinder click HERE.

Ultrasonic Range Finder Setup for Serial Monitor Output

A simple ultrasonic rangefinder that outputs distance measurements to your serial port. You can connect it to an LCD if you want.

Explanation of the Code

The first line declares two variables: duration and distance. Line 12 sends a 2-microsecond low pulse to the trig pin to turn it off at the beginning of each loop. Line 13 sends a 10-microsecond high pulse to the trig pin. Line 15 sends an 8-microsecond pulse to the trig pin, which initiates the sequence of eight 40 kHz pulses.

This program measures how long it takes an echo to return after a high-pitched tone is sent out. The distance variable is defined as the duration times the speed of sound.

If the distance is greater than 400cm, or less than 2cm, display “Distance Out of Range” on the serial monitor. If the distance is not out of range (greater than or equal to 400cm, or less than 2cm), display the distance calculated in Line 20 on the serial monitor.

Ultrasonic Range Finder With LCD Output

Distance measurement is done by measuring the time it takes for the sound wave to travel to the object and back. This information is sent to the LCD screen using the serial monitor.

Note: If you want to know How to Use the Russian Rangefinder click HERE.

A Higher Accuracy Ultrasonic Rangefinder

Adding a thermistor to our range finder circuit gives us better accuracy. We use a thermistor because it changes resistance as temperature changes.

A thermistor is an electronic component that changes resistance according to temperature. By adding a thermistor to our sensor circuit, we can measure distances more accurately.

This program reads the temperature sensor (thermistor) and outputs the reading as an analog voltage via the serial monitor.

Note: if you want to know How to Use Shepherd Scope Rangefinder With Different Bullets clicks HERE.

Explanation of the Code

A basic range finder program that uses the Steinhart-Hart Equation.

how to use rangefinder for arduino

How to Use Rangefinder for Arduino?

High Accuracy Ultrasonic Range Finder

Humidity affects the speed of sound by about 1% in air. This means that if you’re measuring distances in air, humidity should be taken into account when calculating the speed of sound.

There are several types of humidity and temperature sensors you can use on an Arduino. But we will be using the DHT 11 humidity and temperature sensor. It has a thermistor as well as a humidity sensor, so the setup is really simple: after everything is connected, we’ll need to install a special library to run the code. That library is the DHTlib library written by Rob Tilleart. After The library is very easy to install.

Conclusion

Temperature and humidity are measured using the DHT11 sensor. We don’t need to use the Steinhardt-Hart equation to convert resistance to temperature.

The variables for temperature (DHT) and humidity (DHT) are named correctly. Speed is used as a variable within the distance equation on line 27.

We hope that now you know how to use the rangefinder for Arduino. If you have any queries feel free to reach out in the comments section below.

If you want to know more information about rangefinder click HERE.

Author

  • John Moses

    John is the Editor in Chief here at The Outdoor Stores. His area of expertise ensures that there is no one better to suggest which rifles are most suitable for your hunting experience. He is also available for you to contact him personally to discuss the types of animals you want to hunt and the terrain you will be hunting on. Feel free to read his posts for expert opinion on Rifles, Scopes, Rangefinders, Bonoculars and Monoculars.

You Might Be Interested In...

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Might Be Interested In!