شحن مجاني للأوردرات فوق
1000 ج
رمضان كريم
+
Distance Measurement with Separate Waterproof Probe
The Waterproof Ultrasonic Sensor features a separate waterproof probe connected to a control board, making it ideal for outdoor or wet environment applications. Using ultrasonic waves, it accurately measures distances from 2cm to 4.5m with a resolution of 0.3cm, even in challenging conditions.
Key FeaturesIP67 rated probe for wet environments
2cm-450cm range with 3mm resolution
Analog voltage and digital PWM signals
Works with 3.3V or 5V systems
| Operating Voltage | 3.3V – 5V DC |
|---|---|
| Measurement Range | 2cm – 450cm |
| Resolution | 0.3cm |
| Frequency | 40kHz |
| Output Signals | Analog voltage (0-VCC) and PWM |
| Probe Protection | IP67 waterproof rating |
| Operating Temperature | -10°C to +70°C |
| Cable Length | 1m (standard, customizable) |

| Pin | Label | Description | Arduino Connection |
|---|---|---|---|
| 1 | VCC | Power (3.3V-5V) | 5V |
| 2 | GND | Ground | GND |
| 3 | OUT | Analog output (0-VCC) | A0 |
| 4 | PWM | Digital PWM output | D2 |
| 5 | TRIG | Trigger input (optional) | D3 |
// Basic Connections: // VCC → 5V // GND → GND // OUT → A0 (analog input) // PWM → D2 (digital input) // Optional trigger: // TRIG → D3 (digital output) // Keep the control board in a dry location // Only the waterproof probe should be exposed
// Waterproof Ultrasonic Sensor Basic Example
const int analogPin = A0;
const int pwmPin = 2;
void setup() {
Serial.begin(9600);
pinMode(pwmPin, INPUT);
}
void loop() {
// Read analog output (0-VCC corresponds to 0-max distance)
int analogValue = analogRead(analogPin);
float analogDistance = map(analogValue, 0, 1023, 0, 450); // cm
// Read PWM pulse width (pulse duration in μs corresponds to distance)
float pulseWidth = pulseIn(pwmPin, HIGH);
float pwmDistance = pulseWidth / 58.0; // Convert to cm
Serial.print("Analog Distance: ");
Serial.print(analogDistance);
Serial.print(" cm | PWM Distance: ");
Serial.print(pwmDistance);
Serial.println(" cm");
delay(200);
}
// Manual trigger control
void triggerMeasurement() {
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
}
// More precise timing control than automatic mode
// Manage multiple sensors with trigger pins
void readSensors() {
triggerSensor1();
delay(50); // Allow time for measurement
float dist1 = readDistance(SENSOR1_PIN);
triggerSensor2();
delay(50);
float dist2 = readDistance(SENSOR2_PIN);
}
// Smooth readings with moving average
const int numReadings = 5;
float readings[numReadings];
int index = 0;
float smoothDistance(float newDistance) {
readings[index] = newDistance;
index = (index + 1) % numReadings;
float total = 0;
for (int i = 0; i < numReadings; i++) {
total += readings[i];
}
return total / numReadings;
}
// Detect obstacles within threshold
bool checkObstacle(float threshold) {
float distance = readDistance();
return distance < threshold;
}
void loop() {
if (checkObstacle(30.0)) { // 30cm threshold
activateAlarm();
}
}
No account yet?
Create an Account
Recent Comments