Waterproof Ultrasonic Sensor – ElectroSchematics.com

This post is a review of the popular waterproof ultrasonic sensor JSN-SR04T. I hope this will serve as a backdrop for some interesting ultrasonic distance sensor experiments and projects.

A number of ultrasonic articles are already published here, and rather than citing all that material, I would like to begin this post by mentioning a link for your background read: https://www.electroschemics.com/secrets-of-car- reverse-parking-sensors/

Let’s get started!

The JSN-SR04T Waterproof Ultrasonic Sensor

As well as the familiar ultrasonic ranging module HC-SR04, another one seen on online markets is the JSN-SR04 (and variants). The JSN-SR04 ultrasonic ranging module has some notable differences – it has a single waterproof ultrasonic transducer probe and a dedicated electronics circuitry to handle the transducer. Besides, the transducer comes with a pretty long (~2.5 meters) weatherproof cable.

According to many blogposts, the JSN-SR0T4 ultrasonic range finder can provide 25cm-450cm non-contact distance sensing function, ranging accuracy up to 2mm. Note that only the transducer probe and the external itself are waterproof. If water enters the electronic module, the device may stop working or may be permanently damaged ⚠

I think that for some automobile/robotics projects the JSN-SR04 sensor is better suited compared to the regular HC-SR04 sensor. The price, although more, is okay when you consider the unique features you’re getting!

Working voltage of JSN-SRo4 is DC 5V and static working current (quiescent current) is around 5mA while working current (operating current) is about 30mA. The acoustic emission frequency is 40kHz, and the measuring angle is 45-75 degree.

The module (sensor/control electronics) has the same four connections as the HR-SR04 modules :

Trigger, Echo, 5V and Ground.

Key Components & Datasheets:

The IFT-shaped component (IFT is not a right term here) is a special 4-pin ultrasonic transformer used to provide enough driving voltage for the ultrasonic transducer. It also has the function of matching the impedance (thus reduces the ringing time). If this transformer is tuned wrong, then the electronics won’t work correctly. It seems, the inductance of its high-voltage side coil and the capacitance of the ultrasonic transducer can form a resonant circuit. See Page 2 of this PDF datasheet to get a simulation circuit example https://www.futurlec.com/USTR40-14A.shtml

This is the borrowed (and retouched) schematic of JSN-SR04T. Note: there is no exact guarantee!

The R19/R27 Resistor Trick

You may be wondering why the Trigger and Echo pins in the module are also labeled as Rx and Tx respectively. Look, the module has an empty resistor pad (R19) for mode selection.

At this point, note that Mode 1 (Default Mode) uses the echo & trigger pins like a standard ultrasonic sensor whereas Mode 2 (TTL Serial Output Mode) uses software serial. So, if you wish to use Mode 2 you need a 47KΩ resistor soldered to the R19 solder pads. You can also put a 120KΩ resistor there instead to alter the Mode 2 power recognition configuration.

In certain modules this resistor is labeled as R27. Mine is R19, but that is not a large difference. I found that the JSN-SR04T with R27 resistor is in fact JSN-SR04T 2.0 (https://www.makerfabs.com/desfile/files/JSN-SR04T-2.0.pdf), similar to JSN-SR04T but has a bit wider operating voltage (DC 3.0V to 5.5V). I’m sure there’re many other things that I’ve yet to discover, and if you know of one, please leave a comment so that we can pass that knowledge on to others.

Now to a summary of the basic operation of the ultrasonic distance sensor:

A pulse of at least 10us is applied to the Trig pin of the module. This will automatically generate 8 drive pulses at 40kHz. The 8 pulses will reflect off a target and be received back at the module. The module then generates a signal from the Echo pin that corresponds to the time between the drive pulses being transmitted and the reflections being received.

The distance from the transducer to the reflecting surface can be found by multiplying the time that the Echo pin was High by the speed of sound (340m/s) and dividing by 2, since the signal traveled forth and back.

This simply means, if the High time is 15ms, then

d = 15 x 10 -3 x 340 /2 = 2.55 m.

So, the target is 2.55 meters away (note that the speed of sound varies with temperature, but is not taken into account here).

On a side note, you can see many scary posts about the 2.o modules on the web. Don’t panic, there is nothing wrong with them as long as you are willing to experiment a bit with the timing in your code. Using a longer trigger pulse of at least 20µs in lieu of 10µs seems to help if you are having incorrect readings.

The Lazy Road Test (JSN-SR04T/Mode 1)

Everything always looks good on paper (and in its seller’s description), so I plugged my module into an Arduino Prototyping Shield for a quick/lazy evaluation using an Arduino Uno.

If you have played with the ultrasonic distance measurement projects, I’m sure you have at some point played with the HC-SR04 Ultrasonic sensor modules. Shifting to the new waterproof ultrasonic sensor is not a big deal, since it’s pretty easy to modify some example codes to use it.

The quick road test, oh it’s a simple approach to display the distance measurements on the Arduino Serial Monitor. I will use this sensor (or its latest version) in a more complex project in the next part of this post. Stay tuned for that do it yourself project.

Below is the Arduino Sketch used to test the JSN-SR04T ultrasonic distance sensor. This sample code does not require a library.

[code]

#define trigPin 12 // Trig Pin to D12

#define echoPin 11 // Echo Pin to D11

long duration;

int distance;

void setup() {


pinMode(trigPin, OUTPUT);


pinMode(echoPin, INPUT);


Serial.begin(9600);

}

void loop() {


digitalWrite(trigPin, LOW);

delayMicroseconds(5);


digitalWrite(trigPin, HIGH); //Trig HIGH for 10us


delayMicroseconds(10);


digitalWrite(trigPin, LOW);

duration =
pulseIn(echoPin, HIGH);

distance =
duration * 0.034 / 2;


Serial.print(“Distance = “);


Serial.print(distance);


Serial.println(“cm”);


delay(100);

}

[/code]

This is a casual snap of the Serial Monitor readout (nearby wall as the target object).

Note that the module outputs the nearest distance value in the dead zone. The output will be zero (0) if the module does not measure the distance or is out of range. As observed, the minimum distance that can be measured is ~20cm. Moreover, since the transducer has a comparatively large measuring angle, it is notuseful for measuring distances in tight spaces.

While I was working with my experimental setup, the ultrasonic transducer was mounted on an articulating arm so it could be easily tested in an open space.

Below you can see my Arduino setup. Even though I picked up the Arduino Uno R3 for this tutorial, you can use pretty much any standard Arduino. Not a big deal!

In Conclusion

Basically, I just wanted to let you know/see how the JSN-SR04T sensor works and what it can do for you. Some of its major applications are parking sensors, underwater distance measurement, outdoor tank level measurement etc.

Let us outline the features that make JSN-SRo4T sensor stand out from the rest. First, this sensor uses a single transducer instead of two, therefore conserves space and makes the electronics smaller. Second, this sensor not only has trigger and echo interface but also serial communication. Third, this is the only “budgetary” waterproof sensor suitable for an outdoor environment that we come across.

I would love to know what projects you plan on building or have already built with this sensor. If you have any questions, suggestions, or if you think that something crucial is missing in this quick writeupplease leave a comment down below.

At last, I do have a JSN-SR04T 2.0 so it might be time to try a substitution exercise. There might be a lot of very interesting observations coming to light then and I will compile them for a future post.

Leave a Comment