Part

Waterproof ultrasonic, JSN-SR04T

A sealed probe on a cable, 20 cm to 6 m: HC-SR04 style TRIG and ECHO or 9600 baud frames, for NewPing.h.

See every part
  • 4 pins
  • 2 settings
  • In 1 project
Drawn live by the editor's own code, at the size you see it.
Waterproof ultrasonic, JSN-SR04T as drawn in the Mokxi simulator
At a glance

The Waterproof ultrasonic, JSN-SR04T in brief

What it is, and every setting the properties panel gives it.

The JSN-SR04T is the waterproof ultrasonic ranger: a small control board and, on a long cable, one sealed probe in a rubber boot that both sends the 40 kHz burst and hears it come back. That one transducer is why it can live in a water tank, a sump or a car bumper, and why it is deaf for the first 20 centimeters: the probe is still ringing from its own burst, so anything nearer reads as about 20 cm, never less. The 3.0 board runs from 3.0 V to 5.5 V and reaches 6 meters. Its header is 5V, TRIG, ECHO and GND. With the mode pad open it works like an HC-SR04, a 10 microsecond trigger and an echo pulse 58 microseconds a centimeter long, which falls by itself after 40 ms when nothing comes back. Short M1 or M2 and the same two pins become a 9600 baud serial port sending four byte frames: 0xFF, the millimeters high and low, and a checksum. The part’s mode property is that pad, and the distance is a slider.

Family
Sensors
Pins
4
mode
pulse (or serial-auto, serial-command)
what the mode pad on the board is set to.
temperature
20
the air in degrees Celsius, 20 by default. The echo travels at 331.3 + 0.606 T meters a second, as on the HC-SR04.
Pins

4 pins

Named as the editor names them, so a wire lands where you expect it.

Pin
Role
What it does
5V
Input or output
Supply, 3.0 V to 5.5 V. A 3.3 V board runs it too.
TRIG
Input
Input. In pulse mode, high for 10 us or more fires a ping; in serial-command mode it is the module's RX.
ECHO
Output
Push-pull output. In pulse mode, high for the round trip; in the serial modes it is the module's TX, idling high.
GND
Input or output
Ground.
How to use it

How to measure a water tank with a JSN-SR04T and an Arduino

The JSN-SR04T’s control board stays dry outside the tank and its probe goes through the lid, looking down at the water. 5V goes to 5 V, GND to GND, TRIG to pin 12 and ECHO to pin 11. With the mode pad open, as the board ships, it speaks exactly the HC-SR04’s protocol, so NewPing.h and plain pulseIn() both read it unchanged.

The sketch asks NewPing for the distance in centimeters, takes it from the probe-to-bottom distance of 200 cm to get the depth, and prints the depth as a percent of the tank. Drag the slider: at 1 m the water is 98 cm deep and the tank 57% full, at 40 cm it is 93% full.

Now drag the slider under 20 cm. The reading sticks at 20 and never goes lower, because the probe sends and listens with one transducer that is still ringing from its own burst. A tank filled right up to the probe reads two thirds full, so the sketch treats anything under 25 cm as the blind zone, and the probe belongs at least 25 cm above the highest the water can get.

Set the mode property to serial-auto and the board sends a frame every 100 ms on ECHO instead: 0xFF, the distance in millimeters as two bytes, and the low byte of the sum, at 9600 baud. Serial-command waits for a 0x55 on TRIG and answers with one frame. The board works its millimeters out at 348 meters a second, so a meter in 20 °C air reads 1013 mm.

Part pin
Board pin
5V
5 V (3.3 V works too)
GND
GND
TRIG
Pin 12
ECHO
Pin 11

The 3.0 board runs from 3.0 V to 5.5 V and its ECHO swings to its own supply, so on an ESP32 or a Pico power it from 3.3 V and wire TRIG and ECHO straight to two GPIO pins.

JSN-SR04T water tank levellive0.000 s 0.00x
Click to open it in the editor
This is the simulator itself, running here. Click anything to open it in the editor.
Common errors

Common Waterproof ultrasonic, JSN-SR04T errors and fixes

What goes wrong
The fix
It reads 20 cm when the water is right under the probe.
That is the blind zone: nothing nearer than about 20 cm can be heard. Mount the probe at least 25 cm above the highest water and treat 20 to 25 cm as too close.
pulseIn() returns 0 or a 40 ms pulse every time.
Nothing came back within 6 m, or the probe is not pointing at the water. Check the probe’s cable and that the target is inside the range.
Serial reads nothing from ECHO.
In pulse mode the board times pulses; it only sends frames with M1 or M2 set. Set the mode property to serial-auto or serial-command to match the sketch.
An old board ignores a 10 us trigger.
Many 1.0 and 2.0 boards want a longer pulse, about 20 us. The 3.0 board, the one modeled here, takes 10 us.
Questions

Questions and answers

What is the minimum distance of the JSN-SR04T?

About 20 cm. The single transducer is still ringing from its own burst, so anything nearer reads about 20 cm. Treat readings under 25 cm as too close.

Does the JSN-SR04T work with the NewPing library?

Yes. With the mode pad open it uses the HC-SR04’s trigger and echo, so NewPing, pulseIn() and any HC-SR04 code read it unchanged.

What is the JSN-SR04T serial frame?

Four bytes at 9600 baud: 0xFF, the distance in millimeters high byte then low byte, and the low eight bits of the sum of those three. FF 07 A1 A7 is 1953 mm.

How it is modeled

What is true about the Waterproof ultrasonic, JSN-SR04T, here

In its help article’s own words: what the simulation gets right, and where it stops.

Modeled

  • Pulse mode is the HC-SR04's: a 10 us trigger, then ECHO high for the round trip, 58 us a centimeter at 20 °C. With no echo ECHO falls by itself after 40 ms, as the datasheet says. NewPing.h and plain pulseIn() both work.
  • The blind zone. Nothing is heard until the probe stops ringing, the time sound takes to go 20 cm and back. A target nearer than that reads as the edge of the blind zone, about 20 cm, never nearer. A sketch has to treat 20 to 25 cm as "too close", not as a distance; ESPHome's driver throws away anything under 25 cm for this reason.
  • The serial frames, their checksum, the 100 ms period of serial-auto and the 60 ms least gap between 0x55 commands of serial-command.
  • The module's arithmetic. The board works out millimeters at the datasheet's 348 m/s, about 28 °C, so in 20 °C air a wall a meter away reads 1013 mm in the serial modes. That is the module, not the model.

Not modeled

  • No sound is simulated: the slider is one number, not a tank to bounce sound around. The 75 degree beam, echoes off the tank's walls, foam, ripples and condensation on the probe are not modeled, and a reading has no jitter.
  • In the blind zone real boards read 20 cm or nonsense; the model gives the steady 20 cm edge, not the nonsense.
  • The delay from the trigger to ECHO rising is not in the datasheet; the model uses the HC-SR04's 460 us.
  • With nothing in range the serial modes send no frame; the datasheet does not say what a real board sends then.
  • The PWM-automatic, low-power and switch modes (200k, 360k and 470k on the mode pad) are not modeled.
  • Older 1.0 and 2.0 boards (mode resistor R27) are often reported to need a longer trigger, about 20 us. This is the 3.0 board, which takes 10 us.

From JSN-SR04T waterproof ultrasonic sensor, in full.

Projects

See the Waterproof ultrasonic, JSN-SR04T in a project

One built-in project uses it. It opens in the editor, already wired.

Boards

The boards it is shown on

This board has a built-in project with the Waterproof ultrasonic, JSN-SR04T in it.

Libraries

Arduino libraries for the Waterproof ultrasonic, JSN-SR04T

Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.

Wire up the Waterproof ultrasonic, JSN-SR04T

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.