Today we will take a look at the JSN-SR04T and A02YYUW Waterproof Ultrasonic Distance Sensors. We will see how they work outside, and we’ll even test to see if they work underwater (spoiler alert - they won’t!).
When we think of ultrasonic distance sensors, chances are we are thinking of the popular HC-SR04. After all, it’s simple to use, it works pretty well, and it is very inexpensive.
But while the HC-SR04 is a great sensor for indoor use, it isn’t really suitable for use outdoors. It is susceptible to dirt, it’s relatively fragile and, most importantly, it isn’t waterproof.
So today I’ll be examining a couple of ultrasonic distance sensors that are fully waterproof. They also are more advanced than the HC-SR04, as they are both capable of calculating the distance measurement by themselves, without the aid of a microcontroller or microcomputer.
The JSN-SR04T is an interesting sensor for a number of reasons. First, it uses a single transducer, instead of a separate transmit and receive transducer. Second, the transducer is attached to the main circuit board with a 2-meter cable, allowing you to mount the waterproof sensor remote from the non-waterproof board. And third, it actually has six modes of operation.
The A02YYUW looks a bit like a large, rubberized HC-SR-04 in that it has a separate receive and transmit transducer. But that’s where the resemblance ends. This is a smart sensor that outputs serial data, and it can run on 3.3 or 5 volts.
We’ll hook up both sensors to an Arduino Uno and write some simple code to use them. And, as the JSN-SR04 and A02YYUW both use the same format of serial data, we can even reuse the same sketch for both sensors!
Here is the table of contents for today’s video:
00:00 - Introduction
01:33 - How Ultrasonic Distance Sensors Work
04:37 - Look at the two sensors
05:50 - Using the JSN-SR04T Version 3.0
13:12 - JSN-SR04T Mode 0 Sketch & Demo (HC-SR04 Emulator)
18:01 - JSN-SR04T Mode 1 Sketch & Demo (Serial Data)
21:13 - Using the A02YYUW
26:06 - Outdoor Tests
28:18 - Underwater Tests
30:00 - Conclusion
As always you’ll find an article accompanying this video where you can grab all the code I used, as well as pick up some more information.
Hope you enjoy the video!
Bill
"Never trust a computer you can’t throw out a window." — Steve Wozniak
You're unlikely to find anyone who's willing to wade through hectares of unformatted code looking for a problem that you don't even bother to describe.
Try removing all of your code which doesn't relate specifically to the device and the problem in question and please give us a full description of the problem with quoted error messages and screen prints as needed.
We'd like to help, but you have to do some of the work too by providing us with the relevant information.
Anything seems possible when you don't know what you're talking about.
@gooseone One way to cut down on the size of that sketch is to move those huge data declarations out to include files. That way your listing will still compile as usual but on the forum here it will be several hundreds of lines shorter. Also use Tools/Autoformat. There are other things to do to shrink the sketch to the minimum, for instance you have
if(tankLevel >= 100) { level = 4; }
but you can simply code it as
if(tankLevel >= 100)
level = 4;
OR
if(tankLevel >= 100) level = 4;
4 lines is now 1 or 2 with no loss in comprehension and in fact may improve overall comprehension.
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
@gooseone BTW, you should start your own Topic in an appropriate forum/sub-forum since this isn't really about Bill's video.
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
Hi Ron / Will
Sorry new to all this
GT
Hi, will my apologies the code works well using standard sensor connecting the WP model detailed in Rons vid just doesn't want to work, thought by posting they're would a simple explanation.
Regards GT
@gooseone When trying to tag someone, it's @zander @will. This is the Youtube sub-forum, start a new topic in an appropriate dub-forum. post a description of what you expect, of what actually happens, relevant code, try to keep it to less than 50 lines. Screen shots of any screen activity. The use of Serial.println(" expected x = 3 but getting " + String(x)); type debug output is useful.
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
Hi, will my apologies the code works well using standard sensor connecting the WP model detailed in Rons vid just doesn't want to work, thought by posting they're would a simple explanation.
OK, it appears that you're still missing the point, so I'll have to ask the question ... what makes you think it's not working ?
Anything seems possible when you don't know what you're talking about.