krishna teja putha
Published

Modified Water Level Monitoring with Motor Control

Switching the motor OFF whenever sensor value reaches its threshold value using Python and Bolt cloud.

IntermediateProtip1 hour566
Modified Water Level Monitoring with Motor Control

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Grove - Water Sensor
Seeed Studio Grove - Water Sensor
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1
DC Motor, Miniature
DC Motor, Miniature
×1
Breadboard (generic)
Breadboard (generic)
×1
Capacitor 470 µF
Capacitor 470 µF
×1
Electrolytic Capacitor, 200 µF
Electrolytic Capacitor, 200 µF
×1

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
Snappy Ubuntu Core
Snappy Ubuntu Core
SMS Messaging API
Twilio SMS Messaging API

Story

Read more

Schematics

water level monitoring with motor control

Code

code for water level monitoring

Python
copy the code and dump in python 3
import requests, json, conf, time, math 
from boltiot import Bolt, Sms 
data = [] 
mybolt = Bolt(conf.API_KEY,conf.DEVICE_ID) 
Sms = Sms (conf.SID, conf.AUTH_TOKEN, conf. TO_NUMBER,conf.FROM_NUMBER) mybolt.digitalWrite(0, "LOW") 
def get_sy (pin): 
    try:
                 response = mybolt.analogRead(pin) 
                 data=json. loads (response) 
                 if data["success"] !=1:
                           print ("request 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 
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 >= 480):
          print ("alert: water level exceeded the threshold value") 
message = "alert(type1)! water level exceeded. time to          stopfilling the tank"+". the $                      
response = sms. send_sms (the current sensor value is+  str(sensor_value))
         return sensor_value 
    except Exception as e:
                 print ("something went wrong") 
                 print (e)
                return -999 
while True:
           sensor_value = get_sv ("AO") 
           print ("sensor value is =", sensor_value) 
           if sensor_value == -999:
                    print ("request unsuccessful.skipping...") 
                    time.sleep(10)
                    continue  
           if (sensor_value >= 480):
                  print ("alert: water level exceeded the threshold value")                        message = "alert(type1) ! water level exceeded. time to stop                                               filling the tank"+". the $ 
                  response = sms. send_sms ("the current sensor value is "+str                                                            (sensor_value)) 
                  print (response recieved from twilio is : "+str(response))
                  print ("status of sms at twilio is:"+str(response.status))                       mybolt.digitalWrite(0, "high") 
                  time.sleep(60)
                  mybolt.digitalWrite(0, "Low") 
            else:
                    mybolt.digitalWrite(0, "low")
            data.append(sensor_value) 
            time.sleep(10)

Credits

krishna teja putha
1 project • 1 follower
Contact

Comments

Please log in or sign up to comment.