Ultrasonic code trouble

I am trying to use the ultrasonic RAK12007 with the RAK19007 base and RAK3172 core. the duration coming in is not reading correct. This is the basic code I am using the duration value is in the rounded 1,000. I am thinking it maybe something with the clock setting.

#include <Wire.h>

#define TRIG WB_IO6
#define ECHO WB_IO4
#define PD WB_IO5 //power done control (=1 power done,=0 power on)

unsigned long duration;

void setup()
{
Serial.begin(115200);
Wire.begin();
Wire.setClock(400000); // The sensor is listed to work up to 1 MHz I2C speed, but the I2C clock speed is global for all sensors on that bus so using 400kHz or 100kHz is recommended

pinMode(ECHO, INPUT); // Echo Pin of Ultrasonic Sensor is an Input
pinMode(TRIG, OUTPUT); // Trigger Pin of Ultrasonic Sensor is an Output
pinMode(PD, OUTPUT); // power done control pin is an Output
pinMode(LED_BLUE, OUTPUT); // The LED is an Output

digitalWrite(PD, LOW); //low = power on

Serial.println("========================");
Serial.println(" RAK12007 test");
Serial.println("========================");
}
void loop()
{
digitalWrite(LED_BLUE, HIGH);

digitalWrite(TRIG, LOW);
delayMicroseconds(2);
digitalWrite(TRIG, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG, LOW);

duration = pulseIn(ECHO, HIGH); // microseconds
Serial.print("duration - ");
Serial.println(duration);
delay(500);

digitalWrite(LED_BLUE, LOW);
}

This is the Serial.print;
10:28:25.691 → duration - 2000
10:28:26.207 → duration - 2000
10:28:26.675 → duration - 2000
10:28:27.191 → duration - 3000
10:28:27.660 → duration - 2000
10:28:28.160 → duration - 1000
10:28:28.630 → duration - 1000
10:28:29.122 → duration - 1000
10:28:29.639 → duration - 1000
10:28:30.141 → duration - 1000
10:28:30.610 → duration - 2000
10:28:31.126 → duration - 9000
10:28:31.609 → duration - 9000
10:28:32.112 → duration - 9000
10:28:32.583 → duration - 8000

Welcome to RAK forum @Flume ,

It seems that your output is clipped in 1000 interval. I already reported this scenario to our engineering team. I will get back to you whenever I got anything from the team.

I’m using firmware RAK3172-E_latest_final.hex

From here. Rak 3272S-Board RUI3 Arduino programming board - #4 by carlrowan

carlrowan Did you guys find anything out? I’m try to build a board and proof it out. If it works then Ill order 1000 chips.

Hi @Flume ,

The current pulsein precision for the RUI3 is currently at milliseconds. The team already found a way to improve to microsecond on RAK4630 module but not yet on RAK3172. It is currently on R&D. However I am not hopeful it will included in this coming FW update release. Likely, on 2023 update to be included once figured out.