Это видео недоступно.
Сожалеем об этом.
Arduino Tutorial 54: Measuring Speed of Sound With HC-SR04 Sensor
HTML-код
- Опубликовано: 17 авг 2024
- You guys can help me out over at Patreon, and that will help me keep my gear updated, and help me keep this quality content coming:
/ paulmcwhorter
In this lesson we show how the circuit you built in the previous lesson can be used to measure the speed of sound. This is a pretty cool demonstration, and lets you practice your math skills.
You can get the kit I am using for this series at the following link:
amzn.to/2I7N4Ek
I strongly suggest picking up an arduino nano, since it can plug directly into the breadboard, making a portable system more practical. You can pick one up here:
amzn.to/2WXTC2M
As projects get more complicated in these lessons, you guys really need to get a set of breadboard jumper wires which allow you to make neater connections on the board in your projects. You can pick a pack of these wires up here:
amzn.to/2XrY5Kq
In addition as projects get more complicated, you are going to need a bigger breadboard. This is a reasonable one here:
amzn.to/2IY4d3M
Follow along with this lesson on our WEB site:
toptechboy.com...
[Disclosure of Material Connection: I am a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com. This means if you visit the link and purchase the item, I will receive an affiliate commission. Regardless, I only recommend products or services I use personally and believe will add value to my readers.]
#Arduino
Paul has taught me more in a week than my teacher does in a year
faxs
He makes it so much interesting and the subject is also interesting
Totes
I bought the Elegoo kit before I knew you existed. I bought it because I wanted to learn coding for micro controllers. Elegoo comes with a disk full of lessons (which I started doing), but I was not learning how to write the codes because I was only copying theirs. Then I searched the internet and found Paul McWhorter's most excellent tutorials and I am so glad. . Your teaching style does not endorse copying the codes, so I'm am learning to write them on my own while referring to your videos to check and correct myself. Thank you for doing these. Coding is becoming easier. I'm continuing until I run out of your lessons. Loving every minute.
I did my homework and also used the LCD to show the distance! You Rock Paul!
same here
Hello Paul, Just finished this tutorial #54 and having had a career in the US Airforce and flew for a few civilian airlines I was trained as a "Flight Engineer". We were taught about subjects having to do with altitude and the density of the air varies depending on primarily, temperature and altitude. So the speed of sound(or Mach) changes as these two variables change. Sea Lvl standard day(59 deg F, Sea Lvl) equates to a speed of sound of 761 mph as you stated. As altitude increases the speed of sound decreases. I really enjoyed this one, I finished my program before watching you tutorial and was pointing the sensor everywhere to get measurements. Quite accurate.
Invaluable! Patience. Persistence. Critical thinking. When you get our math brain and the real-world empirical thoughts to collaborate, you can solve anything. Thank you Paul for your patience and genuine passion.
Hello Paul,
Another really amazing lesson. I love the math explanations in all of your lessons. No one explains these concepts in other tutorials and you not only explain, it but very clearly and in great detail, step by step !!!!!! Simply extraordinary and amazing !!!!! Please, You and Yours take care and GOD bless and be very safe and well !!!!! Rick
Did the same mistake while doing my homework :D. The ping is travelul the distance twice. Thank you for the lesson! A math refresher is always most welcome :D
Figured out what was wrong with the calculation before you stated it, realized I made the same mistake as you did. Easily one of the best Arduino tutorials on RUclips.
This was a good lesson, i'm a computer science student doing this as a module, this was a good look back at my Physics A-Level.
Hi Paul, Have been following your "most excellent" tutorials and just now calculated the speed of sound at near sea level in Queensland to be 334 m/s. The atmospheric pressure here right now is 1009.6 hP. I am really happy with that result. Thank you so much for your time and effort in publishing these videos.
Excellent!
not only I did the homework, but I also displayed the information not on the serial screen, but directly on the LCD. Very very happy with this. THANK you very much, Mr. Paul, for your teaching!
LEGEND!
I wish you had more of these kinds of videos, this is like a full college course
This sensor responds linearly with distance, but my dog becomes sadder exponentially the farther I go.
There are so many so called teachers out there who tells you download their library, and sketches,maybe let you type 3 words, ( not even type, copy-paste) and they make you think that you do some stuff. Total BS...
With your lessons, for the first time I really understand the logic&math behind it. And like that's not enough, for the first time, before this lesson everything was set on my LCD, measuring and showing distance :) because after I watched your previous video, I had extra time for tinkering. Had to pause a while and pushed myself a little. [ To be honest metric system made it easier :) ] Can't thank you enough, again...
Thanks a lot
I have learned more off of this RUclips channel than I ever did in school
You sir, are the best at explaining things in a manor that only someone who was deliberately trying not to learn... would still learn. Keep up the great work and be safe in your travels.
Hey Paul, thanks for keeping up with your video tutorials. I hope you stay safe during the pandemic. We need you to survive and continue to help and enlighten us with more Arduino knowledge!
Sorry I haven't been studying! Summer classes started and C++ is what we're learning, surprisingly your coding has helped me out a lot already!
Great to hear!
i did the homework for this lesson in the previous lesson, i was ready for this one
This was my favorite lesson so far. I was having trouble getting my measured travel time stable. It was driving me nuts. I was able to get smoother results by logging the last 15 readings and taking an average to use as my travel time. Using this technique, I was able to calculate the speed of sound to 771.1039 MPH. I find that I learn the most when I encounter problems that require troubleshooting on my own. Thanks Paul, you're great keep up the good work.
This lesson blew my mind, i actually measured the speed of sound within 5% on my table and was able to see the signals on my cheap oscilloscope!!! Thank you so much, i love science, math and electronics and this is just incredible you are a great teacher!!!
This was an amazing video, what you said at 9:15 is very true, wish you had more projects like this with math showing us. Hopefully you do more
I did this in physics class this year, and I was lazy to find my ruler that keeps disappearing, so I just used the avg velocity as a constant to find the distance. Didn't expect to do the next video.
The mistake at 20:08 is that the ping time is the total time taken by the ping to cover twice the distance between the sensor and the obstacle, but we have
either consider the distance only one time or we need to divide the ping travel time by 2 so that we get the actual speed of the ultrasonic wave in the air
Exactly!
Was just about to give up when I realised I'd left a zero out of my multiplier. I've been doing a lot of maths lately, and it's nice to have a real world application for it. Thanks Paul
We gotta double the distance since ping goes and backs same distance twice. Paul, I love the way you doing mistake to show common errors. They become so useful for us.
I like the explanation of the maths, what we are looking at is the speed of the sonics (sound).
It's funny how Paul talks about people copy pasting the code and not learning while I was searching for someone to teach me and not just upload the code in the description.Thanks Paul .I want to learn. I am 15 by the way.
Good job! Keep learning and working hard and you will go very far in life.
Once again, I did it in metric. It worked like a champ. The distance from my PC to the wall is 1.56m :). I am breaking for Christmas 2023. See you all in the New Year. Bob
These lessons are fun, and they really boost my self-confidence. I am seeing the world with a different set of eyes; thank you for making me realize that I can help make a better future for everyone by simply learning how to solve problems. There is nothing more important than understanding the magic behind how things work, in my opinion, and I am here for it. Thank you, You are the teacher every student should have.
No! This was not boring me, I've been studying physics thinking that it'd one day be handy with robotics and BAM. This video totally validated the studying, Thanks!
Did my homework - the slope in the eastern hemisphere is 0.1786 [mm/usec] or 0.007 [in/usec]. Can't wait to see Paul's solution!
Very nice Paul keep going do not stop
As long as you have lessons I'll be here. Always learn from your lessons. I forgot about the distance being double. Thanks Paul.
Was able to dial in accuracy by playing with y=mx+b slope values by adj after measuring again. original calc had m=0.006. tweek it to use m=0.0069 and used a -0.18 for b value. It is now spot on down to 1" away. Interesting that the distance values increase when target is brought closer than 1", probably because ping and echo are too close to resolve? Very interesting lesson Paul, thank you again.
First of all. Thank you for all of the excellent content. Instead of doing the homework, I did something a little different. I work at a job where my PC has to be locked every time I leave my desk. I occasionally forget to do this. That is when I had an idea. I can use the sensor to determine when I leave my office and automatically lock my computer. I wrote a C# program that will communicate to the Arduino via the serial port and when the distance of a certain range is detected it will automatically lock the computer.
This was a terrific lesson. It makes one want to do backflips, well mental backflips any way. Such an amazing result with simple tools, math, and a little thinking.At first I thought the results would be way off looking at the data, but after plotting it and using least squares I got a result of 76O miles per hour. It got me thinking about so many things-sound waves vs light waves. Eyeballing a line was darn near as good as calculating the equation of the line.You are a terrific teacher. It was almost like a Sonic boom this time when you said BOOM.
I am a doer by the way I love your videos and I have learned a lot from you so all I want to tell you is thank you for your time.
Thanks Paul, another great project....can't wait to tackle it
A nice example why i prefer the metric system. Thanks for your best Tutorials Mr McWhorter, greets from GER.
you are teaching how things work. Grate job sir respect you
I am so glad that i am not the only one making mistakes .Thanks you are a great teacher
You are welcome!
Paul, cant say this enough, YOU ROCK
I love your teachings Paul and I want to definitely meet you someday😭❤️
I did it, I got the slope m=0.181 mm/microsecond, transferred to 7.13E-3 inch/microsecond, thanks Paul
Well done!
I did my measurements twice and found that the colour of the block made a difference. I used a white block for my second test and the numbers were higher than a box with some mixed brown colours on it. My speed came out to 830 mph with both sets of numbers so it must be that there is some inherent problem with the sensors that causes the error. Great lesson.
Very fun lesson. I ended taking two different measurements thinking I must have made a mistake. Then I realized I was off by a factor of 2, which clued me in. I also did it in meters per second, initially getting a value of 168.87 meters per second * 2 equals 337.74 , against a reported value of
324 meters per second at mean sea level.
Again, great lesson, Paul, and well worth the effort.
I did my homework and I knew what i was trying to find out ( how much does the sound travel in inches for every unit of time in microseconds) . Thank you Paul. This channel is epic !
Teacher that any student can just wish for. Thank you for good explaining.
Yes, I found the problem early on, we missed the return trip. When correcting that, I got as close to the speed of sound in my calculation as you could, using the sensor. This was a great lesson and you can't do this stuff unless you are willing to do the math. If you don't do the math, you will not be able to troubleshoot the problems that come up. This video is going to be mandatory homework for my students. Thanks again Paul. I work through these videos, one a night, after teaching my classes and before dinner.
I ended up with 772, which was decent considering no matter how hard I tried to set up an accurate experiment, I ended up with some minor issues.
Mr McWorther, why would this be boring? If it is, this is not your place to be. Right? I loved it.
"The key to being successful...in LIFE in general is knowing how to do dimensional analysis". Love this!! I wanna embroider this on a pillow, and I don't even embroider! (Honestly, I'm an ICU RN of 40years and used D.A. for drug infusion calculations before smart pumps came along).
And as a nurse then, you understand how important it is to get the math right EVERY time. I tell my students, that when you are school, get the math right 9 out of ten times you get an A and are a hero. In the real world, getting the math right 9 out of 10 times would be disaster. That would be like two dead people a day probably.
Good analytical explanation, thanks
I learned that way of ensuring units come out correct before considering the math back high school in 1971. The value of 365 is 1/2 of the speed of sound because the ping traveled twice the distance measured in the time measured, and the speed of sound is affected by air temperature; V(m/s) = 331.4 + .6(TempC), so results may vary.
You just got to love Paul and how he explains things. I do not get it all, but I do get enough to become a better Arduino Builder. Just 5 months ago or so, I started the Tutorials, and I was so happy to print out "Hello World" . That was 50+ Tutorials ago!!! Now only 14 more Tutorials to go!!!
Really appreciate the in-depth videos. :)
Glad to help!
Hi Paul did the homework but like a good engineer in Australia and most of the world I used SI units so was surprised to see you used imperial units and decimal inches at that, no big drama just a few quick conversions to get the same results. thanks again for another informative tutorial.
To be precise, all the world except USA, Liberia and Burma. And the last two are in the process of changing over. Still a very helpful video, though, as always.
the slope of this lines means that: increasing pingTravelTime by 1 microsecond is caused by increasing the distance between the object and the ultrasonic sensor by 0.00643 inches. I interpret the meaning of the slope by this expression, because in my opinion I see that the distance is the independent variable which we control ourselves, while the time is the dependent variable because it is caused by the change in the distance.
ur lessons are amazing
Hi Paul,
your tutorials are fantastic, thank you. I've sent the Distance result to the LCD and with the press of a button select Temp and humidity...Boom..... waiting for my Nano to arrive. This has been so much fun. Cheers
I suspected that this is the case and Paul confirmed ("times two" error) I did my measuring in mm/μs (0,18625), which gave me 372,5 m/s. A bit too much but results are wavering +/- , around 360 m/s (must be 330, error around 9%). Uncertainty in measurements...Very interesting lesson! Thank you Paul! Love it!
I love you mc.paul ,i came across your video last month,you are amazing 💯💯💯. I wish you could be my real class teacher. I also do your homework.
Fantastic video, thank you Paul!
I want to thank you for your videos. I learn a lot from your videos. The explanations that are given in the Arduino kits are very basic and poorly explained. A big thank you.
Glad you like them!
I didn't quite get what you meant by what m stood for but now it makes sense. As for the hw I was able to build a distance measurer but I did it using cross multiplication with the measurements I got. The slope formula just wasn't working for me but cross multiplication gives me accurate readings. Wrote a serial output to tell me the distance in cm, in, and ft. Its really cool how this works.
I love your videos. They make you think! I wish I had a teacher like you when I was growing up! Come to think of it. I did, she got married and moved away, replaced by an old monotone drab with zero excitement in what he was doing.
I have the circuit measuring the distance. Finally bought a oscilloscope. Love watching the pulse width increasing and decreasing.
Your videos are amazing! You are giving us the tools we need to be successful engineers in the real world!
This is another awesome video! I wish he was my math teacher!
Thanks Paul, another great lesson in math, Thank you
Just love the fact that you explaine everything. Keep goïng!!!
I uderstood that it was the speed of the sound but completely missed that the ping had to travel twice.
Beautifully explained Paul. And yes , these math refreshers are interesting and very well explained.
fyi also i had placed the print command after the delay ans all sort of strange things happened. Great lessons Paul thanks
The ping has to come back so the distance is doubled.
Libraries and codes are great, but I want to understand what's going on, and you sir, are a master of explaining things!!
Definitely an exciting tutorial
Not bored. Not angry. Excited because my homework was perfect with the exception of not remembering that slope is delta y/ delta x or dy/dx or VELOCITY. Truly cannot this AUDIO "ENGINEER" missed that! I knew we were using speed of sound to calculate distance, but somehow this connection hadn't occurred. So silly.
Great Lesson Still enjoying the math lesson
Dude thank you so much
Really helpful video
I did it using the metric system and did it right, next thing I'm gonna try to make a radar using the servo motor and the sensor! (I know you love feet and inches in USA Paul, but no one else use them xD). Best lessons ever, thank you.
Nice work!
Very good to touch the dimension analysis to this lesson
The ping is travelling to the barrier and back. We are only measuring half the distance the ping travels. Our calculations are based on only half the distance the ping travels so its actually travelling twice as fast as are calculated velocity.
Thank you Mr.Paul! So cool! Didn't know about the *2 part of it haha. But it's still so cool that we can measure something as abstract as sound with a simple arduino.
Did the homework. My calculations are: given sos = 343 m/s, the formula is [distance = 343e2 * pingTravelTime/2/1e6] to get the distance in cm.
e2 because we get cm from m by multiplying by 100, /2 to get half the travel time and /1e6 to get s from microseconds.
Got the LCD printing out the results too.
Great work Paul. If anyone is having the same problem as me I have a solution but there's sometimes more than one reason why something doesn't work. My Arduino Uno worked fine with this project but my Nano wouldn't upload. I had to change Tools>Processor from ATMega328P to ATMega328P(Old Bootloader). Then it worked fine. :-)
That's pretty cool! I'm really enjoying all these arduino lessons. Thank you for sharing your knowlege, Paul!
My pleasure!
Very interesting with math and your explanations are good
Another excellent video. I think the explanation about the travel distance being twice the measured distance could have been more compressed and the same time maybe used to explain how the speed of sound also varies with temperature. A good homework would be for the class to look up how that speed varies with sound and use the DHT11 to build and code a system to compensate for that. Lesson 54A maybe? Once again, thank you for your lesson!
Great lesson, loved it! My calculations came out 770mph. On to flip flopping the math.
This was a great lecture. Thank you.
Your explanations are perfect. I prefer to know how to things work so that I can figure out the problems for myself, since you will not be there forever to solve everyones problems. BTW I did figure out this problem on my own before your video.
v=s/t => m is speed
Again, thanks for those masterpiece lessons, Sir.
I took a 2-pronged approach to solving this. 1st, I used the Arduino to give me the travel times. where I got almost the same result as Paul and many of the followers below. So I thought let me confirm that by using my DSO Oscilloscope to capture the HIGH's of pin 11. I took the same measurements as using the Arduino. Turns out. My O'Scope was a more accurate. Example: my 2.25" measurement was 265uS on the O'Scope vs. My Arduino at 213uS. Using all measurements on the O'Scope, after the math I was at 756.58mph. Arduino was at 740.12mph.
(Speed of sound is 761mph - depending a various factors, Temperature, Humidity, and elevation). In short, I find my O'Scope more accurate.
Thank you Paul..... You are fabulous in teaching...... Thanks I am so grateful to you
I appreciate that!
That was super fun!
the calculated slope means the sound waves are traveling at 0.00643x2 inches per microsecond. the times two is because the sound waves will actually reach the distance in half that time, and spend the other half traveling back to the sensor.
or about 326 m/s which is the standard unit for speed of sound
aaand i feel like i kind of already answered the second question when i answered the first... 365mph is HALF the speed of sound because it has to cover the distance between sensor and object twice. i wouldn’t call anything to this point a mistake, personally. it takes 365mph for the sound to travel there and back is just not the final answer for the final speed of the sound waves :)
also absolutely no judgement from me on using mph vs m/s! they both work!
Hello Paul!
Just finished my homework with a little help.
Found a way to save data from Arduino to a file.
Open a command-window in Windows.
At the prompt type the following command:
type com6: >> dataLog.txt
To stop logging use:
ctrl-c
The figure (6) may differ between computers.
Take note of the filepath ( or write it into the command).
Use notepad to read the results afterwards by opening the file.
With regards
Glenn
Glen, Thanks for that i'll be using that command a lot in the future, FYI my PC uses Com port #7
Great lesson and the math is even starting to make sense to me, you are a great teacher😀
Thank you for this excellent series
So nice of you
This is the best series I have ever come across. I have shared it with my friends.
Hi Paul,
I have followed all your tutorials, and think you, and they are great. I hope you don't mind, but I took this turoial, and added the LCD screen to it, so I didn't need the serial port. With Corona virus, and being home working, I will work with my 10 year old submit a project to school on measuring the speed of sound. Thnaks agin so much, Mike
Amazing lesson