Monitor Water Levels using Bolt IoT
Introduction-
Water level monitoring is the process of measuring and recording the height or depth of
water in a particular location, such as a river, lake, reservoir, or well. This information is
used to monitor water levels for various purposes, including flood forecasting, irrigation
management, water resource management, and environmental monitoring.
There are various methods for water level monitoring, including:
1. Staff gauges: These are physical markings on a post or structure that indicate water
level heights.
2. Float sensors: These sensors are placed on the surface of the water and measure the
level based on the position of the float.
3. Pressure sensors: These sensors measure the pressure exerted by the water and
convert it to a water level reading.
4. Radar sensors: These sensors use radar technology to measure the distance from the
sensor to the water surface and convert it to a water level reading.
5. Ultrasonic sensors: These sensors use ultrasonic waves to measure the distance from
the sensor to the water surface and convert it to a water level reading.
Water level monitoring is important for many reasons, including the safety of people living
in flood-prone areas, management of water resources for irrigation and drinking water, and
monitoring of water levels for environmental conservation purposes.
Applications-
Water level monitoring has many important applications in different fields, including:
1. Flood forecasting and warning: Water level monitoring is essential for predicting and
issuing early warnings about potential floods in order to mitigate damage to life and
property. Flood forecasting models rely on accurate and timely water level data to
predict flooding.
2. Irrigation management: Water level monitoring helps farmers manage their
irrigation systems by providing information on water availability and usage. By
monitoring water levels, farmers can optimize their irrigation schedules and
minimize waste.
3. Drinking water management: Water level monitoring is crucial for managing drinking
water resources. By monitoring water levels, water managers can ensure that there
is an adequate supply of water for human consumption and take necessary
measures to protect the quality of the water.
4. Environmental monitoring: Water level monitoring is also used to monitor the health
of aquatic ecosystems, such as lakes, rivers, and wetlands. By measuring water levels
over time, researchers can identify changes in water availability and quality, as well
as the impact of climate change and human activities on aquatic ecosystems.
5. Dam safety: Water level monitoring is critical for monitoring the safety of dams and
reservoirs. By continuously monitoring water levels, engineers can detect any
abnormal changes in water levels that could indicate a potential failure of the dam
structure.
Overall, water level monitoring plays a crucial role in managing water resources and
ensuring the safety and sustainability of our environment and communities.
This sensor has been made such that it has a series of exposed mark lines connected to
GND. The sensor has a low resistance resistor. The resistor keeps the sensor value low till
the water shorts the sensor.
This sensor then changes the water detected to analog signal/ digital signal with the help of
Bolt IoT, and those analog values are used in the program, to achieve the function of water
level monitoring and other similar applications. The good point of this sensor is that it uses
very less power and has higher sensitivity.
Pin definition:
"S" stand for signal input
"+" stand for power supply
"-" stand for GND
Hardware Components Required-
Bolt IoT’s
Bolt WiFi Module
Resistor 330 ohm
Buzzer
5 mm LED
Seeed Studio Grove - Water Sensor
USB-A to Micro-USB Cable
Bolt IoT Breadboard
Software Used-
Bolt IoT Bolt Cloud
Bolt IoT Android App
Telegram
Snappy Ubuntu Core
Steps-
1 : Connect the hardware and circuits as shown
2: Create A product on Bolt Cloud and name it as Water Level Monitor
3: Go to the code tab in the product page and type the JS code given below and save
it.
4: Link the product with your Bolt IoT Device.
5: Download VirtualBox - https://www.virtualbox.org/wiki/Downloads as shown in
the Bolt IoT tutorials.
Ubuntu Server ISO link - http://releases.ubuntu.com/16.04/ubuntu-16.04.6-server-
i386.iso
6: Now in your Ubuntu Server type the Python Code given below.
7: Finally connect the circuit with power supply and Run the Python code which was
written in ubuntu server.
Circuit Connection-
Code-
JS code-
setChartLibrary('google-chart');
setChartType('areaGraph');
setChartTitle('Water Level Monitoring System');
setAxisName('Time Stamp', 'Water Level');
plotChart('time_stamp', 'water');
Python3 code-
import requests, time, math, json
from boltiot import Bolt
import conf2 as conf #my Configuration File
data = [] #Empty list for storing sensor values...
mybolt = Bolt(conf.bolt_api_key, conf.device_id) #My Bolt
mybolt.digitalWrite(0,"LOW")
#Function:Get Sensor Value
def get_sv(pin):
try:
response = mybolt.analogRead(pin)
data = json.loads(response)
if data["success"]!=1:
print("Rquest Failed")
print("Response:",data)
return -999
sensor_value = int(data["value"])
return sensor_value
except Exception as e:
print("Something went wrong")
print(e)
return -999
#Function:Send Telegram Message
def send_tm(message):
url = "https://api.telegram.org/"+conf.telegram_bot_id+"/sendMessage"
data = {
"chat_id":conf.telegram_chat_id,
"text":message
}
try:
response=requests.request(
"POST",
url,
params = data
)
print("This is the telegram response=>")
print(response.text)
telegram_data = json.loads(response.text)
return telegram_data["ok"]
except Exception as e:
print("Errror Occurred in sending the alert message")
print(e)
return False
#MAIN:->
while True:
sensor_value = get_sv("A0")
print("Sensor value is = ",sensor_value)
if sensor_value == -999:
print("Request unsuccessful.Skipping...")
time.sleep(10)
continue
if(sensor_value >= conf.threshold):
print("Alert:Water Level exceeded the threshold value")
message = "Alert(Type 1)!Water Level exceeded.Time to Stop filling the
tank"+
".The current sensor value is:"+str(sensor_value)
telegram_status = send_tm(message)
print("This is the telegram status:",telegram_status)
mybolt.digitalwrite(0,"HIGH")
time.sleep(60)
mybolt.digitalWrite(0,"LOW")
else:
mybolt.digitalwrite(0,"LOW")
data.append(sensor_value)
time.sleep(10)
#END
Conclusion-
With the Bolt Cloud, you can easily control the water level monitor and use
telegram to alert the user when the water goes above or below a certain value
over the internet from anywhere within minutes.