How Does It Work?

The ultrasonic sensor reports the distance value in centimeters (cm) by default.

you could also use this sensor to monitor a salt tank level.

google ai overview search on laptop screen

You may follow our previous guide toinstall Home Assistant on Raspberry Pior an old laptop.

Step 2: Measure Tank Depth

you better measure the tank depth.

This is the distance that you better subtract from the total depth.

A selection of the shows available on (HBO) Max

Then go through this:

Now find thewaterlevelsensorproject and clickEdit.This opens thewaterlevelsensor.yamlfile.

In the file, copy and pastethis YAML code.

The steps are as follows:

After downloading the firmware, clickOpen ESPHome Web.

A split screen image showing the same photo with HDR enabled and disabled

ClickConnectand then snag the USB serial COM port where your NodeMCU, D1 Mini, or ESP32 is connected.

ClickInstall.ClickChoose File, browse to thewaterlevelsensor.binfirmware file, and clickInstall.

Once the firmware is flashed, disconnect the USB cable.

ultrasonic sensor connected to nodemcu tank cover

JSN-SR04 Ultrasonic Sensor

Vin

5V

Once the ultrasonic sensor is connected to the MCU, reconnect the USB cable.

ClickLogsunder thewaterlevelsensor.This will display the logs and data received by the sensor.

For the project, we used the SR04 sensor, which isnt waterproof.

how ultrasonic water level sensor works

We drilled two tiny holes and used a metal wire to keep the SR04 module attached to the cover.

Another bigger hole was made for the wires connected to the ultrasonic sensor.

You may keep both in one case and supply power to the NodeMCU.

jsn sr04 waterproof ultrasonic sensor with nodemcu

Also, ensure good Wi-Fi signal strength when you are installing the NodeMCU or the sensor.

Read our guide onhow to boost your Wi-Fi signal to extend the Wi-Fi range.

measure tank height to find the depth

select the microcontroller from the options

download the waterlevelsensor firmware

choose connected microcontroller to flash the esphome firmware

nodemcu connected to sr04 ultrasonic sensor

jsnsr04-connected-to-nodemcu

logs generated by waterlevelsensor displaying data

ultrasonic sensor installed on water tank cover