__How do you make a range sensor using one transducer:__

- [EZ01 ultrasonic sensor][1] is a *42kHz* transducer
- Arduino-based

[![Datasheet][2]][2]

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][3]][3]

---

__How do you waterproof electronic sensors?__


 - [How to package a sensor watertight in a DIY environment?][4]

→ silicone heat shrink tubing and waterproof epoxy 

There are $13 waterproof ultrasonic sensors on eBay ($15 on Amazon). As Chris Stratton says, the **EZ01 is not designed to work in aquatic environments.** After all, water is 850 times denser than air. 

---

__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
     
    }


  [1]: https://www.maxbotix.com/documents/LV-MaxSonar-EZ_Datasheet.pdf
  [2]: https://i.sstatic.net/ZYE9g.png
  [3]: https://i.sstatic.net/4wVSS.png
  [4]: https://electronics.stackexchange.com/questions/96329/how-to-package-a-sensor-watertight-in-a-diy-environment