venu reddyCharran TridandapaniMoiz ahmed KaziAjitha priyaNARENDRANNarendran
Published © GPL3+

Smart water metering

The term "smart water metering" is used to describe the use of cutting-edge technology for improved water usage tracking and management.

IntermediateFull instructions provided251
Smart water metering

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
Water Detect click
MikroE Water Detect click
×1
RGB Backlight LCD - 16x2
Adafruit RGB Backlight LCD - 16x2
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Resistor 330 ohm
Resistor 330 ohm
×1
LED (generic)
LED (generic)
×1
AA Batteries
AA Batteries
×1
PTS 645 Series Switch
C&K Switches PTS 645 Series Switch
×1
Gravity: Analog Soil Moisture Sensor For Arduino
DFRobot Gravity: Analog Soil Moisture Sensor For Arduino
×1
PHPoC Bread Board
PHPoC Bread Board
×1

Software apps and online services

MATLAB
MATLAB
Blynk
Blynk

Hand tools and fabrication machines

Mastech MS8217 Autorange Digital Multimeter
Digilent Mastech MS8217 Autorange Digital Multimeter
Multitool, Screwdriver
Multitool, Screwdriver

Story

Read more

Schematics

smart water meter

circuit

Code

smart water meter

C/C++
// Include Libraries
#include "Arduino.h"
#include "DHT.h"
#include "NewPing.h"
#include "LiquidCrystal_PCF8574.h"
#include "Adafruit_NeoPixel.h"
#include "SoilMoisture.h"
#include "Pump.h"

// Pin Definitions
#define DHT_PIN_DATA    2
#define HCSR04_PIN_TRIG 4
#define HCSR04_PIN_ECHO 3
#define LEDRGB_1_PIN_DIN 6
#define SOILMOISTURE_5V_PIN_SIG A3
#define WATERPUMP_PIN_COIL1 5
#define WATERLEVELSENSOR_5V_PIN_SIG A1
#define WATERPRESSURESENSOR_5V_PIN_SIG A0


// Global variables and defines
// There are several different versions of the LCD I2C adapter,each might have a different address.
// Try the given addresses by uncommenting the following rows until LCD works following the serial monitor prints.
// To find your LCD address go to: http://playground.arduino.cc/Main/I2cScanner and run the example.
#define LCD_ADDRESS 0x3F
//#define LCD_ADDRESS 0x27
// Define LCD characteristics
#define LCD_ROWS 2
#define LCD_COLUMNS 16
#define SCROLL_DELAY 150
#define BACKLIGHT 255
#define LedRGB_1_NUMOFLEDS 3
// object initialization
DHT dht(DHT_PIN_DATA);
NewPing hcsr04(HCSR04_PIN_TRIG,HCSR04_PIN_ECHO);
LiquidCrystal_PCF8574 lcdI2C;
Adafruit_NeoPixel LedRGB_1(LEDRGB_1_PIN_DIN);
SoilMoisture soilMoisture_5v(SOILMOISTURE_5V_PIN_SIG);
Pump waterpump(WATERPUMP_PIN_COIL1);

// define vars for testing menu
const int timeout = 10000;       // define timeout of 10 sec
char menuOption = 0;
long time0;

// Setup the essentials for your circuit to work.It runs first every time your circuit is powered with electricity.
void setup()
{
    // Setup Serial which is useful for debugging
    // Use the Serial Monitor to view printed messages
    Serial.begin(9600);
    while (!Serial); // wait for serial port to connect.Needed for native USB
    Serial.println("start");

    dht.begin();
    // initialize the lcd
    lcdI2C.begin(LCD_COLUMNS,LCD_ROWS,LCD_ADDRESS,BACKLIGHT);
    LedRGB_1.begin(); // This initializes the NeoPixel library.
    LedRGB_1.show(); // Initialize all leds to 'off'
    menuOption = menu();
}

(/)/ Main logic of your circuit.It defines the interaction between the components 
you selected.After setup,it runs over and over again,in an eternal loop.
void loop()
{
    if (menuOption == '1') {
        // DHT22/11 Humidity and Temperature Sensor - Test Code
        // Reading humidity in %
        float dhtHumidity = dht.readHumidity();
        // Read temperature in Celsius,for Fahrenheit use .readTempF()
        float dhtTempC = dht.readTempC();
        Serial.print(F("Humidity: "));
        Serial.print(dhtHumidity);
        Serial.print(F(" [%]\t"));
        Serial.print(F("Temp: "));
        Serial.print(dhtTempC);
        Serial.println(F(" [C]"));

    }
    else if (menuOption == '2') {
        // Ultrasonic Sensor - HC-SR04 - Test Code
        // Read distance measurement from UltraSonic sensor           
        int hcsr04Dist = hcsr04.ping_cm();
        delay(10);
        Serial.print(F("Distance: "));
        Serial.print(hcsr04Dist);
        Serial.println(F("[cm]"));

    }
    else if (menuOption == '3') {
        // LCD 16x2 I2C - Test Code
        // The LCD Screen will display the text of your choice.
        lcdI2C.clear();                          // Clear LCD screen.
        lcdI2C.print("  Circuito.io  ");                   // Print print String to LCD on the first line
        lcdI2C.selectLine(2);                    // Set cursor at the beginning of line 2
        lcdI2C.print("     Rocks!  ");                   // Print print String to LCD on the second line
        delay(1000);

    }
    else if (menuOption == '4') {
        // LED - RGB Addressable,PTH,5mm Diffused (5 Pack) #1 - Test Code
        for (int i = 0; i <= LedRGB_1_NUMOFLEDS; i++) {
            for (int k = 0; k <= 255; k++) {
                // set leds Color to RGB values,from 0,0,0 up to 255,255,255
                LedRGB_1.setPixelColor(i,LedRGB_1.Color(255 - k,k,100)); // turn on green color on led #i.
                if (i > 0)
                    LedRGB_1.setPixelColor(i - 1,LedRGB_1.Color(0,0,0)); // turn off the last led
                LedRGB_1.show(); // update led color to the hardware.
                delay(1);
            }
        }

    }
    else if (menuOption == '5') {
        // Soil Moisture Sensor - Test Code
        int soilMoisture_5vVal = soilMoisture_5v.read();
        Serial.print(F("Val: "));
        Serial.println(soilMoisture_5vVal);

    }
    else if (menuOption == '6') {
        // Submersible Pool Water Pump - Test Code
        // The water pump will turn on and off for 2000ms (4 sec)
        waterpump.on(); // 1.turns on
        delay(2000);       // 2.waits 500 milliseconds (0.5 sec).
        waterpump.off(); // 3.turns off
        delay(2000);       // 4.waits 500 milliseconds (0.5 sec).
    }
    else if (menuOption == '7') {
        // Disclaimer: The Water Level Sensor Module is in testing and/or doesn't have code,therefore it may be buggy.Please be kind and report any bugs you may find.
    }
    else if (menuOption == '8') {
        // Disclaimer: The Gravity: Analog Water Pressure Sensor is in testing and/or doesn't have code,therefore it may be buggy.Please be kind and report any bugs you may find.
    }

    if (millis() - time0 > timeout) {
        menuOption = menu();
    }
}

// Menu function for selecting the components to be tested
// Follow the serial monitor for instructions
char menu()
{
    Serial.println(F("\nWhich component would you like to test?"));
    Serial.println(F("(1) DHT22/11 Humidity and Temperature Sensor"));
    Serial.println(F("(2) Ultrasonic Sensor - HC-SR04"));
    Serial.println(F("(3) LCD 16x2 I2C"));
    Serial.println(F("(4) LED - RGB Addressable,PTH,5mm Diffused (5 Pack) #1"));
    Serial.println(F("(5) Soil Moisture Sensor"));
    Serial.println(F("(6) Submersible Pool Water Pump"));
    Serial.println(F("(7) Water Level Sensor Module"));
    Serial.println(F("(8) Gravity: Analog Water Pressure Sensor"));
    Serial.println(F("(menu) send anything else or press the onboard reset button\n"));

    while (!Serial.available());

    // Read data from the serial monitor if received
    while (Serial.available())
    {
        char c = Serial.read();
        if (isAlphaNumeric(c))
        {
            if (c == '1')
                Serial.println(F("Now Testing DHT22/11 Humidity and Temperature Sensor"));
            else if (c == '2')
                Serial.println(F("Now Testing Ultrasonic Sensor - HC-SR04"));
            else if (c == '3')
                Serial.println(F("Now Testing LCD 16x2 I2C"));
            else if (c == '4')
                Serial.println(F("Now Testing LED - RGB Addressable,PTH,5mm Diffused (5 Pack) #1"));
            else if (c == '5')
                Serial.println(F("Now Testing Soil Moisture Sensor"));
            else if (c == '6')
                Serial.println(F("Now Testing Submersible Pool Water Pump"));
            else if (c == '7')
                Serial.println(F("Now Testing Water Level Sensor Module - note that this component doesn't have a test code"));
            else if (c == '8')
                Serial.println(F("Now Testing Gravity: Analog Water Pressure Sensor - note that this component doesn't have a test code"));
            else
            {
                Serial.println(F("illegal input!"));
                return 0;
            }
            time0 = millis();
            return c;
        }
    }
}

Credits

venu reddy

venu reddy

1 project • 0 followers
Charran Tridandapani

Charran Tridandapani

1 project • 0 followers
Moiz ahmed Kazi

Moiz ahmed Kazi

1 project • 0 followers
Ajitha priya

Ajitha priya

1 project • 0 followers
NARENDRAN

NARENDRAN

19 projects • 18 followers
Narendran

Narendran

1 project • 0 followers

Comments

Add projectSign up / Login