Stufin
Home Quick Cart Profile

Waterproof Ultrasonic Sensor

Buy Now

Measurement Range

20 cm to 400 cm (4 meters)

Accurancy

1% of measured distance

Resolution

1 cm

Output Interfaces

Analog voltage (0-5V), PWM, UART, I2C

Power Supply

5V DC

Power Consumption

20 mA (average), 50 mA (peak)

Operating Temperature

-20C to 70C

Storage Temperature

-30C to 80C

Humidity

5% to 95% RH

Weight

20 grams

Dimensions

Diameter30 mm, Height: 15 mm

Applications

The Waterproof Ultrasonic Sensor is suitable for a wide range of applications, including

Obstacle detection and avoidance

Proximity detection

Level measurement

Distance measurement

Object detection

Robotics

Automotive systems

Industrial automation

Weather stations

Agriculture monitoring systems

Pinout and Dimensions

For detailed pinout and dimension information, please refer to the datasheet or contact the manufacturer.

Pin Configuration

  • Waterproof Ultrasonic Sensor Documentation
  • Pin Description:
  • The Waterproof Ultrasonic Sensor has 4 pins, each with a specific function. Below is a detailed explanation of each pin:
  • Pin 1: VCC (Power Supply)
  • Function: Provides power to the sensor
  • Description: This pin connects to a power source, typically a voltage regulator or a battery, to supply power to the sensor.
  • Voltage Range: Typically 5V, but can operate within 4.5V to 5.5V
  • Connection: Connect to a power source (e.g., Arduino's 5V pin or a dedicated power supply)
  • Pin 2: Trig (Trigger)
  • Function: Initiates the ultrasonic measurement process
  • Description: This pin sends a trigger signal to the sensor to initiate the ultrasonic measurement process.
  • Signal Type: Digital output (typically 5V)
  • Connection: Connect to a digital output pin on a microcontroller (e.g., Arduino's digital pin)
  • Pin 3: Echo (Output)
  • Function: Provides the measured distance data
  • Description: This pin outputs the measured distance data in the form of a digital signal.
  • Signal Type: Digital output (typically 5V)
  • Connection: Connect to a digital input pin on a microcontroller (e.g., Arduino's digital pin)
  • Pin 4: GND (Ground)
  • Function: Provides a common ground reference
  • Description: This pin connects to the ground of the power source and the microcontroller to provide a common reference point.
  • Connection: Connect to the GND pin on a power source and a microcontroller (e.g., Arduino's GND pin)
  • Connection Structure:
  • To connect the Waterproof Ultrasonic Sensor to a microcontroller like Arduino, follow this structure:
  • 1. Connect VCC (Pin 1) to a power source (e.g., Arduino's 5V pin)
  • 2. Connect Trig (Pin 2) to a digital output pin on the microcontroller (e.g., Arduino's digital pin 2)
  • 3. Connect Echo (Pin 3) to a digital input pin on the microcontroller (e.g., Arduino's digital pin 3)
  • 4. Connect GND (Pin 4) to the GND pin on both the power source and the microcontroller (e.g., Arduino's GND pin)
  • Example Connection Diagram:
  • ```
  • +---------------+
  • | Waterproof |
  • | Ultrasonic |
  • | Sensor |
  • +---------------+
  • | |
  • | |
  • V V
  • +---------------+ +---------------+
  • | Arduino | | Power Source |
  • | (e.g., Uno) | | (e.g., 5V) |
  • +---------------+ +---------------+
  • | | |
  • | | |
  • VCC (5V) ---|-------|-------------|--- 5V
  • Trig (D2) ---|-------| D2 (Output) |
  • Echo (D3) ---|-------| D3 (Input) |
  • GND (GND) ---|-------|--- GND (GND) |
  • | | |
  • +---------------+ +---------------+
  • ```
  • Note:
  • Make sure to use a suitable power supply and follow the recommended voltage range to ensure the sensor's reliability and accuracy.
  • Consult the datasheet and documentation of your specific microcontroller and ultrasonic sensor for specific connection details and guidelines.
  • Always follow proper safety precautions when working with electronic components.

Code Examples

Waterproof Ultrasonic Sensor Documentation
Overview
The Waterproof Ultrasonic Sensor is a durable and weather-resistant sensor designed to measure distances up to 4 meters with high accuracy. It operates by emitting high-frequency ultrasonic sound waves and measuring the time it takes for the sound to bounce back from an object. This sensor is ideal for outdoor and industrial applications where moisture and water exposure are a concern.
Pinout
VCC: 5V power supply
 GND: Ground
 TRIG: Trigger input
 ECHO: Echo output
Technical Specifications
Operating Voltage: 5V
 Operating Frequency: 40kHz
 Measurement Range: 2cm to 400cm
 Accuracy: 1cm
 Waterproof Rating: IP67
Code Examples
### Example 1: Basic Distance Measurement using Arduino
This example demonstrates how to use the Waterproof Ultrasonic Sensor with an Arduino board to measure the distance from the sensor to an object.
```c
const int trigPin = 2;  // Trigger pin
const int echoPin = 3;  // Echo pin
void setup() {
  Serial.begin(9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
}
void loop() {
  int duration, distance;
  
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  
  duration = pulseIn(echoPin, HIGH);
  distance = duration  0.034 / 2;  // Convert time to distance
  
  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");
  
  delay(50);
}
```
### Example 2: Obstacle Detection using Raspberry Pi (Python)
This example demonstrates how to use the Waterproof Ultrasonic Sensor with a Raspberry Pi to detect obstacles within a certain range.
```python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
trigPin = 17
echoPin = 23
GPIO.setup(trigPin, GPIO.OUT)
GPIO.setup(echoPin, GPIO.IN)
def get_distance():
    GPIO.output(trigPin, False)
    time.sleep(0.01)
    GPIO.output(trigPin, True)
    time.sleep(0.00001)
    GPIO.output(trigPin, False)
    
    while GPIO.input(echoPin) == 0:
        pulse_start = time.time()
    
    while GPIO.input(echoPin) == 1:
        pulse_end = time.time()
    
    pulse_duration = pulse_end - pulse_start
    distance = pulse_duration  17000
    return distance
try:
    while True:
        distance = get_distance()
        if distance < 20:
            print("Obstacle detected!")
        else:
            print("No obstacle detected.")
        time.sleep(1)
except KeyboardInterrupt:
    GPIO.cleanup()
```
### Example 3: Measuring Water Level using ESP32 (MicroPython)
This example demonstrates how to use the Waterproof Ultrasonic Sensor with an ESP32 board to measure the water level in a tank.
```python
import machine
import time
trigPin = 26
echoPin = 25
machine.Pin(trigPin, machine.Pin.OUT)
machine.Pin(echoPin, machine.Pin.IN)
def get_distance():
    machine.Pin(trigPin, machine.Pin.LOW)
    time.sleep_us(2)
    machine.Pin(trigPin, machine.Pin.HIGH)
    time.sleep_us(10)
    machine.Pin(trigPin, machine.Pin.LOW)
    
    pulse_start = time.ticks_us()
    while machine.Pin(echoPin, machine.Pin.LOW):
        pass
    pulse_end = time.ticks_us()
    
    pulse_duration = time.ticks_diff(pulse_end, pulse_start)
    distance = pulse_duration  0.034 / 2
    return distance
while True:
    distance = get_distance()
    water_level = 100 - (distance / 400)  100
    print("Water level: {:.2f}%".format(water_level))
    time.sleep(1)
```
These examples demonstrate how to use the Waterproof Ultrasonic Sensor in various contexts, including distance measurement, obstacle detection, and water level measurement.