Hi
I know there are a lot of forums and discussions on the sensor for V1 and V2. I recently ordered one from my local retailer and got the V3 sensor which seems very similar to the V2. Here is the link for the sensor (https://www.aliexpress.com/item/32863960886.html)
I have tried a lot of code samples and tried using different delays for the trigger pulses but there is no improvement. I constantly keep getting 0 cm readings when I use NewPing library and 3cm or 1624cm if I am not using any library. Even tried with using an INPUT_PULLUP sketch but it is also not working.
I even tried connecting a resistor between 5V Vcc and echo pin as I read on some forums but all I get is 0cm or some very large number which is obviously out of the range of the distance the sensor works with.
A few questions before I rule out that the sensor board is faulty.
- When I connect the 5V Vcc and trigger the light on the sensor board starts blinking, should it do that without the ground connected?
- I have tried testing the sensor board for short circuits which I am not an expert of but what I was suprised to see was that the probe jack when it is not connected on the board shows that is fully closed on the multimeter continuity. Can this mean that the board is faulty?
Sharing my sketch below for reference although I have tried many variations of it available online.
#define ECHOPIN 12// Pin to receive echo pulse
#define TRIGPIN 13// Pin to send trigger pulse
void setup(){
Serial.begin(9600);
pinMode(ECHOPIN, INPUT_PULLUP);
pinMode(TRIGPIN, OUTPUT);
digitalWrite(ECHOPIN, HIGH);
}
void loop(){
digitalWrite(TRIGPIN, LOW); // Set the trigger pin to low for 2uS
delayMicroseconds(2);
digitalWrite(TRIGPIN, HIGH); // Send a 10uS high to trigger ranging
delayMicroseconds(10);
digitalWrite(TRIGPIN, LOW); // Send pin low again
int distance = pulseIn(ECHOPIN, HIGH,26000); // Read in times pulse
distance= distance/58;
Serial.print(distance);
Serial.println(" cm");
delay(50);// Wait 50mS before next ranging
}
I am stuck on this for a day now should I order a new one or not. The idea was to use this in my water tank to turn on the main pump when water drops below certain level with probe being on top and measuring the distance of a float.
The image attached shows the points that are short and show continuity on multimeter, but the sensor probe somehow still produces clicking sounds which shows that it is being operated.