Ultrasonic icon indicating copy to clipboard operation
Ultrasonic copied to clipboard

Library doesn't work with new Seead Ultrasonic Distance Ranger V2

Open benpaddlejones opened this issue 11 months ago • 7 comments

Describe the bug Code loads, Serial monitor prints line statements but measurement value is always 0

Code to reproduce

#include <Ultrasonic.h>

Ultrasonic myUltrasonicSensor(5);
int distance;

void setup() {
  Serial.begin(9600);
}

void loop() {
  // Pass INC as a parameter to get the distance in inches
  distance = myUltrasonicSensor.read();
  
  Serial.print("Distance in CM: ");
  Serial.println(distance);
  delay(1000);
}

Wiring Connected to a Seead Senor Shield

Expected behavior As Sensor is moved distance value should show distance to object

Error message none

Context (please complete the following information):

  • OS: [e.g. Windows x64]
  • IDE version: [e.g. Arduino 1.8.5]
  • Sensor: [e.g. HC-SC04]
  • Library version [e.g. 2.1.0]

benpaddlejones avatar Jul 14 '23 01:07 benpaddlejones

Ths is the Library the unit uses: https://github.com/Seeed-Studio/Seeed_Arduino_UltrasonicRanger

benpaddlejones avatar Jul 14 '23 09:07 benpaddlejones

Hello, @benpaddlejones!

Thank you very much for sharing this issue.

Could you give me a link to the sensor you are using? If that's what I'm thinking, unfortunately I don't have any here with me to test.

However, Seed itself provides a library for ultrasound that uses a strategy to measure distance very similar to this one. Could you try this library and tell me if the sensor is behaving correctly with it?

Thank you very much!

ErickSimoes avatar Jul 14 '23 15:07 ErickSimoes

Hi Erick Sensor is version 2.0 listed in the Seead documentation here: https://wiki.seeedstudio.com/Grove-Ultrasonic_Ranger/

Yes it works perfectly with the Seead library (same link you shared) and sample code provided in the documentation.

Happy to help with any testing my end.

Be great if you can solve as I would rather just use one library for both our schools Seead Grove ultrasonic senors and generic 4 pin ultrasonic senors.

Ben

benpaddlejones avatar Jul 15 '23 00:07 benpaddlejones

Great, Ben!

This week I'm going to see if I can get one of these sensors in the lab where I work, but I already bought one of these and now I'm going to wait for it to arrive to do the necessary tests and adjustments (it may take a while due to the delivery time here to Brazil).

As soon as I update it, I'll let you know here.

Thanks!

ErickSimoes avatar Jul 15 '23 15:07 ErickSimoes

@benpaddlejones, would you be able to test version 2.1.0 of the library?

I think the addition of a delay() could be causing this issue you are experiencing.

ErickSimoes avatar Jul 15 '23 16:07 ErickSimoes

Hi Erick I can confim 2.1.0 works perfectly using the example code in the library. Ben

benpaddlejones avatar Jul 15 '23 23:07 benpaddlejones

Hi Erick Did your sensor arrive in the post or still on the way? Ben

benpaddlejones avatar Aug 26 '23 05:08 benpaddlejones