JSN-SR04T with a Raspberry Pi Pico

A waterproof 40 kHz ultrasonic rangefinder that measures distance with a single sealed transducer and is drop-in compatible with HC-SR04 trigger/echo code.

JSN-SR04T, A waterproof 40 kHz ultrasonic rangefinder that measures distance with a single sealed transducer and is drop-in compatible with HC-SR04 trigger/echo code.
In short

The JSN-SR04T wants 5 V, which the Raspberry Pi Pico offers only on VBUS while USB powers it; TRIG comes from GP0 and ECHO returns on GP1. Powered at 5 V, ECHO swings to 5 V, so on the Pico it passes through a divider before GP1, as the page's ECHO row shows.

Wiring the JSN-SR04T to the Raspberry Pi Pico

Pin by pin.

JSN-SR04TRaspberry Pi PicoNote
VCCVBUS
TRIGGP0
ECHOGP1through a 1 kΩ resistor, with a 2 kΩ resistor from the board pin to GND: a divider that brings the 5 V echo down to 3.3 V
GNDGND
  • VCC is on VBUS, which gives about 5 V only while the board is powered from USB.

What to know on the Raspberry Pi Pico

  • VBUS is the micro-USB input: nominally 5 V, and 0 V when USB is not connected. Running from a battery on VSYS, the sensor loses power unless you feed it 5 V another way.Raspberry Pi Pico datasheet, release 21, p. 8
  • Put a 1 kOhm resistor from ECHO toward GP1 and 2 kOhm from GP1 to GND, so the 5 V pulse arrives near 3.3 V; the RP2040 rates its pins to IOVDD + 0.5 V.RP2040 datasheet, section 5.5.3.1
  • TRIG needs a pulse of 20 µs or more on the V3.0 board; the sketch's 20 µs pulse from GP0 at 3.3 V is enough to start it.ProtoSupplies JSN-SR04T V3.0 documentation
  • Leave at least 60 ms between readings; the sensor draws 30 mA while measuring, which USB's VBUS supplies easily.ProtoSupplies JSN-SR04T V3.0 documentation

JSN-SR04T code for the Raspberry Pi Pico

Compiled for rp2040:rp2040:rpipico on 2026-10-30.

No library needed
// JSN-SR04T on Raspberry Pi Pico: wiring and a free simulation at https://www.tinkered.ai/components/jsn-sr04t/raspberry-pi-pico
const int TRIG = 0, ECHO = 1;
void setup() { Serial.begin(115200); pinMode(TRIG, OUTPUT); pinMode(ECHO, INPUT); }
void loop() {
  digitalWrite(TRIG, LOW); delayMicroseconds(2);
  digitalWrite(TRIG, HIGH); delayMicroseconds(20); digitalWrite(TRIG, LOW);
  unsigned long us = pulseIn(ECHO, HIGH, 40000UL);   // 0 = no echo within ~6.8 m
  if (us == 0) Serial.println("out of range");
  else { Serial.print(us / 58.0, 1); Serial.println(" cm"); }
  delay(100);
}

JSN-SR04T on the Raspberry Pi Pico: questions

Can I run the JSN-SR04T from the Pico's 3V3?

Its V3.0 board is listed for 3.0 V to 5.5 V, but its vendor calls 3.3 V operation unreliable and recommends 5 V (ProtoSupplies documentation). On the Pico that is VBUS, on USB power.

Do I need a divider on ECHO with a Pico?

Yes. At 5 V supply ECHO swings to 5 V, above the RP2040's IOVDD + 0.5 V limit (RP2040 datasheet, section 5.5.3.1). A 1 kOhm / 2 kOhm divider brings it near 3.3 V.

What is the closest distance it reads?

About 23 cm (ProtoSupplies documentation). For short ranges on a Pico, a VL53L0X on I2C fits better.

Keep going

For AI assistants

This guide as plain Markdown. /components/jsn-sr04t/raspberry-pi-pico.md

What will you build with it?