HEMAL SEBASTIAN
Published © GPL3+

Automatic Water Pump

Functioning of the pump will be automatic and you don't have to worry about switching the pump on or off.

BeginnerFull instructions provided2 hours1,343
Automatic Water Pump

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
REES52 Water level sensor
×1
5V Single channel relay module
×1
Mini micro submersible water pump DC 3-6V
×1
Breadboard (generic)
Breadboard (generic)
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×6
Male/Male Jumper Wires
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1

Software apps and online services

Snappy Ubuntu Core
Snappy Ubuntu Core
Bolt Cloud
Bolt IoT Bolt Cloud
Telegram

Hand tools and fabrication machines

Multitool, Screwdriver
Multitool, Screwdriver

Story

Read more

Schematics

CIRCUIT CONNECTIONS

This is how the circuit connections are done.

Code

Python code

Python
import json,time,requests,conf
from boltiot import Bolt
mybolt=Bolt(conf.api_key,conf.device_id)
def sensorvalue(pin):
  try:
    response=mybolt.analogRead(pin)
    data=json.loads(response)
    if data['success']!=1:
      print("REQUEST NOT SUCCESSFULL")
      print("THIS IS THE RESPONSE-->",data)
      return -999
    s=int(data["value"])
    return s
  except Exception as e:
    print("SOMETHING WENT WRONG WHEN RETURNING THE SENSOR VALUE")
    print(e)
    return -999
def sends(message):
  url="https://api.telegram.org/"+conf.bot_id+"/sendMessage"
  data={"chat_id":conf.chat_id1,"text":message}
  try:
    response=requests.request("POST",url,params=data)
    print("THIS IS THE TELEGRAM URL")
    print(url)
    print("THIS IS THE TELEGRAM RESPONSE")
    print(response.text)
    telegram_data=json.loads(response.text)
    return telegram_data["ok"]
  except Exception as e:
    print("AN ERROR OCCURED IN SENDING THE ALERT MESSAGE VIA TELEGRAM")
    print(e)
    return False
i=0
while True:
  s=sensorvalue("A0")
  print("THE CURRENT SENSOR VALUE IS :",s)
  if s==-999:
    print("REQUEST WAS UNSUCCESSFULL. SKIPPING.")
    time.sleep(10)
    continue
  if(s>=conf.threshold and i==0):
    print("SENSOR VALUE HAS EXCEEDED THRESHOLD")
    message="THE PUMP IS TURNED OFF"
    mybolt.digitalWrite('4','HIGH')
    telegram_status=sends(message)
    print("THIS IS THE TELEGRAM STATUS :",telegram_status)
    i=1
    time.sleep(10)
    continue
  elif(s<=conf.threshold and i==1):
    print("SENSOR VALUE IS BELOW THRESHOLD")
    message="THE WATER PUMP IS TURNED ON"
    mybolt.digitalWrite('4','LOW')
    telegram_status=sends(message)
    print("THIS IS THE TELEGRAM STATUS :",telegram_status)
    i=0
    time.sleep(10)
    continue
  time.sleep(10)

Bolt cloud

JavaScript
setChartLibrary("google-chart");
setChartType('areaGraph');
setChartTitle('AUTOMATIC MOTER');
setAxisName('water level','time');
plotChart('time_stamp','level');
setCrosshair(true);

Credits

HEMAL SEBASTIAN

HEMAL SEBASTIAN

1 project • 2 followers

Comments