ErickSimoes / Ultrasonic

Minimalist library for Ultrasonic Module HC-SR04, PING))) and Seeed SEN136B5B to Arduino
MIT License
137 stars 65 forks source link

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

Open benpaddlejones opened 1 year ago

benpaddlejones commented 1 year ago

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):

benpaddlejones commented 1 year ago

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

ErickSimoes commented 1 year ago

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!

benpaddlejones commented 1 year ago

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

ErickSimoes commented 1 year ago

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 commented 1 year ago

@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.

benpaddlejones commented 1 year ago

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

benpaddlejones commented 1 year ago

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