Himanshu Dagdi
Published © GPL3+

Water Level Monitoring System in Water Tanks Using Bolt IoT

Feel Bored while Monitoring water tanks in our Houses to avoid overflow and wastage of water? This Simple project can solve these Problems.

IntermediateFull instructions provided5 hours1,993
Water Level Monitoring System in Water Tanks Using Bolt IoT

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
5 mm LED: Yellow
5 mm LED: Yellow
×2
Grove - Water Sensor
Seeed Grove - Water Sensor
×1
Resistor 330 ohm
Resistor 330 ohm
×1
Buzzer
Buzzer
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1
SparkFun Solder-able Breadboard - Mini
SparkFun Solder-able Breadboard - Mini
×1

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
Bolt IoT Android App
Bolt IoT Android App
Snappy Ubuntu Core
Snappy Ubuntu Core
Telegram

Story

Read more

Schematics

CIRCUIT

This is how the connections are done

Code

Python3 Program

Python
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

JS Program :-

JavaScript
Code for the product in Bolt Cloud
setChartLibrary('google-chart');
setChartTitle('Water Level Monitoring !!!');
setChartType('areaGraph');
setAxisName('Time Stamp', 'Water Level');
plotChart('time_stamp', 'water');

Credits

Himanshu Dagdi

Himanshu Dagdi

1 project • 2 followers

Comments

Add projectSign up / Login