OlivierLD / raspberry-coffee

JVM related (Java, Groovy, Scala, Kotlin, etc) samples for the Raspberry PI, relying on PI4J. IoT and friends.
http://raspberrypi.lediouris.net/
111 stars 38 forks source link

HC_SR04 x10 times smaller distance #7

Closed brasta78 closed 6 years ago

brasta78 commented 6 years ago

returning x10 smaller distance that it is

OlivierLD commented 6 years ago

What version are you using, pure Java or JNI? Have you seen the doc at https://github.com/OlivierLD/raspberry-pi4j-samples/blob/master/RangeSensor/README.md ? What range of distances are you talking about?

brasta78 commented 6 years ago

I'm using JAVA. I have 2 other java class for testing HC-SR04 and both return correct result. HC-SR04.java return exactly x10 smaller My testet range was 187cm

OlivierLD commented 6 years ago

I'll make some tests. Could you send the java classes you use for testing? Also see the document at https://github.com/OlivierLD/raspberry-pi4j-samples/blob/master/RangeSensor/README.md Have you tried to use JNI_HC_SR04.java instead of HC_SR04.java ?

brasta78 commented 6 years ago

these classes return exact result https://gist.github.com/rutgerclaes/6713672 https://github.com/oksbwn/Ultrasonic-Sesnor-With-Raspberry-Pi/blob/master/Code/src/Main.java

JNI_HC_SR04.java dindn't tested

OlivierLD commented 6 years ago

Fixed! Thanks to @brasta78 .