Edge to
Cloud

How a tiny sensor can save a life

LoRaWAN, MQTT and AWS IoT for disaster early warning in Nepal

Your guide on this trek

Peter Karki

Peter
Karki

RoleSenior Interactive Developer
Experience5 years in development
StudyingMaster’s in Data Science
How IoT startedTinkering with hardware for my social media content, and I never stopped
Development5 years building interactive things
HardwareTinkering for social media content
IoT and LoRaRadios, sensors, real hills
TodayThis talk

The river is rising.

The village has no signal.

Who warns them?

No service23%
02:00
Monsoon night, upstream village
Searching for network…
0 warnings received

This isn’t hypothetical. 27–28 September 2024, Kathmandu Valley.

240 mmof rain in 24 hours in the valley
236lives lost across Nepal by early October
2 mBagmati above its danger level

Forecasters saw the rain coming. The warnings didn’t say clearly what it meant for each street and each river bank.

Sources: Kathmandu Post via AFP; Copernicus Global Flood Monitoring; The Guardian via ACAPS; Imperial College London rapid study

Your turn: how would you warn them?

Call everyoneThe mobile network is down, or was never there.
Post on social mediaIt’s 2 AM. Everyone’s asleep, and many have no data.
Sound a sirenWho presses the button, and how do they know the water is coming?

Every answer needs the same thing first: someone, or something, that knows the water is rising.

The route for the next 30 minutes

  1. Waypoint 1The toolboxWhat can sensors and satellites see?
  2. Waypoint 2Why the hills are hardWhy warnings arrive late
  3. Waypoint 3Follow one readingFrom riverbank to phone
  4. Waypoint 4The hills fight backMy field research
  5. SummitYour turn, then questions

Waypoint 1 of 4

The toolbox

What can a tiny sensor, and a satellite, actually see?

What is IoT?

The Internet of Things: ordinary objects that sense the world and report it over a network.

Thing+sensor+network=IoT

SmartwatchCounts your steps
Water tank sensorTells you it’s empty
Smart meterReports electricity use
Rain gauge on a hillMeasures rain every minute
18.5

billion connected IoT devices in 2024

21.1 billionexpected by the end of 2025
39 billionexpected by 2030

That’s already more than two for every person on Earth. Laptops and phones aren’t even counted.

Source: IoT Analytics, State of IoT 2025

The IoT protocol family, by distance

Each ring on the map is how far one radio reaches from the same sensor.

Bluetooth LEAbout a room. Phones, earbuds, wearables.
Zigbee and ThreadA home, hopping device to device. Smart bulbs, door sensors.
Wi-FiA building. Cameras, smart plugs.
Cellular IoTKilometres, through cell towers. NB-IoT and LTE-M: meters, trackers.
LoRaWANKilometres, no towers needed. Rivers, farms, hillsides.
MatterNot a radio. A common language so smart home devices from any brand work together, over Wi-Fi and Thread.
MQTTNot a radio either. The messaging rules that carry sensor data to the cloud. More on this soon.

Eyes in the sky, ears on the ground

From orbit

Remote sensing: satellites and drones measuring Earth from far away. They see a whole region at once: rainfall, flood extent, landslide scars, glacial lakes.

But a satellite only passes over every few days.

From the ground

IoT sensors sit in one exact spot on a riverbank or a slope. They report water level, soil moisture and tilt every minute.

But each one covers only a small area.

Together you get the big picture and the ground truth.

Radar sees through monsoon clouds

Normal cameras are blind under monsoon clouds. Sentinel-1 uses radar instead.

Through cloud and rain, day or nightIdeal for mapping where a flood has spread. Watch the sweep fill in the flooded valley.
But it passes over every few daysGreat for mapping the damage. Too slow to wake a village at 2 AM.

Source: European Space Agency, Sentinel-1 mission

Waypoint 2 of 4

Why the hills are hard

If we can sense the danger, why does the warning still arrive late?

Floods.
Landslides.
Glacial lake outbursts.

Every monsoon. Often at night. Often far from any phone signal.

Why warnings arrive late

  • Remote valleys have no mobile signal
  • Mountains block radio waves
  • News travels slower than water

Tsho Rolpa, Dolakha. One of Nepal’s biggest glacial lakes, at 4,580 m.

2000Lake lowered by 3 mExperts had recommended 20 m. The budget stopped at three.
2015Sensors installedA new system to text phones when the water rises.
2018Updates went quietWeak internet, costly data and no mobile signal meant the readings stopped getting out.

The sensor worked.

The network didn’t.

Sources: Kathmandu Post (2015, 2018, 2026); Wikipedia

Waypoint 3 of 4

Follow one reading

02:00 AM. A sensor reads 312 cm. Let’s follow that one number all the way to a phone.

From the edge to the cloud, in four steps

Step 1, at the edgeSense

A small device on the riverbank measures water level or soil moisture.

Step 2, over the airSend

LoRaWAN radio carries it kilometres to a gateway.

Step 3, in the cloudThink

AWS stores it, checks it and learns from it.

Step 4, to peopleAct

An SMS, a siren or a dashboard warns people in time.

Anatomy of a riverbank sensor

PowerSmall solar panel and a battery
VoiceLoRa radio and antenna, kilometres of range
BrainESP32 microcontroller, costs about as much as lunch
SenseUltrasonic sensor measures the distance to the water

Why not just use Wi-Fi or 4G?

BluetoothAbout a room. Needs a phone nearby.
Wi-FiAbout a house. Needs a router and steady power.
4GKilometres. Needs a tower and a SIM, and drains batteries.
LoRaKilometres, on a small battery. Needs one gateway for a whole valley.

On a hillside with no towers and no power lines, only one of these works.

Fun fact: the LoRa distance record

1,336 km

From trackers on a fishing boat off the coast of Portugal to a gateway in the Canary Islands.

An earlier record of 832 km was set from a weather balloon, transmitting at just 25 milliwatts.

Source: The Things Network

How LoRa talks: it chirps

Each LoRa message is a rising whistle, a “chirp”. Like a bird you can still hear in a noisy forest, a chirp survives through noise and over distance.

SF7Short chirp. Fast, shorter reach.
SF12Long chirp. Slow, much further.

The spreading factor (SF) is how slowly you whistle. My field tests swept every SF from 7 to 12.

MQTT: how devices talk

It works like YouTube. A sensor posts to a channel, called a topic. The broker delivers it. Everyone subscribed gets it at once.

PublisherA water-level sensor on the riverbanknepal/sindhupalchok/river/level
BrokerAWS IoT Corereceives every message and hands it to whoever subscribed.
SubscribersFarmer’s phone app. District disaster office. SMS to the village.

Fun fact: MQTT was designed in 1999 to monitor oil pipelines over satellite links, where every byte cost money. That’s why it fits on a tiny ESP32.

What one message actually looks like

Topic: nepal/sindhupalchok/river/level

{
  "site":       "sindhupalchok-river-01",
  "level_cm":   312,
  "rain_mm_hr": 41,
  "battery_v":  3.9,
  "time":       "2026-07-14T02:00:00+05:45"
}
TinyAbout 150 bytes. One photo on your phone is thousands of times bigger.
ReadablePlain JSON that any language can parse.
312 cmThe only number that matters at 2 AM.

The AWS pipeline, as a metro map

Alert line: from sensor to SMS in seconds

  1. SensorESP32 + LoRa
  2. Gatewayradio to internet
  3. IoT CoreMQTT broker
  4. Rulesroutes each message
  5. Lambdais the water too high?
  6. SNSsends the SMS

Learning line: months of readings become predictions

  1. IoT Corecopies every message
  2. S3stores everything
  3. Athenaquery with SQL
  4. QuickSightdashboards
  5. SageMakerlearns to predict

The whole alert fits on one slide

1. IoT rule

SELECT * FROM 'nepal/+/river/level'
WHERE level_cm > 300

The + is a wildcard: every river in Nepal, one rule.

2. Lambda function

import boto3
sns = boto3.client("sns")

def handler(event, context):
    level = event["level_cm"]
    sns.publish(
        TopicArn=ALERT_TOPIC,
        Message=f"Flood warning: river at {level} cm."
    )

Why three minutes, not three seconds?

02:00:00The reading crosses the line312 cm, above the 300 cm alert level.
02:00:02Over the ridge and into AWSLoRa to the gateway, MQTT to IoT Core, the rule matches. A couple of seconds.
02:01, 02:02Two more readings, to be sureOne splash or a branch under the sensor shouldn’t wake a whole village at 2 AM.
02:03The alert goes outLambda calls SNS. Every subscribed phone buzzes.

The rule on the last slide alerts on the very first reading. Waiting for a few in a row is the first upgrade you’d make.

Same village.

Same night.

Different ending.

Three minutes after the river crossed the line, every subscribed phone buzzed.

No service22%
02:03
Monsoon night, upstream village
River Alert, nowFlood warning: river at 312 cm. Move to higher ground now.
1 warning received
1 reading

“Soil moisture is 32%.” So what?

1,000,000 readings

“This slope slid before after days of heavy rain, and today looks the same.”

That’s a prediction.

Change the sensor, keep the pipeline

AgricultureSoil moisture, temperature“Water your crop today” SMS to farmers
FloodRiver water levelEarly warning for villages downstream
LandslideSoil moisture and tiltAlert when a slope starts moving
Glacial lakeLake water levelWarning for the valleys below

Waypoint 4 of 4

The hills fight back

Theory is easy. Then I carried the radios up real hills.

I carried radios up three hills

LoRa boards used in the field
RadioRa-08H LoRa module + ESP32
PositionGPS module, tagged on every reading
LoggingmicroSD card
Settings sweptSF7 to SF12, at 2, 8 and 14 dBm
MeasuredSignal strength (RSSI) and quality (SNR)
HillsMankal, Raniban, Dharmasthali
Hilltop test site

This is a test site

The radio sits on my backpack. The target is the next ridge. Between them: grass, forest, cloud, and a lot of air.

What went wrong (a lot)

The radio refusedThe factory firmware only spoke LoRaWAN, not point-to-point. So I wrote my own.
Getting thereMotorbike, then on foot. One site was such a climb I never went back.
Racing the sunsetSome sweeps ran past dark, lit only by the little screen.
Breadboard prototype on a cutting mat

Built on a cutting mat, tested on a hill

Spaghetti is a featureBreadboard and jumper wires: easy to fix on a hilltop with no soldering iron.
“Resume log?”After a restart, the firmware offers to pick up the log where it stopped, instead of starting the whole sweep again.

Real IoT is 20% code and 80% batteries, weather and walking.

What the hills taught me

Line of sight is everythingA ridge between two radios can kill a link that works fine in the open.
Reach costs speedA higher spreading factor reaches further, but sends slower and uses more battery.
[Your key finding][e.g. signal fell from __ dBm to __ dBm over __ km at __]
Machine learning plans the hikeA path-loss model predicts where a sensor will be heard, before anyone climbs.

Live demo: let’s send an alert

On my deskESP32 publishes

I’ll fake a rising river by moving my hand towards the sensor.

In AWSRule and Lambda fire

Watch the MQTT test client in the AWS console.

In this roomA phone buzzes

Whoever’s number is subscribed gets the SMS.

If the Wi-Fi fails, that’s also a lesson about networks.

Sense.
Send.
Think.
Act.

One reading, from a riverbank to a phone, in four moves. Everything else is detail you can learn one weekend at a time.

Build your first early-warning system this month

  1. Week 1Get an ESP32Add a LoRa module, or start with Wi-Fi
  2. Week 2Open an AWS accountSet a budget alert first, then use the Free Tier
  3. Week 3Publish one messageSend one MQTT message to AWS IoT Core
  4. Week 4Send one alertTrigger an SMS with Lambda and SNS

One sensor, one Lambda, one alert. That’s the first heartbeat of an early-warning system.

Remember Tsho Rolpa?

The sensor worked.

The network didn’t.

Now you know how to build the network.

Questions?

Edge to Cloud: how a tiny sensor can save a life

Open on your phone

Timer starts on first key
Next: Right, Space, click, clicker
Back: Left
N: speaker notes and timer
O: all slides
F: fullscreen
H: this help
H for help
Building the valley