Overview
The JSN-SR04T takes the beloved HC-SR04 formula — fire an ultrasonic ping, time the echo, compute distance — and moves the transducer into a sealed, IP66-class metal-and-epoxy capsule on a 2.5-meter cable. That one change opens up every environment that kills a bare sensor: rain, spray, mud, condensation, dust. It's the sensor for water-tank level gauges, bin-fullness monitors, outdoor parking sensors, and boat/dock distance measurement.
A single waterproof transducer both transmits and receives (the HC-SR04 uses two), and the control board — which stays indoors/dry — handles the drive electronics and timing. The interface is deliberately HC-SR04 compatible: pulse Trig for 10 microseconds, measure the width of the Echo pulse, divide by 58 for centimeters. Any HC-SR04 sketch, library, or tutorial works by changing nothing but expectations at the near end of the range.
That near end is the honest trade-off: because one transducer must stop ringing before it can listen, the JSN-SR04T has a blind zone of roughly 25 cm. From ~25 cm out to ~450 cm it measures reliably with ±1 cm class accuracy; closer than that, readings are invalid. Mount it so the nearest surface you care about stays beyond the blind zone (in a water tank: above the max fill line by 25+ cm) and it will run for years where an HC-SR04 wouldn't survive a season.
At a Glance
Specifications
| Parameter | Value |
| Model | JSN-SR04T (integrated waterproof ultrasonic module) |
| Operating Voltage | 3.0 - 5.5V DC (strongest performance at 5V) |
| Working Current | < 8 mA quiescent, ~30 mA peaks during ping |
| Measuring Range | ~25 - 450 cm (600 cm best case on flat targets) |
| Accuracy | ±1 cm typical (±0.3% class) |
| Beam Angle | ~45 - 75 degrees (wider than HC-SR04) |
| Interface | 5V/Trig/Echo/GND; 10 us trigger pulse, echo width / 58 = cm |
| Alternate Modes | Solder pad/resistor selects serial auto-output or query mode (default = Trig/Echo) |
| Transducer Rating | Sealed, waterproof head; control PCB is NOT waterproof |
| Cable | ~2.5 m fixed lead to control board |
| Operating Temperature | -10°C to +70°C |
Pinout Diagram
Four header pins on the control board — 5V, Trig, Echo, GND — plus the socketed transducer cable. The board goes in your enclosure; only the capsule at the end of the cable faces the weather. Point the capsule squarely at the surface you're ranging: perpendicular mounting matters more here than with narrow-beam sensors because of the wide cone.
Wiring Guide
Arduino Wiring
| Module Pin | Arduino Pin |
|---|---|
| 5V | 5V |
| Trig | D9 |
| Echo | D10 |
| GND | GND |
ESP32 Wiring
Power the module at 5V for full range, and divide the 5V Echo down before it reaches a 3.3V pin.
| Module Pin | ESP32 Pin | Details |
|---|---|---|
| 5V | VIN (5V) | |
| Trig | GPIO 5 | 3.3V trigger works fine |
| Echo | GPIO 18 via divider | 1k from Echo, 2k to GND, junction to pin |
| GND | GND |
Raspberry Pi Wiring
| Module Pin | Pi Pin | Details |
|---|---|---|
| 5V | Pin 2 (5V) | |
| Trig | Pin 16 (GPIO 23) | |
| Echo | Pin 18 (GPIO 24) via divider | 1k/2k divider — Pi pins are NOT 5V tolerant |
| GND | Pin 6 (GND) |
Raspberry Pi Pico Wiring
| Module Pin | Pico Pin | Details |
|---|---|---|
| 5V | VBUS (pin 40) | USB 5V |
| Trig | GP3 | |
| Echo | GP2 via 1k/2k divider | Protect the 3.3V input |
| GND | GND (pin 38) |
Code Examples
Every example medians several pings (ultrasonic loves the occasional wild outlier), flags blind-zone/out-of-range readings, and prints centimeters — drop-in HC-SR04 logic with JSN-aware limits.
Arduino
// JSN-SR04T Waterproof Ultrasonic - Arduino Example
// Trig->D9, Echo->D10, 5V, GND
const int trigPin = 9;
const int echoPin = 10;
long readOnceCm() {
digitalWrite(trigPin, LOW); delayMicroseconds(4);
digitalWrite(trigPin, HIGH); delayMicroseconds(10);
digitalWrite(trigPin, LOW);
long us = pulseIn(echoPin, HIGH, 40000UL); // 40 ms timeout
return us == 0 ? -1 : us / 58;
}
long readMedianCm() {
long a = readOnceCm(); delay(60);
long b = readOnceCm(); delay(60);
long c = readOnceCm();
// median of three
if ((a >= b) == (a <= c)) return a;
if ((b >= a) == (b <= c)) return b;
return c;
}
void setup() {
Serial.begin(115200);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.println("JSN-SR04T ready (blind zone < ~25 cm)");
}
void loop() {
long cm = readMedianCm();
if (cm < 0) Serial.println("Out of range / no echo");
else if (cm < 25) Serial.println("Too close (blind zone)");
else {
Serial.print("Distance: ");
Serial.print(cm);
Serial.println(" cm");
}
delay(300);
}
ESP32 (MicroPython)
# JSN-SR04T - ESP32 MicroPython Example
# Trig->GPIO 5, Echo->GPIO 18 (via 1k/2k divider), 5V->VIN
from machine import Pin, time_pulse_us
import time
trig = Pin(5, Pin.OUT, value=0)
echo = Pin(18, Pin.IN)
def read_once_cm():
trig.value(0); time.sleep_us(4)
trig.value(1); time.sleep_us(10)
trig.value(0)
us = time_pulse_us(echo, 1, 40000) # 40 ms timeout
return -1 if us < 0 else us // 58
def read_median_cm():
vals = []
for _ in range(3):
vals.append(read_once_cm())
time.sleep_ms(60)
return sorted(vals)[1]
print("JSN-SR04T ready (blind zone < ~25 cm)")
while True:
cm = read_median_cm()
if cm < 0:
print("Out of range / no echo")
elif cm < 25:
print("Too close (blind zone)")
else:
print("Distance: {} cm".format(cm))
time.sleep(0.3)
Raspberry Pi (Python)
#!/usr/bin/env python3
# JSN-SR04T - Raspberry Pi Example
# Trig->GPIO23, Echo->GPIO24 (via 1k/2k divider)
import RPi.GPIO as GPIO
import time, statistics
TRIG, ECHO = 23, 24
GPIO.setmode(GPIO.BCM)
GPIO.setup(TRIG, GPIO.OUT, initial=0)
GPIO.setup(ECHO, GPIO.IN)
def read_once_cm():
GPIO.output(TRIG, 1); time.sleep(0.00001)
GPIO.output(TRIG, 0)
t0 = time.time()
while GPIO.input(ECHO) == 0:
if time.time() - t0 > 0.04: return -1
start = time.time()
while GPIO.input(ECHO) == 1:
if time.time() - start > 0.04: return -1
return (time.time() - start) * 17150
try:
print("JSN-SR04T ready (blind zone < ~25 cm)")
while True:
vals = []
for _ in range(3):
d = read_once_cm()
if d > 0: vals.append(d)
time.sleep(0.06)
if not vals:
print("Out of range / no echo")
else:
cm = statistics.median(vals)
if cm < 25: print("Too close (blind zone)")
else: print(f"Distance: {cm:.1f} cm")
time.sleep(0.3)
except KeyboardInterrupt:
GPIO.cleanup()
print("Stopped by user")
Raspberry Pi Pico (MicroPython)
# JSN-SR04T - Pico MicroPython Example (water tank level demo)
# Trig->GP3, Echo->GP2 (via 1k/2k divider), 5V->VBUS
from machine import Pin, time_pulse_us
import time
trig = Pin(3, Pin.OUT, value=0)
echo = Pin(2, Pin.IN)
TANK_DEPTH_CM = 120 # sensor face to tank bottom
SENSOR_OFFSET = 25 # keep sensor above max water by blind zone
def read_cm():
trig.value(1); time.sleep_us(10); trig.value(0)
us = time_pulse_us(echo, 1, 40000)
return -1 if us < 0 else us // 58
while True:
cm = read_cm()
if cm < 0:
print("No echo")
else:
water = TANK_DEPTH_CM - cm
pct = max(0, min(100, water * 100 // (TANK_DEPTH_CM - SENSOR_OFFSET)))
print("Air gap: {} cm | Water: {} cm | Tank: {}%".format(cm, water, pct))
time.sleep(1)