Skip to content
Nur Amin
← All projects
P-08Sistem Peringatan Dini Banjir2025

Flood Early Warning System

An ultrasonic sensor over the river, a buzzer on the post and a phone app that turns centimetres into Safe, Alert, Standby or Danger.

My role
Device, firmware and the monitoring app.
Field
IoT & Embedded
Stack
  • ESP32
  • Arduino C++
  • HC-SR04
  • Buzzer
  • Firebase RTDB
  • MIT App Inventor

Overview

Riverside neighbourhoods usually learn about a flood from the water itself. The idea here was to hang a cheap sensor over the river and give people a few minutes of warning: the ESP32 sends an ultrasonic pulse down, times the echo, and converts it into the distance between the sensor and the surface. The smaller that distance, the higher the water.

There is no server of our own in the middle. The board writes each reading to a single node in Firebase Realtime Database, overwriting the last one, so the database always holds the current state of the river. The mobile app, built with MIT App Inventor, listens for that node to change and compares the new value against the thresholds.

A number in centimetres means little at two in the morning, so the app reduces it to one word and one colour — Safe, Alert, Standby, Danger — next to the live distance and a water gauge. A buzzer on the post covers the people who are not looking at a phone, sounding more urgently as the level climbs.

In pictures

Flood Early Warning System title next to an illustrated river with an ultrasonic sensor on a post, and a phone showing 87 cm and the status WASPADA.
FIG. 01Illustration: the original app is no longer available, and the thresholds are example values. The app UI is in Indonesian.
Three steps — ESP32 measures, Firebase stores /kondisi, the app compares thresholds — above a river cross-section with the sensor measuring distance down to the water.
FIG. 02The device only measures; Firebase holds the latest value and the app decides the status.
Four phones showing 142, 87, 44 and 21 cm as Aman, Waspada, Siaga and Bahaya, each with what it means and how the buzzer behaves.
FIG. 03One word and one colour per level, with example thresholds.

Function

Input
Ultrasonic distance from the sensor down to the water, about once a second
Link
ESP32 writes the reading straight to Firebase Realtime Database
Output
Buzzer on site and a colour-coded status in the mobile app

What it does

  1. 01Ultrasonic distance measurement from above the water, so nothing sits in the river.
  2. 02Readings written to Firebase Realtime Database about once a second.
  3. 03Mobile app that reacts to each change and shows the live distance and a water gauge.
  4. 04Four colour-coded statuses: Safe, Alert, Standby and Danger.
  5. 05Buzzer on site for people without a phone at hand.

Technical notes

Firebase path
/kondisi — {"jarak": 87}
Formula
distance = echo time × 0.0343 / 2 (cm)
Status
The original app is no longer available; images are illustrations