🌐 এই লেখাটি বাংলায় পড়ুন: বাংলা সংস্করণ →

Quick answer: A LoRa flood monitoring system is a solar-powered sensor node fixed above a river or canal that measures the distance to the water surface every few minutes and sends the level by long-range LoRa radio to a base station several kilometres away. The base station tracks both the water level and how fast it is rising, and when a threshold is crossed it sounds a siren and sends SMS and Telegram alerts, while a web dashboard shows the live graph.
This is a complete reference design for final-year EEE/ETE/CSE students: principle, block and circuit diagrams, pin-by-pin wiring, BOM in taka, an honest range estimate, a power budget, the alarm logic and about half of the firmware.
Table of Contents
Why a flood early-warning project matters in Bangladesh (2026)
North-east Bangladesh floods fast because the water comes from the Meghalaya hills. In June 2022 the Department of Disaster Management called the Sylhet flood “the worst in 122 years in the Sylhet region”. Mawsynram and Cherrapunji each got over 970 mm of rain in one day. In 2024, a UNICEF situation report (15 June 2024) counted about 739,000 people affected in Sylhet division.
The Flood Forecasting and Warning Centre (FFWC, BWDB) forecasts the big rivers, but small canals, haor embankments and village khals often have no gauge. A cheap solar node with a local siren closes that “last mile” gap. It is also a strong final-year project: real social impact plus RF link budgets, low-power design, filtering and alarm logic. Still choosing a topic? See our final-year EEE project ideas for Bangladesh.
How the IoT flood warning system works
1. Sensing. A waterproof ultrasonic sensor points down at the water, sends a 40 kHz ping and times the echo: distance = speed of sound × time / 2. With the sensor at surveyed height H above gauge zero, level = H − distance. Where the level swings more than 4.5 m, use a 4–20 mA submersible pressure sensor instead (ρgh: 1 m of water ≈ 9.81 kPa).
2. Filtering. Waves, hyacinth, rain and insects cause bad echoes. The node takes 7 readings and keeps the median, which rejects single spikes.
3. Rate of rise. For flash floods, how fast the water rises matters more than the level. A least-squares line through the last 6 readings gives the rise rate in mm/h, much less noisy than subtracting two readings.
4. LoRa link. LoRa uses chirp spread spectrum. Each spreading-factor (SF) step doubles airtime, and the receiver decodes signals below the noise floor (about −15 dB SNR at SF10), so a 25 mW radio reaches kilometres.
5. Decision and alert. The gateway runs a NORMAL → WATCH → WARNING → DANGER state machine with persistence and hysteresis, then drives a 12 V siren, SMS via a 4G modem, and Telegram plus a dashboard over Wi-Fi.
LoRa point-to-point or LoRaWAN — which should you use?
| Criterion | LoRa P2P (this design) | LoRaWAN |
|---|---|---|
| Gateway hardware | Second ESP32 LoRa board (single channel) | 8-channel SX1302 gateway + network server |
| Public network in Bangladesh | Not needed | No public coverage to rely on; you must run your own |
| Local siren works without internet | Yes | Only if you host the network server locally |
| Best for | 1–10 nodes, a student/community pilot | Dozens–hundreds of nodes, a district-scale product |
| Security | You add AES + sequence numbers yourself | Built in (AES-128, frame counters) |
We use LoRa P2P: a flood siren must work when mobile data and the cloud are down, and a P2P gateway decides locally. You can move to LoRaWAN later with RadioLib’s LoRaWAN stack.
Which LoRa frequency is legal in Bangladesh?
Be honest in your report: we could not find a published BTRC rule for LoRa, and TTN’s frequencies-by-country table lists Bangladesh with no plan. In a TTN forum thread on Bangladesh, users found that LoRa Alliance documents disagree (EU863-870/IN865 vs AS923-1 at 922–925 MHz). Treat 923 MHz (AS923-1) as an assumption, keep TX power low for lab demos, and get BTRC clearance before a permanent installation. The SX1262 covers 863–928 MHz, so changing band is a config change.
LoRa flood monitoring system block diagram

Sensor node: 6 V solar panel → CN3791 MPPT charger → 18650 pack → Heltec WiFi LoRa 32 V3 (ESP32-S3 + SX1262). Inputs: A02YYUW ultrasonic sensor and an optional float switch. Gateway: Heltec V3 receiver → alarm logic → 12 V siren, A7670 4G modem (SMS) and Wi-Fi (Telegram + dashboard), powered from a 12 V SLA battery so it survives load-shedding.
Circuit diagram and pin-by-pin wiring

All Heltec V3 pin numbers come from Espressif’s official arduino-esp32 variant file for heltec_wifi_lora_32_V3 (LoRa SS 8, SCK 9, MOSI 10, MISO 11, RST 12, BUSY 13, DIO1 14, Vext 36). The battery divider (GPIO37 control, GPIO1 ADC, 390k/100k) comes from the board schematic notes in the Heltec_ESP32_LoRa_v3 library. Sensor data is from the DFRobot SEN0311 (A02YYUW) wiki.
| From | To (Heltec V3 — node) | Note |
|---|---|---|
| A02YYUW VCC (pin 1) | Vext (3.3 V switched) | ON when GPIO36 = LOW; sensor takes 3.3–5 V |
| A02YYUW GND (pin 2) | GND | Common ground |
| A02YYUW TX (pin 4) | GPIO4 (UART1 RX) | 9600 baud, 4-byte frames |
| A02YYUW RX (pin 3) | Not connected | Mode select, left default |
| Float switch (danger level) | GPIO7 + 100 kΩ pull-up to 3V3, 1 kΩ series, 100 nF to GND | Active LOW, independent backup |
| Solar + via 100 kΩ / 22 kΩ divider | GPIO2 (ADC1) | Panel health diagnostics |
| 18650 pack (via 1S BMS + 2 A polyfuse) | 2-pin battery connector | Also wired to CN3791 BAT+/BAT− |
| Battery divider (on-board) | GPIO1 ADC, GPIO37 enable (LOW) | VBAT − 390 k − GPIO1 − 100 k − GND |
| SX1262 (on-board) | NSS 8, SCK 9, MOSI 10, MISO 11, RST 12, BUSY 13, DIO1 14 | Do not reuse these pins |
| From | To (Heltec V3 — gateway) | Note |
|---|---|---|
| A7670 board TXD | GPIO4 (UART1 RX) | Bare module UART is 1.8 V: use a level-shifted breakout |
| A7670 board RXD | GPIO5 (UART1 TX) | 115200 baud AT commands |
| A7670 board VIN / GND | 5 V buck output / GND | 2.8 A peaks; 1000 µF at board |
| Siren MOSFET gate (AO3400A) | GPIO6 via 100 Ω, 100 kΩ to GND | Low-side switch + flyback diode |
| Indoor buzzer (via NPN) | GPIO7 | Local alert |
| PRG button (on-board) | GPIO0 | Silence/acknowledge alarm |
| Heltec 5V pin | LM2596 5.0 V output | From 12 V SLA |
The A7670 figures (1.8 V UART domain, 3.4–4.2 V VBAT, 2.8 A peak) come from SIMCom’s A7670 Series Hardware Design V1.00. Most A7670 breakout boards sold locally add a regulator and level shifter; check yours before connecting 3.3 V logic.
Bill of materials (approx. BDT)
| Part | Qty | Approx. BDT (approx., Nov 2026, local market) |
|---|---|---|
| Heltec WiFi LoRa 32 V3 (868/915 MHz version) + antenna | 2 | 7,000–8,500 |
| A02YYUW waterproof ultrasonic (JSN-SR04T is a cheaper, less robust option) | 1 | 2,800–3,500 |
| 6 V 2 W solar panel | 1 | 500–800 |
| CN3791 MPPT charger module (6 V version) | 1 | 350–500 |
| 18650 cells (genuine) + 1S BMS + holder | 2 | 1,100–1,600 |
| Float level switch, resistors, capacitors, polyfuse | 1 set | 300–500 |
| IP65 enclosures + cable glands (node and gateway) | 2 | 900–1,400 |
| A7670C/E 4G breakout + SIM | 1 | 1,800–2,800 |
| 12 V 7 Ah SLA + float charger + LM2596 buck | 1 | 2,000–2,700 |
| 12 V electronic siren + AO3400A + 1N5819 + buzzer | 1 | 450–750 |
| GI pipe / bracket for the node pole | 1 | 800–1,500 |
| Total | ~18,000–24,500 |
Fake 18650 cells are common; read how to spot fake electronic components before buying.
LoRa range estimate: an honest link budget
Assumptions: 923 MHz, SF10, 125 kHz bandwidth, TX +14 dBm, node antenna 2 dBi, gateway antenna 5 dBi, 2 dB cable loss. Receiver sensitivity ≈ −174 + 10·log(125000) + NF 6 − 15 (SF10 SNR limit) ≈ −132 dBm. Link budget = 14 + 2 + 5 − 2 + 132 = 151 dB. Keeping a 15 dB fade margin for rain, foliage and multipath leaves 136 dB of allowed path loss.
Low antennas over flat land follow the plane-earth model: PL ≈ 40·log(d) − 20·log(ht) − 20·log(hr). With the node at 3 m and the gateway at 12 m, 136 dB gives d ≈ 15 km over open water. Adding 15–20 dB clutter loss for trees and tin houses brings it to about 4–7 km. Our working estimate: 2–5 km in villages, 10 km+ across an open haor. At 5 km the mid-path Fresnel radius is about 20 m, so antenna height matters more than TX power. These are estimates, not measurements; do an RSSI/SNR walk test before fixing the site.
Power budget: will a 2 W panel survive the monsoon?
| Phase (per wake-up) | Current | Time | Charge |
|---|---|---|---|
| Boot + sensor on + 7 readings | ~53 mA (ESP32-S3 ~45 + sensor ≤8) | 1.5 s | 80 mA·s |
| LoRa TX, SF10, 12-byte packet | ~165 mA (worst case, max PA + MCU) | 0.29 s | 48 mA·s |
| Wait for ACK (RX) | ~50 mA | 0.6 s | 30 mA·s |
| Total per wake | 158 mA·s = 0.044 mAh |
- Deep sleep: the Heltec_ESP32_LoRa_v3 library author measured ~24 µA (timer wake); we budget 60 µA with charger leakage = 1.4 mAh/day.
- Normal mode (every 5 min, 288 wakes): 288 × 0.044 = 12.7 mAh, plus sleep, gives ~14 mAh/day.
- Alert mode (every 1 min, 1440 wakes): ~65 mAh/day.
- Battery: 2 × 3000 mAh in parallel, 80% usable = 4800 mAh. That is ~74 days of non-stop alert mode with zero sun.
- Solar: a dark monsoon day with 1.5 peak-sun-hours: 2 W × 1.5 h × 70% ≈ 2.1 Wh ≈ 570 mAh at 3.7 V, far above the load.
Time-on-air (SF10/125 kHz, 12 bytes, CR 4/5, 8-symbol preamble) is about 289 ms from Semtech’s formula. The real risk is a board that never truly sleeps: 1 mA instead of 60 µA means 24 mAh/day from sleep alone. Measure it.
Step-by-step build guide
Step 1: Bench-test both Heltec boards
In Arduino IDE select “Heltec WiFi LoRa 32(V3)” and install RadioLib. The snippets use the RadioLib 7.x begin() signature (newer major versions take a config struct, so pin the version). Never transmit without an antenna.
Step 2: Wire the node power path
Connect panel → CN3791 IN, CN3791 BAT → BMS → 18650 pack → polyfuse → Heltec battery connector. Do not plug USB in the field, or two chargers will fight over the same cells.
Step 3: Connect and test the ultrasonic sensor
Power the sensor from Vext so it is fully off in sleep. Check raw readings against a tape measure at 0.5, 1, 2 and 4 m above a bucket of water.
Step 4: Mount and calibrate on site
Fix the sensor on a GI arm well clear of the bank or pier: the 60° beam is about 4.6 m wide at 4 m range. The highest flood must stay 25 cm below the sensor face (3 cm blind zone plus waves). Measure H against the nearest BWDB staff gauge so your readings match the official “danger level”.
Step 5: Build the gateway
Build the 12 V SLA + float charger + LM2596 stage (set 5.0 V before connecting). Test the A7670 by hand (AT, AT+CSQ, one SMS), then wire the siren MOSFET.
Step 6: Set thresholds and run a soak test
Agree WATCH/WARNING/DANGER levels with the Union Parishad or BWDB officer, then run 7+ days before connecting the outdoor siren.
Firmware architecture (explained 100%)
| Module | Runs on | What it does |
|---|---|---|
| config.h | Both | Pins, radio settings, site constants (H, thresholds, intervals) |
| Sonar driver | Node | Vext power, frame parsing, median of 7, range checks |
| Rate estimator | Node + gateway | Least-squares slope over a 6-sample window kept in RTC memory |
| Packet + radio | Node | Packed struct (ID, seq, level, rate, VBAT, flags), AES-128, TX, ACK, 2 retries |
| Sleep scheduler | Node | 5 min normally, 1 min if rising > 50 mm/h or float tripped |
| Receiver + validator | Gateway | Decrypt, check ID, drop duplicates/replays, ACK, log RSSI/SNR |
| Alarm state machine | Gateway | NORMAL/WATCH/WARNING/DANGER/NODE-OFFLINE with k-of-n persistence and hysteresis |
| Alert dispatcher | Gateway | Siren, SMS via A7670, Telegram, rate limiting |
| Dashboard + logger | Gateway | Live chart, CSV log, OTA |
Data flow and timing: wake → sensor on → 300 ms settle → 7 readings (~1 s) → sensor off → level and rate → TX (~0.29 s) → ACK → sleep. The gateway listens continuously; each valid packet updates the node history, re-computes the rate over a longer 30–60 min window and steps the state machine.

Rate-of-rise alarm logic and false-alarm handling
- WATCH: level > warning level or rise > 100 mm/h; faster sampling, dashboard flag.
- WARNING: level within 300 mm of the danger level or rise > 200 mm/h for 3 consecutive packets. SMS + Telegram.
- DANGER: level ≥ danger level on 2 of the last 3 packets, or the float switch trips. Siren + SMS to everyone.
- Hysteresis: a state only clears after the level stays 50 mm below its threshold for 30 minutes.
- Plausibility: reject jumps > 500 mm in 5 minutes (birds, debris); flag a value “stuck” for 6 hours.
- Node silent for 3 intervals: send “NODE OFFLINE”, never a flood alarm.
These are starting values for a small canal; a flashy hill stream and a slow river need different site-specific thresholds.
Code: the node firmware (about 50% shown)
Below is roughly half of the code: configuration, sensor driver, rate calculation and the node’s wake-measure-send-sleep cycle. The gateway, encryption/ACK, calibration and alarm engine are not shown.
// config.h - Heltec WiFi LoRa 32 V3 node (pins: Espressif variant file)
#pragma once
#define PIN_LORA_NSS 8
#define PIN_LORA_DIO1 14
#define PIN_LORA_RST 12
#define PIN_LORA_BUSY 13
#define PIN_VEXT 36 // LOW = Vext ON (sensor power)
#define PIN_SONAR_RX 4 // A02YYUW TX -> UART1 RX
#define PIN_SONAR_TX 5 // unused (sensor RX not connected)
#define PIN_FLOAT_SW 7 // danger float switch, active LOW
#define LORA_FREQ_MHZ 923.2 // ASSUMPTION - confirm with BTRC
#define LORA_BW_KHZ 125.0
#define LORA_SF 10
#define LORA_CR 5 // 4/5
#define LORA_TX_DBM 14
#define TCXO_VOLT 1.8 // Heltec V3 TCXO on DIO3
#define SENSOR_H_MM 5200 // sensor face above gauge zero (survey)
#define T_NORMAL_S 300
#define T_ALERT_S 60
// A02YYUW frame: 0xFF, H, L, SUM (SUM = low 8 bits of 0xFF+H+L)
#include <algorithm>
int readSonarMM(HardwareSerial &s, uint32_t timeoutMs = 300) {
uint8_t b[4]; uint32_t t0 = millis();
while (millis() - t0 < timeoutMs) {
if (s.available() < 4) { delay(2); continue; }
b[0] = s.read();
if (b[0] != 0xFF) continue; // hunt for header
s.readBytes(&b[1], 3);
if ((uint8_t)(b[0] + b[1] + b[2]) != b[3]) continue; // bad checksum
int mm = (b[1] << 8) | b[2];
return (mm < 30 || mm > 4500) ? -1 : mm; // blind zone / range
}
return -1;
}
int medianSonarMM(HardwareSerial &s, int n) { // n <= 9
int v[9], k = 0;
for (int i = 0; i < n; i++) { int r = readSonarMM(s); if (r > 0) v[k++] = r; }
if (k < n / 2 + 1) return -1; // too many bad echoes
std::sort(v, v + k);
return v[k / 2];
}
// Least-squares slope of the last RATE_N levels -> mm per hour
#define RATE_N 6
RTC_DATA_ATTR uint32_t clockS = 0, tS[RATE_N]; // clockS advanced before sleep
RTC_DATA_ATTR float yMM[RATE_N];
RTC_DATA_ATTR uint8_t nBuf = 0;
int16_t updateRate(uint16_t level_mm) {
if (nBuf == RATE_N) { // slide the window
memmove(tS, tS + 1, (RATE_N - 1) * sizeof(uint32_t));
memmove(yMM, yMM + 1, (RATE_N - 1) * sizeof(float));
nBuf--;
}
tS[nBuf] = clockS; yMM[nBuf] = level_mm; nBuf++;
if (nBuf < 3) return 0;
float sx = 0, sy = 0, sxx = 0, sxy = 0;
for (int i = 0; i < nBuf; i++) {
float x = (tS[i] - tS[0]) / 3600.0f; // hours since oldest sample
sx += x; sy += yMM[i]; sxx += x * x; sxy += x * yMM[i];
}
float den = nBuf * sxx - sx * sx;
return den > 1e-6f ? (int16_t)((nBuf * sxy - sx * sy) / den) : 0;
}
#include <RadioLib.h>
SX1262 radio = new Module(PIN_LORA_NSS, PIN_LORA_DIO1, PIN_LORA_RST, PIN_LORA_BUSY);
struct __attribute__((packed)) FloodPkt {
uint8_t nodeId, flags; uint16_t seq, level_mm, vbat_mv; int16_t rate_mmph;
};
RTC_DATA_ATTR uint16_t seq = 0;
void setup() {
pinMode(PIN_FLOAT_SW, INPUT); pinMode(PIN_VEXT, OUTPUT); digitalWrite(PIN_VEXT, LOW);
Serial1.begin(9600, SERIAL_8N1, PIN_SONAR_RX, PIN_SONAR_TX);
delay(300); // sensor settle (tune)
int dist = medianSonarMM(Serial1, 7);
digitalWrite(PIN_VEXT, HIGH); // sensor OFF
FloodPkt p = {}; p.nodeId = 1; p.seq = seq++;
if (dist < 0) p.flags |= 0x01; // bit0: sensor fault
else { p.level_mm = SENSOR_H_MM - dist; p.rate_mmph = updateRate(p.level_mm); }
if (digitalRead(PIN_FLOAT_SW) == LOW) p.flags |= 0x02; // bit1: float
p.vbat_mv = readVbatMv(); // GPIO37 LOW, analogReadMilliVolts(1) x 4.9 (not shown)
if (radio.begin(LORA_FREQ_MHZ, LORA_BW_KHZ, LORA_SF, LORA_CR,
0x12, LORA_TX_DBM, 8, TCXO_VOLT) == RADIOLIB_ERR_NONE) {
radio.transmit((uint8_t*)&p, sizeof(p)); // (ACK/retry not shown)
radio.sleep(); }
uint32_t T = (p.rate_mmph > 50 || (p.flags & 0x02)) ? T_ALERT_S : T_NORMAL_S;
clockS += T + millis() / 1000;
esp_sleep_enable_timer_wakeup((uint64_t)T * 1000000ULL);
esp_deep_sleep_start();
}
void loop() {}
That is about 50% of the project code. The 1.8 V TCXO value matches Meshtastic’s Heltec V3 variant.
Want the complete production firmware? It includes the gateway firmware (receiver, ACK, replay rejection), the full NORMAL/WATCH/WARNING/DANGER alarm engine with persistence and hysteresis, the on-site calibration routine, AES-128 encryption, SMS alerts via A7670, Telegram alerts, a live web dashboard, CSV data logging, node-offline detection and OTA updates. Message us on WhatsApp to get the full source code, circuit files and help building it.
Testing and accuracy you can expect
- Level accuracy: DFRobot publishes no accuracy figure; in our experience with similar ultrasonic sensors expect about ±1–2 cm on calm water, worse with waves.
- Temperature: sound speed is 331.3 + 0.606·T m/s, so a 10 °C swing shifts a 3 m reading by about 5 cm if uncompensated. Re-check against the staff gauge each season.
- Bench rate test: fill a bucket slowly and confirm WATCH/WARNING trigger and clear with hysteresis.
- Range test: log RSSI/SNR along the route; keep 10 dB margin above the SF10 limit.
| Problem | Likely cause | Fix |
|---|---|---|
| Readings jump randomly | Beam hits bank, pier or vegetation | Move arm further out, check the 60° cone |
| Always −1 (timeout) | TX/RX swapped, Vext not ON | Sensor TX → GPIO4; GPIO36 LOW |
| radio.begin() error −706/−707 | TCXO setting mismatch | Use 1.8 V TCXO on Heltec V3 |
| Battery drains in weeks | Board not in deep sleep, OLED on, USB plugged | Measure sleep current, disable OLED |
| Gateway resets when sending SMS | Modem 2.8 A peak sags the 5 V rail | 3 A buck, 1000 µF bulk cap, short thick wires |
| Siren false triggers | Single-packet decision | Use 2-of-3 persistence and plausibility checks |
Safety and responsibility
This is a student/community prototype; it does not replace FFWC/BWDB warnings, and people must follow official evacuation advice. Keep the 220 V float-charger wiring in a closed, earthed box. Shade and ventilate the node enclosure, because lithium cells overheat in summer sun. Install poles over water with a partner, never during a flood.
Future upgrades and real-world uses
- Add an upstream tipping-bucket rain gauge for earlier warning.
- Switch to LoRaWAN with a self-hosted network server for 20+ nodes along a river.
- Use a 4–20 mA pressure sensor or 60 GHz radar for deep rivers (120 Ω shunt → 0.48–2.4 V on the ADC).
- For an M.Sc. extension, predict the level 1–3 hours ahead with an LSTM or TinyML model (see our M.Sc. thesis topics and TinyML project ideas).
- Product angle: Union Parishads, NGOs, fish farms and shrimp ghers need cheap level alerts. Make a PCB with our KiCad to JLCPCB guide.
Frequently asked questions
Solar or battery water-level sensors that report over LoRa radio to a gateway, which checks level and rate of rise and raises alarms by siren, SMS or internet.
Ultrasonic is cheap and non-contact but limited to 4.5 m and sensitive to temperature. Pressure sensors suit deep rivers but need silt cleaning. Radar is most accurate and most expensive.
Estimated 2–5 km through villages and 10 km+ over open water with a high gateway antenna. Height and line of sight matter more than TX power.
Median filtering, plausibility limits, k-of-n persistence, hysteresis, a second independent sensor (float switch), and a separate “node offline” message.
Yes. With LoRa P2P the gateway decides locally and sounds the siren without Wi-Fi; SMS needs only basic cellular coverage.
About 18,000–24,500 BDT for one node and one gateway with siren and SMS (approx., Nov 2026).
Conclusion
A LoRa flood monitoring system is one of the few student projects that can genuinely save lives in Bangladesh. The hardware is simple; the engineering is in a realistic link budget, a node that truly sleeps, rate-of-rise logic and honest false-alarm handling. Test on a bucket, then a real canal, and clear the frequency with BTRC before a permanent installation.
Want to build a flood early-warning system for your thesis, your village or your NGO? We design custom PCBs, firmware and complete working prototypes for students and companies. Message us on WhatsApp or use the contact form. You can write in Bangla or English.