Ultrasonic Sensor only detects max 52cm distance + issues with library

Im using Ultrasonic Sensor With Qwiic and NULA Mini ESP32-C6 connected by Qwiic

I have some errors with the ultrasonic measures the highest value i can get from getDistance() is 1053

code snipets from example:
#include “Ultrasonic-distance-sensor-easyC-SOLDERED.h”

hc.getDistance()
hc.getDuration()

Outpout:
Distance: 1053. Time: 61968

one issues is that this getDistance shoud return distance in cm but it returns the milimeter distance in both ways so this is needed to get cm
int distance = hc.getDistance() / 20; (10 to get cm and 2 to not get both ways)

the second is when i move the object more then 50cm away the counter resets to 0, both distance and the time.

so if i mesure something at 51 cm i get 1 cm instead, 52 cm i get 2 cm.

looks like the internal library is reading only 2 registers so with 16bits we cant get bigger values

the documentation here

says it can measure to 4meters currently this is not really true as it tops out at 0.5meters

Hello @petar_kekez

Thank you for bringing this to our attention. We have come to the conclusion that the Ultrasonic Sensors were sent with incorrectly configured firmware flashed to them. We are very sorry for the inconvenience.

There is a way to reprogram the chip using the accessible UPDI pins on the breakout itself, this requires an UPDI programmer such as an Atmel ICE device or with using a microcontroller as a jtag2UPDI device: GitHub - ElTangas/jtag2updi: UPDI programmer software for Arduino (targets Tiny AVR-0/1/2, Mega AVR-0 and AVR-DA/DB MCUs) · GitHub
This does require some soldering work. You can find the firmware here.

You are, of course, eligible for a replacement, please contact us via our email hello@soldered.com with your order number and either a link to this forum thread or explaining the issue.