Sridhar Babu
Published © GPL3+

IOT based tank water monitoring system

Get notified when the water in tank is at low or high level using iot device which leads to saving of more water.

BeginnerFull instructions provided3 hours22,034
IOT based tank water monitoring system

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
LED (generic)
LED (generic)
×1
Buzzer
Buzzer
×1
Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

SMS Messaging API
Twilio SMS Messaging API
Bolt Cloud
Bolt IoT Bolt Cloud

Hand tools and fabrication machines

Tape, Electrical
Tape, Electrical

Story

Read more

Schematics

CIRCUIT DIAGRAM

Code

code for arduino

C/C++
this code is used to read the sensor value and control the leds and buzzer
const int out=2;
const int in=3;
const int red=10;
const int green=8;
const int buzz=12;

void setup(){
Serial.begin(9600);
pinMode(in, INPUT);
pinMode(out, OUTPUT);
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(buzz, OUTPUT);
digitalWrite(green,LOW);
digitalWrite(red,LOW);
digitalWrite(buzz,LOW);
}

void loop()
{
long dur;
long dis;
long tocm;
digitalWrite(out,LOW);
delayMicroseconds(2);
digitalWrite(out,HIGH);
delayMicroseconds(10);
digitalWrite(out,LOW);
dur=pulseIn(in,HIGH);
tocm=microsecondsToCentimeters(dur);
Serial.println(String(tocm));
if(tocm<=6)
{
  digitalWrite(red,HIGH);
 digitalWrite(green,LOW);
  digitalWrite(buzz,HIGH);
  delay(5000);
  digitalWrite(buzz,LOW);
  delay(2000);
  digitalWrite(buzz,HIGH);
   delay(2000);
  digitalWrite(buzz,LOW);
 delay(2000);
  digitalWrite(buzz,HIGH);
   delay(2000);
  digitalWrite(buzz,LOW);
  delay(2000);
  digitalWrite(buzz,HIGH);
   delay(2000);
  digitalWrite(buzz,LOW);0
  
}
else{
if(tocm>=20)
{
  digitalWrite(red,HIGH);
  digitalWrite(buzz,LOW);
  digitalWrite(green,LOW);
  digitalWrite(buzz,LOW);
}else
{
 digitalWrite(green,HIGH); 
 digitalWrite(red,LOW);
 digitalWrite(buzz,LOW);
}
}
delay(5000);
}

long microsecondsToCentimeters(long microseconds)
{
return microseconds / 29 / 2;
}

code for bolt-iot module

Python
this code is used for reading sensor value and send messages to your phone from twillio
from boltiot import Sms, Bolt
import json, time
minval=6
maxval=20
SSID = 'YOUR SID' 
AUTH_TOKEN = 'YOUR TWILLIO AUTH TOKEN' 
FROM_NUMBER = 'YOUR TWILLIIO NUMBER'
TO_NUMBER = 'YOUR PHONE NUMBER'
API_KEY = 'YOUR BOLT IOT API KEY'
DEVICE_ID = 'YOUR BOLT DEVICE ID'
FRAME_SIZE = 10
MUL_FACTOR = 6


mybolt = Bolt(API_KEY,DEVICE_ID)
sms = Sms(SSID,AUTH_TOKEN,TO_NUMBER,FROM_NUMBER)


while True: 
    print ("Reading sensor value")
    response = mybolt.serialRead('3') 
    data = json.loads(response)
    j=data['value'].rstrip()
    print("Sensor value is: " +j)
    try:
        if int(j)<=minval:
            print("Making request to Twilio to send a SMS")
            response = sms.send_sms("The tank is full please swith off the motor ")
            print("Response received from Twilio is: " + str(response))
            print("Status of SMS at Twilio is :" + str(response.status))
        if int(j)>=maxval:
            print("Making request to Twilio to send a SMS")
            response = sms.send_sms("The tank is empty please swith on the motor ")
            print("Response received from Twilio is: " + str(response))
            print("Status of SMS at Twilio is :" + str(response.status))    
    except Exception as e: 
        print ("Error occured: Below are the details")
        print (e)
    time.sleep(5)
8

Credits

Sridhar Babu

Sridhar Babu

1 project • 5 followers

Comments