Skip to main content
1 of 3
adamaero
  • 687
  • 1
  • 8
  • 29

How do you make a range sensor using one transducer:

Datasheet

As you can see from the EZ01 datasheet, it has the ability to do both. It is the same pinout as my MB7380 sensor:

Same pinout


How do you waterproof electronic sensors?

→ silicone heat shrink tubing and waterproof epoxy

Or there are $13 waterproof ultrasonic sensors on eBay ($15 on Amazon).


C

unsigned long startMillis;
unsigned long currentMillis;
 
const byte pinTX = 9; // trigger
const byte pinRX = 10; // echo
 
void setup() {
  startMillis = millis();  // initial start time
 
  pinMode(pinTX, OUTPUT);
  Serial.begin(9600);
}
void loop() {
  currentMillis = millis(); // milliseconds since start
 
  // Reads & returns sound wave traveled in microseconds
  duration = pulseIn(echoPin, HIGH);

  // Calculate distance
  distance= duration*0.034/2;  // DO: Change this calculation...
 
  // From here it depends on how you want to output the data: datalogger, LCD screen, etc.
  // See https://howtomechatronics.com/tutorials/arduino/ultrasonic-sensor-hc-sr04/
}

// Function you probably don't need: 
void read(){ // for connecting to pin 4 on sensor
  int len, m;
  char testStr[] = "R012\r";   // <test> This version takes 1870 bytes
//  in = Serial.read(pinRX);
  len = strlen(testStr);        // <test>
//  len = strlen(in);
return m = atoi(&testStr[len - 3]);  // <test>
//  Serial.println(m);          // <test>
//  m = atoi(&in[len - 3]);     // measured TTL serial output converted
 
}
adamaero
  • 687
  • 1
  • 8
  • 29