Waterproof Ultrasonic Distance Sensors – JSN-SR04T & A02YYUW 💧☔

Waterproof Ultrasonic Distance Sensors – JSN-SR04T & A02YYUW 💧☔

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!).

Article with code: https://dronebotworkshop.com/waterproof-ultrasonic
More articles and tutorials: https://dronebotworkshop.com
Join the conversation on the forum: https://forum.dronebotworkshop.com
Subscribe to the newsletter and stay in touch: https://dronebotworkshop.com/subscribe/

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

50 Comments

  1. Prayers for your mother and you, I’m 75 now and have been through it. I’m new to the Arduino IDE, I’m getting an error while running this code for Mode 1. It reads "unsigned char CS", anything I should have turned on or off in the IDE, or maybe a library I need to not include.

  2. I know I’ll always get the straight dope here. Well-reasoned, detailed, rarely biased and always clear. I get all the info I need to make a decision that is best for me. Thanks.

  3. I wonder how to make an output graphical screen that represents the data relevant provided by the sensor?
    Anyone knows were to start?

  4. I have a question, i try to braodcasr a signal from the esp 32 and a jsn-sr04m-2 ultrasonicsensor but my readings are almost always 0 or 8000/9000 and that cant be right…even whit a simpel test code i cant get nice readings…what can i do ? Or how can i get in toutch whit you to fix it?

  5. The AJ-SR04M is vary unstable,,, Shure you can get stable readings, BUT those stable readings will change, to OTHER stable readings depending what is located around the pcb of the device…. EMI….. Example.. put the device (PCB) in a plastic case ,, you get stable reading of say 111.x Now lay a 12 gage wire not connected to anything across the top of box and reading changes to a stable reading of 22.x …. We did shield the pcb, but this type of thing still happened..

  6. Any single – sensor ultrasonic sensor system has a "blind time" associated with the resonant behavior of the sensor, any tuned circuit in the transmit or receive path, and, of course, the length of the "outbound" pulse, as our esteemed presenter notes.

  7. Hi, I copied and applied the sketch for the A02YYUW. I have an Arduino Uno IDE 2.0.3
    Everything goes well including compiling but when I turn on the serial monitor there is no output.
    It says in a line that is printed in light gray:
    Message(enter to send message to ‘Arduino Uno’ on ‘Com6’)

    I selected ‘Arduino Uno COM6’ in the top left of the sketch.
    The button to the right of the compiling button also does not respond when pressed.
    What’s wrong?

  8. id like to put this sensoncoming cars through the back and beep say a range of 8 feet. can this work

  9. Regarding the JSN-SR04T sensor, please inform if this sensor is produced with NON-TOXIC materials, since it will get wet with the evaporation of the water inside the water tank and the drops will fall into the water in the box that will be consumed for drinking, cooking, etc. . Thank you very much.

  10. Hello,
    I have a reolink camera with a pir sensor and want to make it into a underwater dome but need another sensor then the pir for activating the camera when motion is detected. You think i can replace the pir in de camera with this one ?

  11. Could 2 JSN-SR40T sensors be controled by a single Arduino UNO or a Mini ? Could pins 10&11 be used on one and 5&6 on the other each turn on a different LED ?

  12. Thank you very much for this video. I’ve watched multiple videos of these same sensors and it seems that in water the distance must be greater for them to work. This has something to do with how fast the sound returns in small spaces. IE there was a test where results from edge of water was not accurate, but from boat was accurate as it was over 3 meters.

  13. I’m using the AJ-SR04M that received from Aliexpress instead of JSN-SR04T, with ESP32 board and the accuracy is OK but the measurement is freezing after a reboot of the board or due to power cut. Any idea what could be the issue?
    Community in Home assistant forum reached a dead end!

  14. Programming error "unsigned char CS" is being use by the Arduino WiFi board. It took me long enough to find the reason for the error. The variable "CS" is being used by the WIFI board, Just thought you would want to know. I’ll try a different char.

  15. Should A02YYUW work on a drone landing mechanism? Im trying to see if I can measure the distance on the landings and advertise the user of the drone if it is too close to the ground in agriculture applications

  16. Wonderful job, I am working on a driveway gate project and you have helped tremendously. Thank you.

  17. Still one of the most comprehensive instructors on the internet! Thank you so much for the amazing info and time you put into the videos

  18. I was giving up on ultrasonic sensors for outdoor use because mounting behind glass would not work. Thanks for this vid

  19. Hello Sir, your explanation is very helpful for me. My background is in civil engineering with zero knowledge of Arduino. I am starting to learn to use Arduino Uno R3 for my lab research. By following your instructions, I successfully can install and read the single data from an A02YYUW sensor. However, I need to install two sensors in one Arduino board and read the data from the two simultaneously. Can you give me an example code for it? It will help my study. Thank you.

  20. There’s a problem with the A02YYUW sensor if you’re trying to meausure a fluid level in a 150mm PVC pipe. The sound reflections confuse the sensor and it gives the wrong readings (something similar happens if you put it at the domed apex of a water tank, or near the corrugations at the side). I found that narrowing the sound aperture by cutting a 50mm high piece of packing foam to fit over the sensor with a similar sized rectangular window for it to hear through fixes the problem.

  21. Hello !:) Can you somehow use these ultrasonic devices to agitate water? i.e. make some movements so it does not just stand still

  22. Would you have any advice on connectring JSN-SR04T to Raspberry Pi3B via UART pins 14,15? I enabled enable_uart=1 in boot config, I can see /dev/ttyS0 device appeared but I don’t seem to ready any data off it with screen /dev/ttyS0 9600 command

  23. Have you considered building a robotic lawn mower. Maybe modify one of today’s very lightweight battery powered mowers?

  24. Do you know any model that working properly under the water, we are trying to make a submarine vehicle and we have to map the pool or we should know whether we near of the wall or not

  25. You are a great instructor. I read somewhere that the minimum distance is 20 cm. I monitor water loevel in an IBC tote and when near the top it reads 19 or 20 cm then as the water is drawn off for irrigation it begins to read 21- 30 and at 31 cm it disables the pump so it wont burn out. If I get alot of rain, it refuses to read anything for awhile, maybe 2 days, but then it fires up and works again. Any ideas as to why?? Thanks to all who can help.

  26. Hi everyone – It’s come to my attention that there has been someone masquerading as myself, responding to some comments here with a link to a Telegram chat to win a prize from me. THIS IS A SCAM, I am not holding a contest, nor do I have a Telegram account. PLEASE DO NOT RESPOND TO THESE MESSAGES!!

    It’s happening on a lot of my videos, I’m taking steps to remove them manually, but as I have 162 videos, it will take some time. If you do run across a suspicious comment, I would appreciate you letting me know at info@dronebotworkshop.com.

    Thanks!

    Bill (The real one!)

  27. Fantastic video! Thank you for making these. Are there sensors where the receive and transmit modules are separate units? This would be great for measuring the distance between two moving objects. Any help here will be much appreciated.

  28. hey what if i got 2 – 4 sensor ultrasonic conection to a single microcontrol? what library should i use? or can i use SoftwareSerial Library to comunicate 2 or more sensor with UART?

  29. The waterproof single sensor appears to be exactly the sensor used in millions of cars for parking sensors… You get 8 of them in a parking sensor kit for €12-25, or 4 sensors, without electronics, for about €8.

  30. Nice video. Question: Would it be possible to extend the cable on one of these sensors? My anticipated application is measuring the water level in a river, for which I want to attach the sensor to a beam above the water. Thanks!

Leave a Reply to @miguelposada3684 Cancel reply

Your email address will not be published.


*