The objective of water measurement is to quantify the volume, flow rate, or quality of water for specific purposes. These objectives can vary depending on the context, such as agriculture, environmental monitoring, industrial processes, or water resource management. Common objectives include:
1- Resource Management:
Monitoring water supply in reservoirs, rivers, or aquifers.
Ensuring sustainable usage of water resources.
2- Irrigation Efficiency:
Measuring water delivered to fields to optimize crop irrigation.
Reducing water wastage and improving agricultural productivity.
3- Environmental Protection:
Monitoring river flows and water levels to prevent flooding.
Assessing water quality to detect pollution or ecological changes.
4- Industrial Processes:
Measuring water consumption in manufacturing.
Monitoring water flow for process optimization.
5- Billing and Regulation:
Ensuring accurate metering for water usage billing in residential, commercial, or industrial sectors.
Enforcing regulatory compliance for water extraction or discharge.
6- Flood and Drought Management:
Monitoring water levels to predict and mitigate floods.
Assessing water availability during droughts.
7- Research and Development:
Supporting scientific studies on hydrology, climate change, or water ecosystems.
Evaluating the efficiency of water conservation techniques or technologies.
Using an ESP32 microcontroller to measure water level with simple components like wires, resistors, and a bottle involves creating a basic water-level sensor system. The system measures water level based on electrical conductivity and communicates the data via Bluetooth to an app created in MIT App Inventor.
Water Conductivity: Water conducts electricity, so when the water level touches a wire probe, it completes the circuit.
Voltage Divider: By using resistors, the ESP32 reads the varying voltage levels corresponding to different water heights.
Bluetooth Communication: The ESP32 sends water level data to the app via Bluetooth.
ESP32 Microcontroller
Role: Acts as the brain of the system. It reads the input from the water-level probes (wires) and communicates the data to a mobile app via Bluetooth.
Wires (Probes)
Role: Serve as water-level sensors inside the bottle.
Working Principle:
Water completes the circuit when it touches a wire, allowing a small current to flow, which changes the voltage at the input pin.
The voltage level corresponds to the height of water in the bottle.
Resistors
Role:
Protect the ESP32 by limiting the current flow in the circuit.
Create a voltage divider circuit for stable and measurable signals.
Bottle
Role:
Acts as the water container for the measurement system.
Provides a controlled environment to test water-level detection.
Helps simulate real-world water-level monitoring scenarios.
First We drill 5 holes in the bottle. Then we fix a connection wire in each hole.
Then we connect:
1- the lowest jumper wire to the 3.3V pin of ESP32
2- the 2nd wire connecting to pin D33 of ESP32
3- the 3rd wire to pin D32 of ESP32
4- the 4th wire to pin D35 of ESP32
5- the 5th jumper wire to pin D34 of ESP32
Here are the micropython programs that can detect the level of water filled in the bottle and send this information to the Smartphone via Bluetooth.
1- Flash your ESP32 with MicroPython using this file esp32-20210902-v1.17.bin.
2- import this two libraries : ble_uart_peripheral.py , ble_advertising.pyfor communication to Smartphone.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
from esp_ble_uart import * import time from machine import Pin, ADC from machine import freq #freq(160000000) level_1 = ADC(Pin(33)) level_1.atten(ADC.ATTN_11DB) level_2 = ADC(Pin(32)) level_2.atten(ADC.ATTN_11DB) level_3 = ADC(Pin(35)) level_3.atten(ADC.ATTN_11DB) level_4 = ADC(Pin(34)) level_4.atten(ADC.ATTN_11DB) nom = 'ESP32-ble-uart-gcworks' UUID_UART = '6E400001-B5A3-F393-E0A9-E50E24DCCA9E' UUID_TX = '6E400003-B5A3-F393-E0A9-E50E24DCCA9E' UUID_RX = '6E400002-B5A3-F393-E0A9-E50E24DCCA9E' val_rx = "12" uart = Bleuart(nom, UUID_UART, UUID_TX, UUID_RX) uart.close() def rcp_rx(): global val_rx if uart.any(): while uart.any(): val_rx = uart.read().decode().strip() print('sur rx: ', val_rx) def env_tx(val_tx): uart.write(str(val_tx) + '\n') print("tx", val_tx) send_1=0 send_2=0 send_3=0 send_4=0 while True: #uart.irq(handler=rcp_rx) level_1_value = level_1.read() print("niveau 1",level_1_value) level_2_value = level_2.read() print("niveau 2",level_2_value) level_3_value = level_3.read() print("niveau 3",level_3_value) level_4_value = level_4.read() print("niveau 4",level_4_value) if (level_1.read()==0) and (level_2.read()==0) and (level_3.read()==0) and (level_4.read()==0): env_tx("0") # send water level 0 to smartphone send_1=0 if (level_1.read()!=0) and (level_2.read()==0) and (level_3.read()==0) and (level_4.read()==0) and send_1==0: env_tx("25") # send water level 1 to smartphone send_1=1 send_2=0 if (level_1.read()!=0) and (level_2.read()!=0) and (level_3.read()==0) and (level_4.read()==0) and send_2==0: env_tx("50") # send water level 2 to smartphone send_1=0 send_2=1 send_3=0 if (level_1.read()!=0) and (level_2.read()!=0) and (level_3.read()!=0) and (level_4.read()==0) and send_3==0: env_tx("75") # send water level 3 to smartphone send_2=0 send_3=1 send_4=0 if (level_1.read()!=0) and (level_2.read()!=0) and (level_3.read()!=0) and (level_4.read()!=0) and send_4==0: env_tx("100") # send water level 4 to smartphone send_3=0 send_4=1 time.sleep_ms(500) |
This code continuously reads the analog signals from the input pins, converts the voltage levels into water height values and sends the water level data via Bluetooth.
Design the Interface:
1- Create sliders, labels, or progress bars to show water levels.
2- Add a "Connect" button to establish Bluetooth communication.
Here is the Designer part of the application with App Inventor :
Programming the application with App Inventor:
a- Use the available blocks in App Inventor to establish a Bluetooth connection with the ESP32.
- Starting with Android 12, Bluetooth permissions have been enhanced to improve security and user data protection. This is why we must declare the authorizations that your application needs in the AndroidManifest.xml file. For Bluetooth, you'll need to include ACCESS_FINE_LOCATION, BLUETOOTH_SCAN, and possibly BLUETOOTH_CONNECT permissions, depending on the features you're using.
b- Use these programming blocks to connect the smartphone to the ESP32 board via Bluetooth:
c- Use these programming blocks to Continuously receive data and parse the water levels.
Download project Download apk fileEducational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.
Zaouiet Kontech-Jemmel-Monastir-Tunisia
+216 92 886 231
medaliprof@gmail.com
Robotic site created by MedAli-Teacher info