Build a Tank Volume Reader for Under $30 using ESP32

The Internet of Things has brought a lot of formerly complex device applications into the homes of many craft brewers and winemakers. Applications with level sensors have been used for decades in large refineries, water treatment plants, and chemical plants. With sensor prices falling, now both industrial and DIY can monitor the volume of any tank, barrel, or canister.

The sensors available on the open market can sense almost anything and are classified accordingly. The sensor used for measuring humidity is termed humidity sensor, pressure called pressure sensor, distance is called position sensors, and so on. In a similar fashion, the sensor used for measurement of fluid levels is called a level sensor.

The level sensors are used to measure the level of the free-flowing substances. Such substances include liquids like water, oil, slurries, etc as well as solids in granular/powder form (solids which can flow). These substances tend to get settle in the container tanks due to gravity and maintain their level in rest state.

In this guide you will learn how to build your own home-made level, temperature, and humidity sensor. Also included are instructions for you newly collected data to be utilized via Ubidots, an application enablement platform.

Wiring and Casing

The sensor HC-SR04 (Ultrasonic Sensor) works with 5V logic. Please, follow the table and diagram below to make the correct connections between the ESP32 and the ultrasonic sensor :

Please, follow the table below to make the correct connections between the ESP32 and the DHT11 sensor (Temperature and Humidity Sensor):

I built a small prototype with a scale-sized tank to shows the functions of the sensor, but a final prototype with it case should look like this:

As you can see the ultrasonic sensor should be at the top of the tank, so with it we’re going to be able to measure the distance between the up part of the tank and the endpoint of the substance:

Place the temperature and humidity sensors to monitor an environment.

To program your connected device, connect with the Arduino IDE.

Before beginning with the ESP32, set up your board with the Arduino IDE. If you are not familiar with a board set up, please reference the article below and follow step-by-step until you’ve compiled the board:

Once you’ve pasted your code and assigned the appropriate wifi, verify in the Arduino IDE. To verify, in the top left corner of our Arduino IDE you will see the below icons. Choose the Check Mark icon to verify any code.

Once verified, you will receive a “Done compiling” message in the Arduino IDE.

Once uploaded, you’ll receive a “Done uploading” message in the Arduino IDE.

With this, the sensor is now sending the data to the Ubidots Could!

Management of the data in Ubidots

If your device is correctly connected you will see a new device created within your device section in your Ubidots application. The name of the device will be “esp32“, also inside the device, you will see the variables distance, humidity, and temperature:

If you desire to change your device and variable names to a more friendly one, please reference this article: