Arduino and ultrasound distance sensor

I bought some time ago HC-SR04 Ultrasonic Sensor Distance Measuring Module to play with ultrasound distance measurements with Arduino Duemilanove 2009 Atmega 328P SCM Board.

ultrasound1s

The working principle of the HC-SR04 Ultrasonic Sensor Distance Measuring Module when the module get trigger “start” pulse, it sends eight 40khz square wave pulses and automatically detect whether receive the returning pulse signal. If there is signals returning, through outputting high level and the time of high level continuing is the time of that from the ultrasonic transmitting to receiving. So the pulse length tells the time of flight from sensor to measured distance and back. The HC-SR04 Ultrasonic Sensor Distance Measuring Module was wired to Arduino board with Male to Female DuPont Breadboard Jumper Wires (pretty useful accessory for prototyping with Arduino).

ultrasound2s

Arduino programming environment contains Ping example made for an ultrasonic range finder from Parallax. It detects the distance of the closest object in front of the sensor (from 2 cm up to 3m). It works by sending out a burst of ultrasound and listening for the echo when it bounces off of an object. The Arduino board sends a short pulse to trigger the detection, then listens for a pulse on the same pin using the pulseIn() function. The duration of this second pulse is equal to the time taken by the ultrasound to travel to the object and back to the sensor. Using the speed of sound, this time can be converted to distance.

The HC-SR04 Ultrasonic Sensor Distance Measuring Module has a little bit different interface, because it had separate pins for trigger and echo. This means that I needed to modify the example source code (was not too hard).

Here is my modified code (over 90% based on Ping example that comes with Arduino IDE 1.0.5):

/* Ping))) Sensor

This sketch reads a PING))) ultrasonic rangefinder and returns the
distance to the closest object in range. To do this, it sends a pulse
to the sensor to initiate a reading, then listens for a pulse
to return. The length of the returning pulse is proportional to
the distance of the object from the sensor.

The circuit:
* +V connection of the PING))) attached to +5V
* GND connection of the PING))) attached to ground
* Trigger connection of the PING))) attached to digital pin 7
* Echo connection of the PING))) attached to digital pin 8

http://www.arduino.cc/en/Tutorial/Ping

created 3 Nov 2008
by David A. Mellis
modified 30 Aug 2011
by Tom Igoe
by Tomi Engdahl

This example code is in the public domain.

*/

// this constant won't change. It's the pin number
// of the sensor's output:
const int pingTrigPin = 7;
const int pingEchoPin = 8;

void setup() {
// initialize serial communication:
Serial.begin(9600);
}

void loop()
{
// establish variables for duration of the ping,
// and the distance result in inches and centimeters:
long duration, inches, cm;

// The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
pinMode(pingTrigPin, OUTPUT);
digitalWrite(pingTrigPin, LOW);
delayMicroseconds(2);
digitalWrite(pingTrigPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingTrigPin, LOW);

// The same pin is used to read the signal from the PING))): a HIGH
// pulse whose duration is the time (in microseconds) from the sending
// of the ping to the reception of its echo off of an object.
pinMode(pingEchoPin, INPUT);
duration = pulseIn(pingEchoPin, HIGH);

// convert the time into a distance
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);

Serial.print(inches);
// Serial.print("in, ");
Serial.print(", ");
Serial.print(cm);
// Serial.print("cm");
Serial.println();

delay(100);
}

long microsecondsToInches(long microseconds)
{
// According to Parallax's datasheet for the PING))), there are
// 73.746 microseconds per inch (i.e. sound travels at 1130 feet per
// second). This gives the distance travelled by the ping, outbound
// and return, so we divide by 2 to get the distance of the obstacle.
// See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf
return microseconds / 74 / 2;
}

long microsecondsToCentimeters(long microseconds)
{
// The speed of sound is 340 m/s or 29 microseconds per centimeter.
// The ping travels out and back, so to find the distance of the
// object we take half of the distance travelled.
return microseconds / 29 / 2;
}

This code outputs lines with two numbers (inches and centimeters) separated by comma. The communications speed is 9600 bps. Everything worked well with TeraTerm. The output was two numbers per line separated with comma outputted at 9600 baud rare. The numbers tell the distance in inches and centimeters.

Now time to try to get some graphs. This could be down in many ways, for example using Processing like in Graph example, Realtime Plot of Arduino Serial Data Using Python, Graphing with Excel or use application specifically made for this like SerialChart.

SerialChart is an open source application for charting data sent via RS-232 port in real time. I had used the software earlier successfully, read the documentation and checked SerialChart Tutorial, but for some reason I could not get data from Arduino that was mapped to COM11. I finally found that I had the same issue issue that was mentioned at Serial chart says that the com port is busy when its not page:

This a problem that comes from the qt serial library. So I will not be fixing that but as a workaround I want to let you know that you’re not stuck with high-numbered ports that Windows assigns , you can change them to something lower than 10, for example COM7 , COM5

I configured Arduino USB serial port number to COM2 and now SerialChart worked well.

SerialChart configuration I used:

[_setup_]
port=COM2
baudrate=9600

width=1000
height=201
background_color = white

grid_h_origin = 100
grid_h_step = 10
grid_h_color = #EEE
grid_h_origin_color = #CCC

grid_v_origin = 0
grid_v_step = 10
grid_v_color = #EEE
grid_v_origin_color = transparent

[_default_]
min=-1
max=1

[Field1]
color=gray
min=0
max=255

[Field2]
color=red
min=0
max=255

Here is the output I got with SerialChart program:

serialchart_scaled

Now I can visually see what the sensor senses and also see the numeric values.

73 Comments

  1. fastest way to get pregnant says:

    I pay a quick visit each day a few sites and information sites to read posts, but this web site offers feature based writing.

    Reply
  2. Tomi Engdahl says:

    Ultrasonic shoe sensors help the visually impaired
    http://www.edn.com/electronics-blogs/sensor-ee-perception/4422512/Ultrasonic-shoe-sensors-help-the-visually-impaired

    Denver Dias, as part of his undergraduate studies, set out to create a new interface to help with environmental awareness for those who cannot see.

    His concept was to move the obstacle detection out of the hands of the person. He is accomplishing this by mounting an array of ultrasonic sensors around some tennis shoes. The concept behind this prototype is that any obstacle will be detected and a physical notice will be given to the wearer in real time.

    Reply
  3. Cleo Pizzella says:

    Have read a number of using the articles in your site today, and I really like your style of running a blog.

    Reply
  4. Halloween hacking ideas « Tomi Engdahl’s ePanorama blog says:

    [...] Here is one really scary looking lantern. Fire Breathing Jack-O-Lantern of Death page tells about a very dangerous Halloween effect hack. This isn’t a new idea but it is a very unique and simple implementation based on re-purposing existing commercial products controlled with Arduino + ultrasound distance sensor. [...]

    Reply
  5. Tomi Engdahl says:

    Home Heating Hacking Part 1 or How to Measure an Oil Tank
    http://alaskanshade.blogspot.ch/2013/12/home-heating-hacking-part-1-or-how-to.html

    Unless I go out to the tank regularly and check it with a dipstick, I have no idea how fast or slow we are using up the tank.

    There is really only one product already on the market that is similar to what I want: The Rocket. It is $120, only reads in 10% increments and just displays on the receiver. Without hacking the wireless protocol that is being used, there is no way to do automatic data logging and a 60 gallon granularity is not optimal for the analysis I want to be able to do.

    Ultrasonic sensors – there are a lot of different ultrasonic sensors. There are expensive industrial models and cheap ones that are often used in hobby robotics. After looking at several different sensors, I picked up a Maxbotix EZ4 (more on these later).

    I started out with the EZ4 sensor mentioned above. This sensor is versatile and simple to use. It has circuitry onboard that does most of the work and communicates the results as an analog voltage, PWM or RS232 signal. The down side of this sensor is that it only offers 1-inch resolution which is about 15 gallons in the middle of the tank, but something that works is better than nothing and I can swap it out later.

    Reply
  6. Tomi Engdahl says:

    Good Vibrations: Giving the HC-SR04 a Brain Transplant
    http://hackaday.com/2014/03/17/good-vibrations-giving-the-hc-sr04-a-brain-transplant/

    [Emil] got his hands on a dozen HC-SR04 ultrasonic sensors, but wasn’t too happy with their performance. Rather than give up, he reverse engineered the sensor and built an improved version.

    [Emil] reverse engineered the schematic of the HC-SR04 and found some interesting design decisions.

    A mask programmed microcontroller manages the entire unit, commanding the ultrasonic transmitter to send 40Khz pulses, and listening for returns on the receive side of the system.

    [Emil] solved these problems by creating his own PCB with an ATtiny24 and a 12MHz crystal

    Making a better HC-SR04 Echo Locator
    http://uglyduck.ath.cx/ep/archive/2014/01/Making_a_better_HC_SR04_Echo_Locator.html

    Reply
  7. ajin says:

    dear friends,
    can i detect an object at a particular distance, means i want an output high when 5 cm distance is reached, what changes have to made in this program please help me.

    Reply
    • Tomi Engdahl says:

      You just need to write a suitable Arduino software to detect the distance you want.
      Use Arduino to measure the distance, and then compare the result to your reference distance that that should be reached.
      When the distance is reached do whatever needs to be done (for example turn output pin on/off, send message to PC etc..)

      Reply
  8. Johnd194 says:

    Really wonderful information can be found on web blog.

    Reply
  9. Tomi Engdahl says:

    A Virtual Touchscreen (3D Ultrasonic Radar)
    http://hackaday.com/2014/08/24/a-virtual-touchscreen-3d-ultrasonic-radar/

    Producing items onto a screen simply by touching the air is a marvelous thing. One way to accomplish this involves four HC-SR04 ultrasonic sensor units that transmit data through an Arduino into a Linux computer. The end result is a virtual touchscreen that can made at home.

    Reply
  10. Tomi Engdahl says:

    Tiny Robot Shakes Head At You In Dissaproval
    http://hackaday.com/2015/08/15/tiny-robot-shakes-head-at-you-in-dissaproval/

    If you don’t have enough things staring at you and shaking their head in frustration, [Sheerforce] has a neat project for you. It’s a small Arduino-powered robot that uses an ultrasonic distance finder to keep pointing towards the closest thing it can find. Generally, that would be you.

    When it finds something, it tries to track it by constantly rotating the distance finder slightly and retesting the distance, giving the impression of constantly shaking its head at you in disappointment.

    you should read [Sheerforce]’s code first: it’s a great example of documenting this for experimenters who want to build something

    Tiny Robot Shakes Head At You In Dissaproval
    http://www.instructables.com/id/Its-Alive-A-little-robot-that-follows-you-with-its/

    Reply
  11. Tomi Engdahl says:

    Garage Parking Sensor
    Ultrasonic parking sensor for garage mounting
    https://hackaday.io/project/3922-garage-parking-sensor

    This gadget is ment as an alternative to the tennis-ball-meets-bumper type of parking aids.

    Reply
  12. Tomi Engdahl says:

    HC-SR04 Isn’t the Same as Parallax PING))) But It Can Pretend to Be!
    http://hackaday.com/2015/09/22/hc-sr04-isnt-the-same-as-parallax-ping-but-it-can-pretend-to-be/

    “It’s only software!” A sentence that strikes terror in the heart of an embedded systems software developer. That sentence is often uttered when the software person finds a bug in the hardware and others assume it’s going to be easier for fix in software rather than spin a new hardware revision. No wonder software is always late.

    He wanted to use the less expensive HC-SR04 ultrasonic rangefinder in a prototype. Longer term he wanted to have the choice of either a Parallax PING or MaxBotix ultrasonic sensor for their better performance outdoors. His hardware hack of the SR04 made this a software problem which he also managed to solve!

    [Clint] was working with the Arduino library, based on the Parallax PING, which uses a single pin for trigger and echo. The HC-SR04 uses separate pins.

    modified the HC-SR04 sensor

    HC-SR04 Ping Sensor Hardware Mod
    http://www.cascologix.com/blog/hc-sr04-ping-sensor-hardware-mod

    If you intend to do your prototyping with the HC-SR04 module, you may find yourself having to write slightly customized code to drive the HC-SR04, which has one more pin compared to the Parallax ping sensor. This is because the HC-SR04 has separate pins for the trigger and echo function, where the Parallax module combines this functionality into one pin. For example, the Arduino “ping” example sensor sketch was written for the Parallax ping sensor and will not work “out-of-the-box” with the HC-SR04 as it only has provisions in the code for one signal pin.

    Well, there is a hardware hack you can perform on the HC-SR04 that will make if function virtually identical to the Parallax ping sensor. Simply connect a 10k ohm resistor across the ‘Trig’ and ‘Echo’ pin and remove the 10k pullup on the HC-SR04 attached to the ‘Trig’ pin

    This modification allows the ‘Echo’ pin to drive both the HC-SR04 ‘Trig’ pin and the Arduino ‘pingPin’ when it is in a high-impedance input mode during echo receive. Conversely it also allows the Arduino ‘pingPin’ to drive the HC-SR04 ‘Trig’ pin in output mode when triggering a pin

    Reply
  13. Tomi Engdahl says:

    Bootstrapping Motion Input with Cheap Components
    http://hackaday.com/2015/10/07/bootstrapping-motion-input-with-cheap-components/

    Let’s get one thing straight: This device isn’t going to perform like a Leap controller. Sure the idea is the same. Wave your hands and control your PC. However, the Leap is a pretty sophisticated device and we are going to use a SONAR (or is it really SODAR?) device that costs a couple of bucks. On the plus side, it is very customizable, requires absolutely no software on the computer side, and is a good example of using SONAR and sending keyboard commands from an Arduino Leonardo to a PC. Along the way, I had to deal with the low quality of the sensor data and figure out how to extend the Arduino to send keys it doesn’t know about by default.

    Reply
  14. Tomi Engdahl says:

    SRF01 Ultrasonic Sensor Teardown
    http://hackaday.com/2015/11/28/srf01-ultrasonic-sensor-teardown/

    The SRF01 is a popular ultrasonic sensor used primarily for range finding applications. [Jaanus] discovered that they had a few flaws, including not working after being dropped. The faulty ones began to pile up, so he decided sensor_01to tear one apart and put his engineering skills to use.

    The SRF01 is unique in that it only uses a single transducer, unlike the SRF04, which uses two. Using only one transducer presents a problem when measuring very close distances.

    SRF01 teardown and reverse engineering
    http://jaanus.tech-thing.org/teardowns-and-reviews/srf01-teardown/

    I needed small ultrasonic sensors for a flying sensor. So I got the smallest one – SRF01. Quite nice unit, works down to 0 cm. There were some problems with it – Maximum detection frequency is only ~14 Hz and the resolution isn’t so great (1 cm).

    From component side: It has JST ZH series 3 pin connector for communication and power. Since the working voltage is 3.3 – 12 V it uses LP2980 3.3V voltage regulator to power all the components. The transducer used is 400PT from china/Multicomp. Received signal is amplified by MAX4232AKA dual 10MHz op-amp. Then it is fed to PIC24FJ16GA002 ADC.

    Reply
  15. Tomi Engdahl says:

    El Cheapo Phased-Array Sonar
    http://hackaday.com/2015/12/04/el-cheapo-phased-array-sonar/

    Sonar is a great sensor to add to any small-scale robot project. And for a couple bucks, the ubiquitous HC-SR04 modules make it easy to do. If you’ve ever used these simple sonar units, though, you’ve doubtless noticed that you get back one piece of information only — the range to the closest object that the speaker is pointing at. It doesn’t have to be that way. [Graham Chow] built a simple phased-array using two SR04 modules, and it looks like he’s getting decent results.

    The hack starts out by pulling off the microcontroller and driving the board directly, a hack inspired by [Emil]’s work on reverse engineering the SR04s. Once [Graham] can control the sonar pings and read the results back, the fun begins.

    Spread Spectrum Phased Array Sonar
    https://www.hackster.io/graham_chow/spread-spectrum-phased-array-sonar-018e22

    Hacking two cheap HC-SR04 ultrasonic distance sensors and a launchpad to create a spread spectrum phased array Sonar.

    Reply
  16. Tomi Engdahl says:

    Hacklet 91: Ultrasonic Projects
    http://hackaday.com/2016/01/16/hacklet-91-ultrasonic-projects/

    Ultrasound refers to any audio signal above the range of human hearing. Generally that’s accepted as 20 kHz and up. Unlike electromagnetic signals, ultrasonics are still operating in a medium – generally the air around us. Plenty of animals take advantage of ultrasonics every day. So do hackers, makers, and engineers who have built thousands of projects based upon these high frequency signals. This weeks Hacklet is all about the best ultrasonic projects on Hackaday.io!

    Reply
  17. Tomi Engdahl says:

    Arduino Radar
    https://www.eeweb.com/project/arduino-radar/

    The project is very simple using only an ultrasonic sensor for detecting an object, a small servo motor used for rotating the sensor, an arduino board, and an algorithm for controlling the devices.

    Arduino Radar Project
    https://www.youtube.com/watch?v=kQRYIH2HwfY
    http://howtomechatronics.com/projects/arduino-radar-project/

    Reply
  18. Tomi Engdahl says:

    Octosonar is 8X Better than Monosonar
    http://hackaday.com/2017/02/25/octosonar-is-8x-better-than-monosonar/

    The HC-SR04 sonar modules are available for a mere pittance and, with some coaxing, can do a pretty decent job of helping your robot measure the distance to the nearest wall. But when sellers on eBay are shipping these things in ten-packs, why would you stop at mounting just one or two on your ‘bot? Octosonar is a hardware and Arduino software library that’ll get you up and running with up to eight sonar sensors in short order.

    HC-SR04 I2C Octopus “octosonar”
    https://hackaday.io/project/19950/instructions

    The minimum setup to use this usefully requires

    a PCF8574 or PCF8574A IC
    two HC-SR04 sensors
    two NPN transistors and some resistors to make a NOR gate
    example sketch SonarI2Cv2

    Reply
  19. Tomi Engdahl says:

    HC-SR04 I2C Octopus “octosonar”
    https://hackaday.io/project/19950-hc-sr04-i2c-octopus-octosonar
    Connect 8 ultrasonic range sensors to an Arduino with I2C bus and one pin

    Reply
  20. Tomi Engdahl says:

    #40 Ultrasonic Distance Sensors Arduino Tutorial and Comparison for HC-SR04, HY-SRF05, US-015
    https://www.youtube.com/watch?v=aLkkAsrSibo

    In this video I test three ultrasonic sensors for distance accuracy and opening angle. I also show how to use them in one pin and two pin configurations and I introduce a three sensor set-up for autonomous robots.

    Reply
  21. Tomi Engdahl says:

    Measuring Air Flow with Ultrasonic Sensors
    http://hackaday.com/2017/07/26/measuring-air-flow-with-ultrasonic-sensors/

    Measuring air flow in an HVAC duct can be a tricky business. Paddle wheel and turbine flow meters introduce not only resistance but maintenance issue due to accumulated dust and debris. Being able to measure ducted airflow cheaply and non-intrusively, like with this ultrasonic flow meter, could be a big deal for DIY projects and the trades in general.

    The principle behind the sensor [ItMightBeWorse] is working on is nothing new. He discovered a paper from 2015 that describes the method that measures the change in time-of-flight of an ultrasonic pulse across a moving stream of air in a duct

    [ItMightBeWorse] is using readily available HC-SR04 sensor boards and has already done a proof-of-concept build.

    Building homemade ultrasonic air flow measurement device.
    https://www.youtube.com/watch?v=BNTSSxzm1GM

    Reply
  22. Tomi Engdahl says:

    SonicScape (Binaural Vision Glasses for the Blind)
    https://hackaday.io/project/20899-sonicscape-binaural-vision-glasses-for-the-blind

    Wearable vision technology for the visually impaired using ultrasonic sensors and a binaural soundscape environment

    The urban environment is a very difficult place to navigate and orientate yourself through, especially if you are a visually impaired person trying to live your life. That is why I have tried to come up with a technological solution that will help blind people know of their surrounding obstacles in an unknown environment without the help of a walking stick or a guide dog. Further from having a basic Arduino integrated system through the help of a pair of ultrasonic sensors (HC-SR-04) connected through bluetooth (HC-05, HC-06) , I want to also add some sort of GPS or RFID mapping system to the portable device which will allow the blind user to track themselves of where they are currently through a voice-activated agent. It will allow for family or relatives of the blind user to also track them of where they are through an app on their smartphone. That is what I am trying to achieve by the end of this project.

    Reply
  23. Tomi Engdahl says:

    #40 Ultrasonic Distance Sensors Arduino Tutorial and Comparison for HC-SR04, HY-SRF05, US-015
    https://www.youtube.com/watch?v=aLkkAsrSibo

    In this video I test three ultrasonic sensors for distance accuracy and opening angle. I also show how to use them in one pin and two pin configurations and I introduce a three sensor set-up for autonomous robots. I use an Arduino Leonardo to transfer the results to Excel.

    #9 Arduino Data Logger with Direct Input to Excel
    https://www.youtube.com/watch?v=AgJegJ30Pj4&feature=youtu.be

    Reply
  24. Tomi Engdahl says:

    How about replacing ultrasound with Laser?

    Shooting laser to measure distance
    https://www.youtube.com/watch?v=7dJKJUmfQ1A

    I show you how to measure distance with this laser distance sensor. With the help of the Adafruit library is this I2C sensor an easy-to-use item.
    It’s emitting a laser beam of 940nm and is also known as Time-of-flight sensor
    Project page:
    https://rohling-de.blogspot.fi/2017/04/shooting-laser-to-measure-distance.html

    Reply
  25. Tomi Engdahl says:

    SonicDisc: A 360° Ultrasonic Scanner
    https://www.hackster.io/platisd/sonicdisc-a-360-ultrasonic-scanner-211e6a?ref=explore&ref_id=recent___&offset=0

    Who said autonomous driving was only for the premium car manufacturers? SonicDisc enables you to autonomously park like a pro for $10.

    Reply
  26. Tomi Engdahl says:

    Hackaday Prize Entry: Sonic Glasses
    http://hackaday.com/2017/08/28/hackaday-prize-entry-sonic-glasses/

    For his entry into the Assistive Technology part of the Prize, [Pawit] is building binaural glasses for the blind. It’s difficult to navigate unknown environments without a sense of sight, and these SonicScape glasses turn cheap distance sensors into head-mounted sonar.

    The glasses are built around a pair of ultrasonic distance sensors (the HC-SR-04, if you’re curious), mounted in a convenient 3D-printed enclosure that looks sufficiently like a pair of glasses to not draw too many glares.

    SonicScape (Binaural Sensor Glasses for the Blind)
    https://hackaday.io/project/20899-sonicscape-binaural-sensor-glasses-for-the-blind

    Obstacle detection glasses for the visually impaired using ultrasonic sensors and a binaural soundscape environment

    Reply
  27. Abhay Kalmegh says:

    Thanks for sharing..can you please tell me how to connect hcsr-04 with raspberry pi b+ modal.

    Reply
  28. Tomi Engdahl says:

    Ultrasonic Array Gets Range Data Fast and Cheap
    https://hackaday.com/2017/08/30/ultrasonic-array-gets-range-data-fast-and-cheap/

    How’s your parallel parking? It’s a scenario that many drivers dread to the point of avoidance. But this 360° ultrasonic sensor will put even the most skilled driver to shame, at least those who pilot tiny remote-controlled cars.

    SonicDisc: A 360° ultrasonic scanner
    https://platis.solutions/blog/2017/08/27/sonicdisc-360-ultrasonic-scanner/

    For some years now, I have been on a never-ending quest to discover the cheapest way for a miniature vehicle to position itself. One that performs decently that is. My latest idea involved the, less-than-a-dollar, HC-SR04 ultrasonic sensors to acquire a holistic view of the surroundings. But let’s take it from the beginning…

    The way I used the HC-SR04 ultrasonic sensors thus far was by triggering each to transmit an ultrasonic pulse, wait for it to reflect on an object and then determine how far away the object stood by the time it took for the “echo” to return. The problem with this lies in sequentially waiting for each measurement.

    Empirically, I know it takes more or less 10 milliseconds for each measurement to complete for ranges under 1.5 meters, common for miniature car applications.

    The solution was to execute the measurements in parallel. I checked out an article about using the HC-SR04 sensors with interrupts which verified the feasibility of the concept.

    Long story short, instead of waiting for each sensor to finish measuring, we initially trigger all sensors at once and then utilize the pin change interrupts to log down the echo arrival times. Finally, at a predefined interval we calculate the distance for each sensor. If an echo has not arrived yet, we consider the measurement as erroneous. The said interval is 10 milliseconds at the moment. This means we are able to conduct eight measurements in the time it took for a single one to be completed!

    SonicDisc is designed to transmit the calculated distances to another unit, e.g. a microcontroller or a Raspberry Pi. It “talks” over the widely-adopted I2C bus.

    Reply
  29. Tomi Engdahl says:

    Ping#
    Beam-formed ultrasonic distance sensor
    https://hackaday.io/project/27089-ping

    Found a handful of the ubiquitous HC-SR04 ultrasonic sensors for cheap. Trying to teach them a new trick with beam forming for fast scanning and for a narrower beam width.

    Idealy the spacing between the elements would be less than a wavelength and preferably 1/4 wavelength. With the wavelength being aprox 14mm it makes it very difficult to pack the ultrasonic cans close enough. The last array had relatively large spacing. A redesign packed the sensors as close as possible.

    This array is still too limited to form arbitary beams. In combination with the already narrow beamwidth of the transducers, the side loves of the beam pattern formed by the array is suppressed. It might be possible to perform the scanning within a 30° range.

    Reply
  30. Tomi Engdahl says:

    Listening for Hand Gestures
    https://hackaday.com/2017/11/01/listening-for-hand-gestures/

    [B. Aswinth Raj] wanted to control a VLC player with hand gestures. He turned to two common ultrasonic sensors and Python to do the job. There is also, of course, an Arduino. You can see a video of the results, below.

    Control your Computer with Hand Gestures using Arduino
    https://circuitdigest.com/microcontroller-projects/control-your-computer-with-hand-gestures

    Recently Gesture controlled Laptops or computers are getting very famous. This technique is called Leap motion which enables us to control certain functions on our computer/Laptop by simply waving our hand in front of it. It is very cool and fun to do it, but these laptops are really priced very high. So in this project let us try building our own Gesture control Laptop/Computer by combining the Power of Arduino and Python.

    We will use two Ultrasonic sensors to determine the position of our hand and control a media player (VLC) based on the position. I have used this for demonstration, but once you have understood the project, you can do anything by just changing few lines of code and control your favorite application in your favorite way.

    The Arduino should be programmed to read the distance of hand from the US sensor. The complete program is given

    By reading the value of distance we can arrive at certain actions to be controlled with gestures, for example in this program I have programmed 5 actions as a demo.

    Action 1: When both the hands are placed up before the sensor at a particular far distance then the video in VLC player should Play/Pause.

    Action 2: When right hand is placed up before the sensor at a particular far distance then the video should Fast Forward one step.

    Action 3: When left hand is placed up before the sensor at a particular far distance then the video should Rewind one step.

    Action 4: When right hand is placed up before the sensor at a particular near distance and then if moved towards the sensor the video should fast forward and if moved away the video should Rewind.

    Action 5: When left hand is placed up before the sensor at a particular near distance and then if moved towards the sensor the volume of video should increase and if moved away the volume should Decrease.

    Reply
  31. Tomi Engdahl says:

    Measuring Airflow in an HVAC System
    https://hackaday.com/2017/11/04/measuring-airflow-in-an-hvac-system/

    [Nubmian] wrote in to share his experiments with measuring airflow in an HVAC system. His first video deals with using with ultrasonic sensors. He found an interesting white paper that described measuring airflow with a single-path acoustic transit time flow meter. The question was, could he get the same effects with off-the-shelf components?

    [Nubmian] created a rig using a pair of typical ultrasonic distance sensors. He detached the two transducers from the front of the PCB. The transducers were then extended on wires, with the “send” capsules together pointing at the “receive” capsules. [Nubmian] set the transducers up in a PVC pipe and blew air into it with a fan.

    https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4481905/

    Reply
  32. Tomi Engdahl says:

    HC-SR04 I2C Octopus “octosonar”
    Connect up to 16 ultrasonic range sensors to an Arduino with I2C bus and one pin
    https://hackaday.io/project/19950-hc-sr04-i2c-octopus-octosonar

    Reply
  33. Tomi Engdahl says:

    Ultrasonic Sensors Measure Up in Home-Automation Applications
    http://www.electronicdesign.com/embedded-revolution/ultrasonic-sensors-measure-home-automation-applications?NL=ED-003&Issue=ED-003_20171213_ED-003_230&sfvc4enews=42&cl=article_1_b&utm_rid=CPG05000002750211&utm_campaign=14538&utm_medium=email&elq2=e82d28c81b384cdba1ae0ccd00bf4808

    Sponsored by Texas Instruments: Long used in sonar and more recently automotive systems, this venerable technology lives on in modern products for the home.

    Ultrasonics or ultrasound is a radar-like system that uses ultrasonic signals at frequencies above those typical for human hearing, usually above 16 to 20 kHz. The 40- to 70-kHz range tends to be most popular. Its main application is object detection and distance measurement.

    Ultrasonic sensors are already widely used in automotive applications and a variety of industrial applications. Now, though, new potential applications are being discovered in the home-automation market.

    Ultrasonic object detectors work like radar. A transceiver consisting of a transmitter transducer radiates a signal toward a target. That target reflects or echoes the signal back to the transducer receiver at the source (Fig. 1). These transducers are usually of the piezoelectric type, with 58 kHz being a common signal frequency.

    Ultrasonic Applications

    The concept of ultrasonics has been around for many decades, as is the case with the U.S. Navy’s sonar systems. Early TV set remotes exploited ultrasonic tones to change channels and volume. And ultrasonic sensors have been used in distance-measuring applications. Other common uses today include:

    Object detection and ranging in automated robots (e.g., self-guiding vacuum cleaner)
    Liquid-level measurement in tanks
    Parking assist in cars
    Blind-spot detection in cars in side rear-view mirror assemblies
    Kick-to-open tailgates on SUVs
    Liquid-flow metering

    Also known as a Smart Trunk Opener (STO), this system has grown significantly over recent years, especially in SUVs and high-end passenger vehicles.

    Reply
  34. Tomi Engdahl says:

    Core Independent Ultrasonic Range Detection
    https://www.eeweb.com/profile/microchip/articles/core-independent-ultrasonic-range-detection

    Learn to send and receive Ultrasonic pulses using a CPU/Core Independent approach that decreases accuracy while increasing range.

    Reply
  35. Tomi Engdahl says:

    Ultrasonic Smart Instrument
    http://www.instructables.com/id/Ultrasonic-Smart-Instrument/

    This is an instrument that uses a Ultrasonic sensor to measure the distance of an object (this could be your hand). With this a note is selected to play, in different modes the instrument plays different things. This could be a single note (for using the instrument as a bass) or multiple notes in sequence (for use as a synthesizer).

    Reply
  36. Tomi Engdahl says:

    MEMS ultrasonic time-of-flight innovation: sensors advance user experiences
    https://www.edn.com/electronics-products/electronic-product-reviews/other/4459187/MEMS-ultrasonic-time-of-flight-innovation–sensors-advance-user-experiences?utm_source=Aspencore&utm_medium=EDN&utm_campaign=social

    Chirp claims the CH-101 and CH-201 are the first commercially available MEMS-based ultrasonic ToF sensors. One main function of both of these first two devices is having both the transmitter and the receiver in a single device.

    These devices are in a 3.5×3.5 mm LGA package, and combine a MEMS ultrasonic transducer with a custom low-power CMOS SoC that handles all ultrasonic signal-processing functions. Similar to a MEMS microphone in size, the CH-101 and CH-201 operate on a single 1.8V supply, plus have an I2C interface. The sensor’s on-board microprocessor enables always-on operation for wake-up sensing applications.

    Reply
  37. Tomi Engdahl says:

    UltrasonicEyes © GPL3+
    https://create.arduino.cc/projecthub/unexpectedmaker/ultrasoniceyes-b9fd38?ref=user&ref_id=328294&offset=0

    UltrasonicEyes is a fun and quirky project you can place somewhere and watch as it looks at things moving around in front of it. Freaky!

    So I created what I call UltrasonicEyes – a fun project that you sit somewhere near where people move around and it will look around at where people are, and blink and well, just weird you out in a fun and creepy way!

    Reply
  38. Tomi Engdahl says:

    Dead Simple Ultrasonic Data Communication
    https://hackaday.com/2018/06/01/dead-simple-ultrasonic-data-communication/

    In the video after the break, [Eduardo] demonstrates his extremely simple setup for using ultrasonic transducers for one-way data communication. Powered by a pair of Arduinos and using transducers salvaged from the extremely popular HC-SR04 module

    HACK AN ULTRASONIC HC-SR04 AND MAKE IT TALK EACH OTHER
    http://www.zolalab.com.br/eletronica_projetos/ultrasonic_talk.php

    Reply
  39. Tomi Engdahl says:

    Ultrasonic Data Transmission With GNU Radio
    https://hackaday.com/2013/12/10/ultrasonic-data-transmission-with-gnu-radio/

    When we hear GNU Radio was used in a build, the first thing we think of is, obviously, radio. Whether it’s a using extremely expensive gear or just a USB TV tuner dongle, GNU Radio is the perfect tool for just about everything in the tail end of the electromagnetic spectrum.

    There’s no reason GNU Radio can’t be used with other mediums, though, as [Chris] shows us with his ultrasound data transmission between two laptops.

    Ultrasound data transmission via a laptop
    https://www.anfractuosity.com/projects/ultrasound-via-a-laptop/

    Reply
  40. Tomi Engdahl says:

    Dual ultrasonic sensors combine for 2D echolocation
    https://blog.arduino.cc/2018/07/13/dual-ultrasonic-sensors-combine-for-2d-echolocation/

    Ultrasonic sensors are great tools for measuring linear distance or object presence. As shown in this experiment by “lingib,” two sensors can also be combined to determine not just linear distance to a sensor, but its position in an X/Y plane.

    For his experiment, he hooked two of these units up to an Arduino Uno at a known distance from each other, with one emitter blanked out with masking tape. The non-blanked emitter pulses an ultrasonic signal, which is bounced back to it as well as the second sensor by the measured object. From the time it takes to receive the return signal, distance to each sensor can be inferred, giving a triangle with each side known. Trigonometry is then used to pinpoint the item’s position, and a Processing sketch displays coordinates on lingib’s computer.

    Reply
  41. Tomi Engdahl says:

    Measuring Distance with Sound © CC BY
    https://create.arduino.cc/projecthub/ioarvanit/measuring-distance-with-sound-353c17

    Using ultrasonic sensors to measure distance of obstacles, taking into account temperature and humidity that affect the speed of sound.

    Reply
  42. Tomi Engdahl says:

    Slow sound radar
    https://hackaday.io/project/5944-slow-sound-radar

    How to slow up the sound in the air and get 2D sound image, to help visually impaired persons in navigation

    Reply
  43. Tomi Engdahl says:

    Fun and Creative Way to Demo the HC-SR04
    https://create.arduino.cc/projecthub/minion4evr/fun-and-creative-way-to-demo-the-hc-sr04-a8e67e?fbclid=IwAR1FzoA2J1zArrgvFkmfNRNvi-GT0nYngZUBdGwLra6cwprEIkeJT0fHtX0

    With a Windows tablet, Arduino, and HC-SR04, you can create a graphical caliper to show the distance.

    Reply
  44. Tomi Engdahl says:

    #103 HC-SR04 Ultrasonic Obstacle Avoidance and Range Finder (fun!)
    https://www.youtube.com/watch?v=bAMVzUmEcGY

    My 2WD (two-wheel drive) buggy needs some sort of obstacle avoidance sensor so the HC-SR04 I’ve had in my components drawer since my PIC days came out. Using this ultrasonic detector is easy and gives accurate distance results up to about 3cm from the device.

    In this video we’ve added it to the 2WD buggy we’re slowly building (very cheap kit from the Gar East) and this gives it obstacle detection capabilities.

    Detect obstacles on your robot buggy with this ultrasonic device
    https://github.com/RalphBacon/HC-SR04-Ultrasonic-Sensor

    Reply

Leave a Reply to Abhay Kalmegh Cancel reply

Your email address will not be published. Required fields are marked *

*

*