Specifications
| Sensing element | RCWL-9610A with a 40 kHz transmit and receive pair |
|---|---|
| Supply voltage | 3.3 V to 5 V |
| Supply current | 2 to 3 mA typical at 5 V; the listing rates it at 15 mA |
| Interfaces | GPIO, I2C, UART and 1-Wire, chosen by two solder bridges |
| I2C address | 0x57, fixed |
| UART | 9600 baud |
| Range | 2 cm to about 3 m; 4 m in ideal conditions |
| Accuracy | About 1 cm under a metre, resolving about 0.3 cm |
| Beam angle | About 15 degrees |
| Measurement cycle | 50 ms in GPIO mode, 100 ms on a bus |
| Operating temperature | −40 to 90 °C |
| Board | 46.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.
| Mode | J1 | J2 | ECHO becomes | TRIG becomes |
|---|---|---|---|---|
| GPIO | open | open | Echo pulse | Trigger |
| I2C | short | open | SDA | SCL |
| UART | open | short | TX | RX |
| 1-Wire | short | short | unused | Data |
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.
| Pin | GPIO | I2C | UART | 1-Wire |
|---|---|---|---|---|
| GND | Ground | |||
| VCC | 3.3–5 V | |||
| Echo | Echo | SDA | TX | not used |
| Trig | Trigger | SCL | RX | Data |
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.
}from machine import Pin, time_pulse_us
import time
trig = Pin(9, Pin.OUT)
echo = Pin(10, Pin.IN)
while True:
trig.off(); time.sleep_us(2)
trig.on(); time.sleep_us(500)
trig.off()
us = time_pulse_us(echo, 1, 25000) # returns negative on timeout
print("no echo" if us < 0 else "%.1f cm" % ((us / 2) * 0.0343))
time.sleep_ms(100)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.