Ultrasonic sensor hcsr04 ultrasonic sensor hcsr04 sen15569 this is the hcsr04 ultrasonic ranging sensor. Recently i made an internet of things project which involves an ultrasonic sensor and nodemcu wifi module in it. The hcsr04 is an inexpensive ultrasonic distance sensor that can assist your robot in navigating around a room. It is efficient and suitable for many applications that require sensitive measurements in places where it is impractical to measure distance physically. Ultrasonic sensor hcsr04 is a sensor that can measure distance. Another substitute for the ultrasonic sensor is the hcsr04 module. Distance measurement using arduino and ultrasonic sensor. Hcsr04 ultrasonic distance sensor with arduino dronebot. Well explain how it works, show you some of its features and share an arduino project example you can follow to integrate in your projects. It emits an ultrasound at 40 000 hz 40khz which travels through the air and if there is an object or obstacle on its path it will bounce back to the module. Arduino hcsr04 sensor arduino hcsr04 ultrasonic sensor and processing example by hisham marzouk download arduino code and processing code.
This economical sensor provides 2cm to 400cm of noncontact measurement functionality with a ranging accuracy that can reach up to 3mm. Ultrasonic sensor hcsr04 arduino tutorial ardumotive. Ultrasonic ranging module hc sr04 provides 2cm 400cm noncontact measurement function, the ranging accuracy can reach to 3mm. It comes complete with ultrasonic transmitter and receiver modules. It utilizes noncontact technology, with physical contact between the sensor and objects not needed for. The latest version of this library can be downloaded here on. The module is very easy use, now with the library, user just need a function then he can get the distance. The ultrasonic sensor also known as distance measuring sensor provides 2cm to 400cm of noncontact measurement functionality with a ranging accuracy that can reach up to 3mm. Ultrasonic sensor interfaced with nodemcu esp8266 12e for. Ultrasonic module hcsr04 distance measuring transducer sensor for arduino new. Ultrasonic sensor hcsr04 with arduino tutorial arduino project. The pir sensor was used to detect movement while the ultrasonic sensor is used to measure distance to an object that is within the sensors field of view. After spending far too long on this than i felt i needed to, i decided to. This module includes ultrasonic transmitter, receiver and control circuit.
This is a simple tutorial on interfacing ultrasonic sensor with nodemcu wifi module and measure distance. Sensor is initialized by creating instance of class ultrasonicdistancesensor and providing trigger and echo pins. This sensor uses ultrasonic sound to measure distance just like bats and dolphins do. Ultrasonic sensor module hcsr04 distance measuring sensor. In this project i will introduce you to the hcsr04 ultrasonic sensor. The hcsr04 sends a ping as a submarine does and measure the time between sending and receiving anything back when an object is in front of the sensor. Then we declare 2 floats, duration and distance, which will hold the length of the sound wave and how far away the object is. Ultrasonic module hcsr04 distance measuring transducer. The ultrasonic distance sensor module hcsr04 can measure distances from 2 centimeters up to 5 meters if youre lucky. Ultrasonicint tp, int ep this is a initial function for ultrasonic ranging module, choose the pins for module trig and echo pin. Compatible with the modules hcsr04, ping and seeed studio sensor. Using the hcsr04 ultrasonic distance sensor with arduino.
These are important factors to consider when designing and programming a robot using an ultrasonic sensor. Here we are giving an example for the hcsr04 ultrasonic sensor using the arduino board. It can be used in various applications such as positioning, locating, dimensioning, selecting, level measurement, controlling and profiling. The newping library written by tim eckel can be used with many ultrasonic distance sensors.
In this arduino tutorial we will learn how the hcsr04 ultrasonic sensor works. In this project we are going to interface ultrasonic sensor hcsr04 with arduino and lcd display. Each hcsr04 module includes an ultrasonic transmitter, a receiver and. The hcsr04 ultrasonic sensor is versatile device that has become a staple in robotics projects. Get objectdistance detection in your project using the lowcost hcsr04 ultrasonic distance module from elegoo. Like others ultrasonic sensor, hcsr04 uses sonar to determine distance to an object like bats or dolphins do. The hcsr04 ultrasonic module has 4 pins, ground, vcc, trig and echo. Details about ultrasonic module hcsr04 distance measuring transducer sensor for arduinoavr. The module includes ultrasonic transmitters, receiver, and. Arduino hcsr04 ultrasonic sensor and processing officialhrm. The ground and the vcc pins of the module needs to be connected to the ground and the 5 volts pins on the arduino board respectively and the trig and echo pins to any digital io pin on the arduino board. Other objects can absorb the sound wave all together cloth, carpeting, etc, which means that there is no way for the sensor to detect them accurately. Its a four pins module which can be used in several applications involving measuring the distance or in the detection of an obstacle.
Getting started with the hcsr04 ultrasonic sensor arduino create. Ultrasonic module hcsr04 distance transducer sensor for. This sensor require an digital output trig and input echo pin to use it. You can upload the following example code to your arduino using the arduino ide. Now that you have wired up the sensor it is time to connect the arduino to the computer and upload some code. Ultrasonic distance measurement project using arduino. Hcsr04 is an ultrasonic sensor that measures distances from 2 to 400cm.
This library is for the hcsr04 ultrasonic ranging module. Today in this tutorial we are going to learn how to. Hcsr04 datasheet ultrasonic proximity sensor custom. After buying a hcsr04 from amazon, i could not get it to work out of the box. Works with many different ultrasonic sensor models. It essentially gives your arduino eyes spacial awareness and can prevent your robot from crashing or falling off a table. Ultrasonic sensor which is used in the project is the most popular one among the diy circuit community, the hcsr04.
How to make an arduino door alarm using an ultrasonic sensor. Now that we have a complete understanding of how hcsr04 ultrasonic distance sensor works, we can begin hooking it up to our arduino. The hcsr04 uses sound instead of light as the gp2d12 module does. Ultrasonic sensor hcsr04 with arduino tutorial ultrasonic sensor hcsr04 is a sensor that can measure distance. How to build an object detector with arduino using an hcsr04 and an sg90 servo.
Details about ultrasonic sensor module hcsr04 distance measuring sensor for arduino sr04. Using arduino sensors car parking using ultrasonic module hcsr04 distance sensor for arduino. How to use a hcsr04 ultrasonic distance sensor with arduino. Not wanting to concede i had a doa sensor on my hands, i searched for a simple example setup.
It can measure the distance between the sensor and the object by the time from the sound wave of a specific frequency to the time when the sound wave is heard to bounce back. You could, for example, use it to check the water level in a tank or as a parking sensor in your garage. Open arduino ide software and write down your code, or download the. The hcsr04 is an ultrasonic distance sensor that can be paired alongside arduino and raspberry pi. New ultrasonic module hcsr04 distance transducer sensor. In this project we are going to use the hcsr04 ultrasonic ranging module with an arduino.
The actual distance can be calculated by dividing its value with 2 as the time will be twice once the waves travel and get back from the sensor. Use an hcsr04 ultrasonic sensor to give your robot the perception of distance. The hcsr04 ultrasonic sensor is a very affordable proximitydistance sensor that has been used mainly for object avoidance in various robotics projects. The ultrasonic sensor is used to measure the distance. Vcc is the power supply for hcsr04 ultrasonic distance sensor which we connect the 5v pin on the arduino trig trigger pin is used to trigger the ultrasonic sound pulses. It can measure distance from 2 cm to 4 meters with a ranging accuracy. Using the hcsr04 ultrasonic range sensor with an arduino. Arduino distance sensor using the hcsr04 pi my life up. An ultrasonic sensor based distance meter enables distance measuring of a target object without making any physical contact. It has a focus of less than 15 degrees and an accuracy of about 2mm. Work with ultrasound module in a simple and light way. Ultrasonic hcsr04 sensor which looks like the eyes of a robot is commonly known as the distance sensor. Hello, here we are using the hcsr04 ultrasonic module to measure distance, its a classic arduino project to learn how to use the board, this module can measure up to 5m its quiet accurate and easy to calibrate as we saw in the video, you can integrate it in your projects, especially robots to detect obstacles or measure distance too while moving. The hcsr04 ultrasonic distance sensor is a popular affordable sensor that provides 2cm 0.
The ultrasonic sensor is useful in obstacle avoidance and other systems that require distance as a variable. How to measure distance using ultrasonic sensor hcsr04. Projects, examples, source codes, download files and much more can be found here. Gowoops 5pcs hcsr04 ultrasonic module distance measuring. Smraza ultrasonic module hcsr04 distance sensor can measure the distance to an object by using echo. The modules includes ultrasonic transmitters, receiver and control circuit. In this tutorial we will connect and use the hcsr04 ultrasonic sensor with the uno to calculate distances. New ultrasonic module hcsr04 distance transducer sensor for arduino robot. This time, we launched the hcsr04 ultrasonic module user guide, and our technician also wrote hcsr04 demo for the widespread diy hobbyists to download. Complete guide for ultrasonic sensor hcsr04 with arduino this article is a guide about the popular ultrasonic sensor hc sr04. This popular ultrasonic distance sensor provides stable and accurate distance measurements from 2cm to 450cm. The hcsr04 ultrasonic sensor uses sonar to determine distance to an object like bats or dolphins do.
A demonstration of how to use the hcsr04 ultrasonic sensor with lcd and arduino in order to measure the distance of an object. The hcsr04 is a readily available, cheap, and easy to use ultrasonic proximity sensor module that can be used for a wide variety of projects. This library allows an arduino board to use multiple hcsr04 sensors for get current distance in cm. Ultrasonic sensor hcsr04 with arduino tutorial arduino. Feb 2, 2018 hc sr04 ultrasonic sensor is arduino ultrasonic distance measurement sensor. Library for ultrasonic ranging module hcsr04 arduino. Using the hcsr04 ultrasonic distance sensor with arduino one of the most useful sensors for robotics projects is a distance sensor. Distance meter using arduino uno and hc sr04 ultrasonic sensor. Using the same principle as bats echo location, this module uses trigger and echo pin to send a signal and listen for it to be bounced back. Arduino library for hcsr04 ultrasonic distance sensor. Hcsr04 ultrasonic sensor arduino tutorial 5 examples.
Example using the ultrasonic sensor hcsr04 read distance from the serial monitor. Minimalist library for ultrasound module to arduino. Interface with hcsr04 ultrasonic sensors connected to arduino hardware in matlab. The length of the pulse is proportional to the time it took for the transmitted signal to be detected. Hcsr04 arduino nano ultrasonic sensor and processing code download arduino code and processing code. Ultrasonic distance measurement is a useful tool in various applications lately. Hcsr04 ultrasonic module can offer noncontact distance whose range sensing is up to 2mm function with the range of 2cm 400cm. Complete guide for ultrasonic sensor hcsr04 with arduino. The hcsr04 is an ultrasonic distance measuring module, commonly used for object avoidance, navigation and altitude hold purposes. Distance sensor mysensors create your own connected. Its application could be as liquid level sensor, tank level sensor, oil. It offers excellent noncontact range detection with high accuracy and stable readings in an easytouse package.
1533 1511 603 89 1151 804 955 1122 983 1194 867 1157 289 113 643 685 1125 1107 251 38 24 733 529 175 1034 720 1336 674 509 1148 1088 792 722 1550 84 863 133 26 1386 172 772 1335