← Projects

LoRa IoT Sensor Network with Real-Time Dashboards

2025 · LoRa, ESP32, PHP/MySQL, Kotlin · Course project

A lot of useful monitoring happens where there is no Wi-Fi and no mobile signal: soil moisture in a field, water level during a flash flood, telemetry from a boat far from the coast. Most IoT demos quietly assume a network is already there. For my CSE323 Operating Systems Design project at North South University, my teammate Nazifa Tasnim Mahee and I wanted to build something that does not, and to carry the data all the way to a screen you can actually look at.

The sender node is a Seeeduino LoRaWAN board with an MQ2 gas sensor and a soil moisture sensor attached. It sends short text packets over LoRa to a gateway, which is an Arduino Uno with a Dragino LoRa shield and a small OLED showing the last packet received. The Uno passes each line over serial to an ESP32, and the ESP32 is the only part that needs Wi-Fi. It strips the packet down to a sensor name and a value, wraps them in JSON and posts them to a PHP script, which writes the reading into a MySQL table with a prepared statement.

The sender node on a breadboard: a Seeeduino LoRaWAN board with an antenna, an MQ2 gas sensor and a soil moisture probe
The sender node, with the MQ2 gas sensor and the soil moisture probe.
The gateway: an Arduino Uno with a Dragino LoRa shield and antenna, wired to an ESP32 and a small OLED screen
The gateway. The Uno and LoRa shield receive packets, and the ESP32 forwards them over Wi-Fi.

Operating system ideas on a microcontroller

The part I enjoyed most was using course concepts where there is no operating system at all. The sender runs a non-preemptive round-robin scheduler, written as a small state machine: a variable says which task is next, the task runs, and the variable flips to the other sensor. It is simple, but it means neither sensor can starve the other.

Readings do not go straight onto the radio. Each one is pushed into a small circular buffer, and the buffer’s head, tail and count are stored in flash through the FlashStorage library. Because the queue state lives in flash rather than RAM, unsent readings are still there after a complete power loss. When the buffer fills, the oldest record is overwritten.

On the application side, one PHP endpoint returns the latest readings as JSON, and two independent clients read it. The web dashboard uses Chart.js, and the Android app is native Kotlin, using Retrofit for networking and MPAndroidChart for graphs. Both refresh every few seconds.

The web dashboard with line charts for the MQ2 and soil sensors and a table of the latest readings
The web dashboard, built with Chart.js.
The Android app showing the same two sensor charts and a list of recent readings
The Android app reading the same endpoint.

What it does not do yet

We tested the full chain and it behaved as expected. I have no range or battery figures from this build, so I will not claim any. Reading the code again, the reliability story has gaps. The buffer protects against the sender losing power, but a reading leaves the buffer when it is sent, not when delivery is confirmed. The gateway also drops a reading if Wi-Fi is down rather than retrying.

The rest of what I would do next is on our own future-work list: support for several sender nodes (the node ID is currently fixed), logins for the web and mobile clients, CSV export, push alerts when a value crosses a threshold, and deep sleep on the sender for battery life.

Status: CSE323 course project, Summer 2025, North South University.