MeWater

MeWater

A Water Conservation Project built on IoT & AWS Cloud Technologies

Introduction

With the increasing water demand - freshwater specifically, water sources are straining as they aren't replenishing as fast as would be optimal. Water conservation includes all the policies, strategies and activities to sustainably manage the natural resource of freshwater [Wikipedia].

With this in mind, one of the ways we could conserve water is by detecting and mitigating leakages.

MeWater is a simple solution that utilizes the robustness of the Internet of Things (IoT) & infinite compute and storage cloud technology to monitor household pipelines, detect leakages and mitigate this by cutting off supply to the affected pipelines.

MeWater's Progress So Far

Internet of Things (IoT)


This was the initial rig used to put our solution to the test. It included:

  • Flow Sensors / Flow Meters

  • Water Pump - To simulate water inlet

  • 3 Taps - One of which was used to simulate a leak

  • A solenoid valve (Added later) - to cut off supply whenever a leak is detected

  • ESP32 microcontroller - the 'brains'

The ESP32 microcontroller's job is to read from the flow meters and send that telemetry to our cloud infrastructure.

The microcontroller sends telemetry via the MQTT protocol and connects to an MQTT server set up on AWS IoT Core.

The leakage detection algorithm is run on the cloud and the microcontroller 'listens' for a 'leakage alarm' and triggers the solenoid valve to cut off the water supply to the affected tap (simulated pipeline)

The IoT stack is well documented by my project partner (Fanuel Conrad) here.

Cloud Infrastructure - Amazon Web Services (AWS)


There are 4 major functions that this architecture serves:

  1. Getting IoT Data from IoT Core and Storing it in an S3 Bucket (Raw Data)

  2. Processing the raw data into something useful to display to end-users

  3. Sending alerts to users in case a leak is detected

  4. Sending valve shutdown command to IoT Devices in case a leak is detected

    1 - Getting IoT Data from IoT Core and Storing it in an S3 Bucket (Raw Data)

To get data from IoT Core and store it in an S3 Bucket, an IoT rule is used. The Data is stored in JSON format in the S3 bucket; which makes it both readable and easy to process.

Here's a sample packet of data that the microcontroller sends to the cloud.

{
  "time": 4736,
  "inlet_flowrate": 0,
  "outlet1_flowrate": 0,
  "outlet2_flowrate": 0,
  "inlet_volume": 0,
  "outlet1_volume": 0,
  "outlet2_volume": 0
}

2 - Processing the raw data into something useful to display to end-users

A Lambda Function (serverless function) is then used to process the data from S3 and store the processed data in DynamoDB for quick access by our web application (the end-users point of interaction with our system). Processing in this step involves aggregating the volume information as well as determining whether there's a leak or not.

3 - Sending alerts to users in case a leak is detected

The leakage detection algorithm that we are currently using is a poor man's version and fails in some test cases. We are currently working on a more sophisticated algorithm.

Here's the current working algorithm.

$$leakedVolume = inletVolume - (outlet1Volume + outlet2Volume)$$

Once a leak is detected, i.e. the leakedVolume has a value greater than zero, a message containing the leakage info is published to an AWS SNS Topic (Simple Notification Service)

  • A Second Lambda function that's subscribed to this topic receives the message and immediately publishes a shutdown command to the MQTT Server, which then handles communication with the MQTT Client (our ESP32 microcontroller)

  • At the same time, an SMS, as well as an E-mail, is sent to the end-user notifying them of the same.

You can read more about our cloud solution here.

Web Application (Dashboard)


The primary function of the dashboard is to relay information to the end user. Using easy-to-read charts and a de-cluttered User Interface achieves that.

The dashboard is built using Python (Flask) for the backend, and Bootstrap 5 for the frontend.

It is deployed on AWS via the Elastic Compute Cloud (EC2) service

Get access to the repository here.

Future Improvements

  • Better Leakage Detection & Mitigation Algorithm

  • A More robust test rig

  • Application Programming Interface (API) to expose our IoT data to anyone interested in analysis / building out their solution.

  • Granular Data (Dashboard)

  • Feel free to leave suggestions in the comment box below. Better yet, reach out to me!

Reference List