Documentation

JSN-SR04T Waterproof Ultrasonic Distance Sensor Module for Arduino, Raspberry Pi & ESP32 | ShillehTek Product Manual
Documentation / JSN-SR04T Waterproof Ultrasonic Distance Sensor Module for Arduino, Raspberry Pi & ESP32 | ShillehTek Product Manual

JSN-SR04T Waterproof Ultrasonic Distance Sensor Module for Arduino, Raspberry Pi & ESP32 | ShillehTek Product Manual

manualshillehtek

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

Range
~25 - 450 cm
Blind Zone
0 - 25 cm (by design)
Transducer
Waterproof, 2.5m cable
Interface
Trig/Echo (HC-SR04 style)
Supply Voltage
3.0 - 5.5V (5V best)
Frequency
40 kHz ultrasonic

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.

JSN-SR04T waterproof ultrasonic distance sensor pinout diagram showing sealed transducer, cable and 5V Trig Echo GND pins

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
Warning: Echo swings to 5V when the module runs at 5V — use the 1k/2k divider (or run the whole module at 3.3V and accept shorter max range).

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

jsnsr04t_arduino.ino
// 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)

jsnsr04t_esp32.py
# 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)

jsnsr04t_rpi.py
#!/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)

jsnsr04t_pico.py
# 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)

Frequently Asked Questions

Why do I get nothing (or garbage) closer than ~25 cm?
That's the single-transducer blind zone: the same element that pings must stop vibrating before it can hear, and during that ring-down time close echoes are lost. It's physics, not a defect. Design around it — mount the sensor at least 25-30 cm from the nearest surface you'll ever need to measure. If you need 2-25 cm ranging, use an HC-SR04 (dry environments) or a VL53L0X laser sensor.
Can the whole thing go underwater?
Only the capsule is sealed — and it's built for weather and splashes, not sustained submersion. The control PCB must stay dry. And note it measures distance through AIR (to a water surface, for level sensing); it is not a sonar for measuring through water. For tank level: capsule above the water, pointing down, PCB in a dry box.
Readings jump around over a water surface. How do I stabilize them?
Median filtering (in every example) kills most spikes. Beyond that: keep 60+ ms between pings so old echoes die out, aim dead-perpendicular at the surface, and keep the cone clear of tank walls, pipes, and ladder rungs — the wide 45-75° beam happily returns the nearest thing, not necessarily the water. In tall narrow tanks a short PVC "stilling tube" under the sensor works wonders.
Is it a drop-in replacement for HC-SR04 code?
Yes — same 10 us Trig pulse, same Echo timing, same /58 math, so NewPing and every HC-SR04 sketch work unchanged. The two differences to respect: the blind zone (25 cm vs 2 cm) and slower repetition (wait ~60 ms between pings, and some board revisions dislike being triggered faster than ~100 ms). If a library hammers it at 20 Hz and gets zeros, slow it down.
What are the "mode" resistor pads on the board?
An unpopulated resistor spot (often marked R27/M) switches the board from Trig/Echo mode into UART modes: with a 47k fitted it auto-streams distance frames over serial every ~100 ms; with 120k it answers on request. Handy for long cable runs to the MCU. Most users leave it empty — default Trig/Echo keeps it compatible with everything.
Does temperature affect accuracy?
Sound speed shifts ~0.6% per 10°C, so a fixed /58 conversion drifts a couple of percent across seasons. For bin/tank gauges that's irrelevant; for precision, compensate: cm = us x (331.3 + 0.606 x tempC) / 20000. Pair it with a DS18B20 or DHT22 outdoors and correct in software.
Can I extend or shorten the transducer cable?
The 2.5 m lead is matched to the drive electronics; modest extensions (a meter or two of decent coax/twisted pair, soldered and sealed) usually work but can cost range, and cutting it short is safe. If you need the sensor far from the MCU, the better pattern is: keep the capsule-to-board lead stock, and extend the 4-wire logic side — or use the UART mode, which tolerates long runs happily.

Related Tutorials