TK50DIGITALI2CUARTONEWIREbeginner

Ultrasonic Distance Sensor

Distance by echo timing, on a chip that speaks four protocols and runs from 3.3 V. Soft and angled surfaces are where it quietly lies to you.

Comes in this kit — not sold separately

Specifications

Sensing elementRCWL-9610A with a 40 kHz transmit and receive pair
Supply voltage3.3 V to 5 V
Supply current2 to 3 mA typical at 5 V; the listing rates it at 15 mA
InterfacesGPIO, I2C, UART and 1-Wire, chosen by two solder bridges
I2C address0x57, fixed
UART9600 baud
Range2 cm to about 3 m; 4 m in ideal conditions
AccuracyAbout 1 cm under a metre, resolving about 0.3 cm
Beam angleAbout 15 degrees
Measurement cycle50 ms in GPIO mode, 100 ms on a bus
Operating temperature−40 to 90 °C
Board46.4 × 26.0 mm

What it is

A 40 kHz burst goes out, bounces off whatever is in front of the board, and comes back. The time between is proportional to distance: halve it, multiply by the speed of sound, and you have centimetres.

What makes this board different from the sensor it is named after is the chip doing that work. An RCWL-9610A runs from 3.3 V to 5 V and can hand you the result four different ways, where the classic HC-SR04 is a 5 V part with one interface. The board prints its own supply range on the back: 3.3V-5V.

There is no regulator and no level shifter here. VCC goes straight to the chip, and both signal pins are chip pins brought out to the header, so the logic level is whatever you feed the supply. On an ESP32 that means the 3V3 rail and four plain wires — no divider.

The four modes

Two solder pads on the left edge, J1 and J2, decide which protocol the sensor speaks. Both arrive open, which is GPIO — so an untouched board behaves exactly like an HC-SR04.

ModeJ1J2ECHO becomesTRIG becomes
GPIOopenopenEcho pulseTrigger
I2CshortopenSDASCL
UARTopenshortTXRX
1-WireshortshortunusedData

The table is printed on the board itself. J2 is the upper pad.

Pinout

Left to right on the back, pins pointing down. GND is the square pad.

PinGPIOI2CUART1-Wire
GNDGround
VCC3.3–5 V
EchoEchoSDATXnot used
TrigTriggerSCLRXData

Wiring

Four wires. GND to GND, VCC to 3V3 on a 3.3 V board or 5V on an Uno, and the two signals to any two pins. The row of four round holes above the header is an unfitted 2.0 mm connector on the same four nets, not a second pinout.

Example

GPIO mode, no library. Note the timeout on pulseIn: without it a missing echo blocks the sketch for a full second and then reads as zero centimetres.

#define TRIG 9
#define ECHO 10

void setup() {
  Serial.begin(115200);
  pinMode(TRIG, OUTPUT);
  pinMode(ECHO, INPUT);
  digitalWrite(TRIG, LOW);
}

void loop() {
  // The supported library holds TRIG high for 500 us. The 10 us used by every
  // HC-SR04 example also starts a measurement.
  digitalWrite(TRIG, HIGH); delayMicroseconds(500);
  digitalWrite(TRIG, LOW);

  // Time out at ~4 m of round trip. Without a limit, a missing echo blocks
  // for a full second and then reads as a valid measurement of nothing.
  long us = pulseIn(ECHO, HIGH, 25000UL);

  if (us == 0) {
    Serial.println("no echo");        // absorbed, angled away, or out of range
  } else {
    Serial.print((us / 2.0) * 0.0343, 1);   // cm at about 20 C
    Serial.println(" cm");
  }

  delay(100);   // A measurement cycle is 50 ms. Let the last burst die away.
}

Over a bus

In I2C or UART mode the chip does the timing and the arithmetic, and hands back three bytes holding the distance in micrometres, most significant byte first. Divide by 10 000 for centimetres.

The command is one byte — 0x01 over I2C at address 0x57, or 0xA0 over UART at 9600 baud — then a wait of about 150 ms, then three bytes back. There is no register map and no status flag.

Where to start

The handbook below takes the part from the first reading to the four modes and what it can honestly see. If you only read one page, make it the honest range: the 4 m on the box and the 2–3 m you should design to are both true, and the difference is what surfaces do to 40 kHz sound.

When it doesn’t work

The listing says HC-SR04. Is this an HC-SR04?
Not electrically. The chip is an RCWL-9610A, which runs from 3.3 V and speaks four protocols where an HC-SR04 needs 5 V and speaks one. It is pin-compatible in GPIO mode, so an old sketch runs unchanged — but the wiring advice written for an HC-SR04 does not apply, starting with the voltage divider.
Do I need a voltage divider on the ECHO line for an ESP32?
No. There is no regulator and no level shifter on this board, so the signal pins answer at whatever you feed VCC. Power it from the 3V3 rail and ECHO comes back at 3.3 V, straight into the pin. Powering it from 5V on a 3.3 V board is what would create the problem.
It reads zero, or a huge number, at random.
No echo came back. Soft or angled surfaces do this, and so does anything closer than 2 cm. Treat a timeout as 'unknown' rather than as a distance, and take the median of three readings.
Can I put two of them on one I2C bus?
No. The address is 0x57 and there is no pad or register to change it, so two sensors answer at once and neither reading survives. Give each sensor a pair of GPIO pins, or one pin each in 1-Wire mode.
Readings are consistently a few per cent out.
Temperature. The speed of sound changes about 0.6 m/s per degree, so a reading calibrated at 20 °C is out by roughly 3 % at 5 °C. Correct for it if the accuracy matters.
Which pin is the data wire in 1-Wire mode?
TRIG, not ECHO. The single wire carries the trigger out and the answer back on the pin marked TRIG/SCL/RX, and the ECHO pin is unused. This is the most common way to wire this board wrong.

The TK50 ultrasonic handbook

11 articles · about 55 minutes

This page is the reference: what the part is, what it is made of, and the questions people arrive already asking. The handbook is the walk — the same part in the order somebody actually meets it.

Sound, and the time it takes

2 articles

What the sensor actually measures, and why the part in this box is not the HC-SR04 its own listing is named after.

What is in the box

2 articles

Five identical boards, four pins, and the twelve lines that get a distance out of the first one.

Two bridges choose the protocol

2 articles

The table printed on the back of the board, what the two pads are actually wired to, and why the same two pins change name four times.

Asking over a bus

2 articles

One byte out, three bytes back, and the surprise that they are micrometres. Then which of the four modes a given project actually wants.

What it can honestly see

3 articles

The blind zone, the range worth designing to, the degrees per second of drift nobody mentions, and what to check when every reading is zero.

Edit this page — content/modules/ultrasonic-sensor.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

Ultrasonic Distance Sensor

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum