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 = Wire.read(); // receive high byte (overwrites previous reading)
reading117 = reading117 << 8; // shift high byte to be high 8 bits
reading117 |= Wire.read(); // receive low byte as lower 8 bits
Serial.print("Sensor 117...");
Serial.println(reading117); // print the reading
}
}