Detect water leaks in close to actual time utilizing AWS IoT


Water is without doubt one of the most treasured sources wanted for the sustenance of life. Nonetheless, solely 2% of the worldwide water provide is appropriate for human consumption. The US Environmental Safety Affiliation (EPA) estimates that 1.7 trillion gallons, roughly 30 p.c of all handled water, is wasted yearly in the US.

Based on New York Metropolis Division of Environmental Safety, a leaking hearth hydrant can waste as much as 1,000 gallons of water per minute. Utilities need to deploy guide sources to determine these leaks, which could be a time consuming and labor-intensive course of. Furthermore, if these leaks aren’t addressed, then utilities may be penalized with heavy fines for non-compliance with environmental legal guidelines. These dangers are an end result of the water provide infrastructure seen in most cities, the place provide strains are run underground, creating pure challenges to rapidly determine and restore leaks. In most cases, leaks are by no means detected till the subsequent scheduled upkeep name or throughout an emergency state of affairs the place use of fireplace hydrant is verified. A typical upkeep name can take as much as 3 months and will require a minimal of three visits. Think about how a lot water is wasted throughout this era. The answer described on this weblog may help cut back leakage waste and upkeep prices for the utilities.

Answer overview

Think about a state of affairs, the place water is flowing by way of hearth hydrants throughout cities and rural areas, and someplace alongside such lengthy routes, a minor leak happens. The leak stays undetected for a number of weeks to months. Even after the leak is detected, it may take a number of extra weeks to determine the precise location after which repair it. At the moment, most hearth hydrants may be upgraded with an IoT sensor to speak statistics on the standing and utilization of the hearth hydrant. These sensors may help determine water leaks in nearly actual time to set off proactive upkeep actions. Within the proposed structure, an IoT-enabled, 5G-capable hearth hydrant communicates utilizing MQTT protocols to AWS. These hearth hydrants use AWS IoT Core to authenticate with AWS.

Structure diagram

Earlier than we deep dive into the structure, let’s perceive the 4 levels represented by the architectural diagram.

The primary stage establishes communication from IoT gadgets to AWS over MQTT protocol.

The second stage shops the collected information and maintains it for long-term compliance causes.

The third stage dispatches notifications to discipline groups for lively leak conditions and allows them to take actions ASAP.

The fourth stage gives back-office operators management over the complete system. Again-office operators can make the most of Amazon QuickSight dashboards to view lively leaks and actions being carried out, machine well being, and rather more based mostly on the collected information.

Stage 1: IoT Communications

5G-capable hearth hydrants can set up communications with AWS over MQTT protocols.

  • AWS IoT Core helps set up communication. Bulk on-boarding of gadgets is feasible with AWS IoT Machine Administration.
  • AWS IoT Machine Administration will securely entry IoT gadgets, monitor well being, detect and remotely troubleshoot issues, and handle software program and firmware updates.
  • AWS IoT Machine Defender helps preserve safety of all on-boarded IoT gadgets, displays safety metrics, and generates alerts based mostly on deviations from the anticipated habits of every machine.
  • As soon as this communication is established, the hearth hydrant can ship hydrant well being standing, geo-location and water move information over safe MQTT protocol in JSON format to AWS.

Stage 2: Storage

As soon as IoT gadgets begin sending occasions, there will likely be extra information to gather and course of.

Stage 3: Dispatch & Repair

Occasions comprise very important details about potential leaks. Now, related hearth hydrants can talk with AWS so back-office groups may be notified in close to real-time and alert discipline employees for rapid motion.

  • Hearth hydrant publishes a notification to AWS IoT Core over an MQTT protocol after a set interval.
  • AWS IoT Core Guidelines Engine retrieves the notification from the MQTT subjects.
  • AWS IoT Core Guidelines Engine then sends the notification to AWS IoT Occasions.
  • AWS IoT Occasions has a detector mannequin that displays incoming IoT occasions, (e.g. a fireplace hydrant’s water move and strain degree), by sending a request again to the AWS IoT Core MQTT matter.
  • AWS IoT Occasions detects the water move and strain abnormalities based mostly on outlined thresholds. If the water strain and move fall exterior of outlined thresholds, AWS IoT Occasions sends a notification message to an Amazon Easy Notification Service (Amazon SNS) matter.
  • The sector operations workforce receives a notification message to tell discipline operators of the potential leak state of affairs.
  • Along with triggering an alert, AWS IoT Occasions sends the identical message to Amazon DynamoDB to create a assist case. The back-office workforce tracks the standing of fireplace hydrants utilizing an Amazon QuickSight dashboard.
  • As soon as the leak is fastened, the sector operations workforce updates the standing of the assist case.

Stage 4: Perception Reporting

All of the collected occasions saved in Amazon S3 allow reporting capabilities.

  • Amazon Athena is used to investigate and question on collected occasions.
  • Amazon QuickSight helps insightful dashboards for back-office operators to assist them visualize lively leaks, actions being carried out for lively leaks, geographical distribution of leaks, in addition to assist them monitor well being standing for gadgets and rather more.


To comply with alongside and arrange the asset inspection answer, you should definitely have the next:

  • An AWS account.
  • A tool or laptop computer/pc with an entry to your AWS account, Python model 2.7.18+ put in, and the AWS IoT Machine SDK for Python model 1.3.1+.

Organising AWS IoT Occasions to handle hearth hydrant leaks

An AWS IoT rule must be configured to ahead machine information from AWS IoT Core (MQTT matter) to AWS IoT Occasions.

  • Go to the AWS Administration Console and choose AWS IoT Core.
  • Choose Message Routing, then Guidelines, after which select Create rule. Rule description is an optionally available discipline.

IoT Rule set up

IoT Rule arrange

  • Set the Identify for the rule and set the rule question assertion to SELECT * FROM ‘iot/matter’. Pattern question under.

sample query

Pattern Question

  • Select Add rule motion.
  • Choose IoT Occasions possibility and enter Enter title.
  • Choose the Enter beforehand created.
  • Choose Create new function and enter a function title.
  • Choose Add rule motion.
  • Choose Create rule.
  • A pattern of the rule created in AWS Console.

Create Rule

Create Rule

In AWS IoT Occasions, create the next elements to start out the hearth hydrant’s water move and strain:

  • Choose AWS IoT Occasions from the companies menu. On the AWS IoT Occasions web page, choose an industry-specific template from the part proven following.

Create Detector Model

Create Detector Mannequin

  • From that display choose Easy Alarm and select Begin.

IoT Event template selection

IoT Occasion template choice

  • Create a detector mannequin with 3 states every, with 2 transitions as proven following.

Create Detector Model

Create Detector Mannequin

  • Upon receipt of a notification, the machine state is modified to “ActiveLeak“. This state is used to set off the alert to discipline employee and back-office dashboard.

Creating an enter in AWS IoT Occasions

You’ll be able to create an enter in AWS IoT Occasions by following the information to create an enter. In our instance, we create an enter with the next particulars:

  • An instance Enter title set to “deviceNotificationInput”
  • Add a JSON file with following instance JSON payload:
  • {
    "geoLocation": "42.3928258265305, -71.07754968042828",
    "timeStamp": "2022-05-31 08:47:44.870092",
    "cityName": "Boston",
    "state": "MA",
    "deviceId": "BOS0”,
    "sensorHealth": "OK",
    "inputFlow": "10",
    "outputFlow": "10"

Create Device Notification Input

Create Machine Notification Enter

Creating and publishing a detector mannequin in AWS IoT Occasions

In our instance, we create a detector mannequin with the next particulars and you’ll find a pattern at AWS IoT Occasions Developer Information.

  • Three states (Regular, ActiveLeak and Snooze).
  • Every with transitions that switches the machine from one state to a different.
  • Upon receiving a notification from the machine, the traditional transition triggers the sending of a notification to the outbound AWS IoT Core’s MQTT matter and adjustments the machine state to out_of_range and pushing state to ActiveLeak.
  • If the restore is taking longer, then machine state may very well be pushed to Snooze state whereas the repair is being carried out.
Regular StateActiveLeak StateSnooze State
normal stateactive leak statesnooze state

States for the detector mannequin

Making a detector mannequin

  • Create an IAM function for the Detector Mannequin. For extra data, see the documentation for establishing permissions for AWS IoT Occasions.
  • Create the pattern detector mannequin as proven within the earlier picture with states and transitions.

Analyzing information utilizing Amazon QuickSight

Following are the kind of visualizations you possibly can create with the info utilizing Amazon QuickSight.

Machine well being standing: The under chart exhibits the machine standing together with machine areas of fireplace hydrants. These charts will help back-office groups to determine defective hearth hydrants and ship geolocation to discipline operators to repair these defective gadgets.

Device health report – Keeps back office up to date with compliance and device health status near real time

Machine well being report – Retains again workplace updated with compliance and machine well being standing close to actual time.

Lively leaks: The under chart exhibits water leaks throughout 3 instance cities – New York, Chicago, and Boston.

Active leak report – Shows active leaks across cities for the back office

Lively leak report – Exhibits lively leaks throughout cities for the again workplace

Geo-locations of lively leaks: The under chart exhibits lively water leaks on a map, plotted utilizing machine Geo coordinates. This may very well be helpful for back-office groups to actively have a look at streets the place there is a matter.
geolocation of fire hydrants

Geo location of fireplace hydrants – Exhibits hearth hydrants in map/avenue view with their standing

Cleansing up

To keep away from incurring undesirable expenses, delete the next sources:


On this weblog, we confirmed how AWS IoT companies can be utilized to detect real-time leaks in hearth hydrants and pin-point the precise location of the leaks. This answer can result in a discount in time to repair the leaks, thereby lowering water wastage and enhancing environmental influence. The identical answer may be prolonged to detect leaks in house water home equipment or leaks in oil/ pure fuel pipelines.

To be taught extra about tips on how to use AWS IoT Core, you possibly can discuss with the documentation.

AWS welcomes suggestions. Please join with us on LinkedIn if in case you have ideas or questions.


mrunal daftariMrunal Daftari is an Enterprise Senior Options Architect at Amazon Internet Companies. Mrunal relies in Boston, MA. He’s a cloud fanatic and really enthusiastic about discovering options for purchasers which can be easy and addresses their enterprise outcomes. He loves working with cloud applied sciences offering easy, scalable options that drive constructive enterprise outcomes, cloud adoption technique, design modern options and drive operational excellence.
Vaibhav Sabharwal is a Senior Answer Architect with Amazon Internet Companies (AWS). He’s a part of the Monetary Service Technical Area Group. He helps AWS clients to construct cloud adoption technique, design modern options and drive operational excellence.



Please enter your comment!
Please enter your name here