SRF02 in mm

good evening,

im working on a projekt using the ultrasonic sensors srf02. i wanted to ask if its possible somehow to make this kind of sensors to measure in mm.

it would be very helpful because im trying to get more exact results.
i tried changing the variable from int to float so i could see the decimal but it didnt really work.

do you have some tipps?

void USS117() {

Wire.beginTransmission(117); //0x74 vorne rechts
// but i2c adressing uses the high 7 bits so it’s 112
Wire.write(byte(0x00)); // sets register pointer to the command register (0x00)
Wire.write(byte(0x51)); // use 0x51 for centimeters
Wire.endTransmission(); // stop transmitting

// step 2: wait for readings to happen
delay(65); // datasheet suggests at least 65 milliseconds
Wire.beginTransmission(117); // transmit to device #112
Wire.write(byte(0x02)); // sets register pointer to echo #1 register (0x02)
Wire.endTransmission(); // stop transmitting

// step 4: request reading from sensor
Wire.requestFrom(117, 2); // request 2 bytes from slave device #112

// step 5: receive reading from sensor
if (2 <= Wire.available()) { // if two bytes were received
reading117 =; // receive high byte (overwrites previous reading)
reading117 = reading117 << 8; // shift high byte to be high 8 bits
reading117 |=; // receive low byte as lower 8 bits
Serial.print(“Sensor 117…”);
Serial.println(reading117); // print the reading

The device does not have an option to return mm. Also there does not seem to be an option to return fractions of cm. Why do think it returns something it does not?


because i need it for my project.

to get more exact results.

naderkh123123: because i need it for my project.

to get more exact results.

I guess the specifications for the device does not concern you?


The limitation is the frequency that common ultrasonic sensors are using, 40kHz. That, with the speed of sound, calculates to a resolution (measurement steps) of about 7.5mm. Leo..

Half a wavelength at 40kHz is 4.25mm, not 7.5mm. Since its measuring the start of a pulse train, in theory more precision than that is possible, but it will be somewhat sensitive to the nature of the reflecting surface.

Half a wavelength change in separation causes a full wavelength change in acoustic path for any reflection- based sensor. millimeter resolution with an HC-SR04 by detecting phase change.