Liliana
Published © CC BY

Smart Forest & Water Quality Monitoring System Using LoRaWAN

This project aims to build a low-power, scalable environmental monitoring system for protecting natural ecosystems.

AdvancedShowcase (no instructions)Over 1 day16
Smart Forest & Water Quality Monitoring System Using LoRaWAN

Things used in this project

Hardware components

Seeed Studio SenseCAP S2100 LoRaWAN Data Logger/DTU
×1
Seeed Studio SenseCAP S2105 Soil Sensor
×1
Seeed Studio SenseCAP S2101 Air Quality Sensor
×1
SenseCAP M2 Multi-Platform LoRaWAN Indoor Gateway(SX1302) - EU868
Seeed Studio SenseCAP M2 Multi-Platform LoRaWAN Indoor Gateway(SX1302) - EU868
×1

Story

Read more

Schematics

System Architecture

Board Diagram

Code

Node-RED Flow

JSON
Example JSON
[
  {
    "id": "mqtt_in",
    "type": "mqtt in",
    "name": "LoRaWAN Data In",
    "topic": "sensors/+/uplink",
    "broker": "mqtt_broker",
    "x": 160,
    "y": 100,
    "wires": [["parser"]]
  },
  {
    "id": "parser",
    "type": "json",
    "name": "Parse Sensor Data",
    "x": 360,
    "y": 100,
    "wires": [["function"]]
  },
  {
    "id": "function",
    "type": "function",
    "name": "Environmental Rules",
    "func": "let data = msg.payload;\n\nif (data.temperature > 40 && data.soil_moisture < 20) {\n    msg.payload = {alert: '🔥 Wildfire Risk Detected', data};\n} else {\n    msg.payload = {status: 'normal', data};\n}\nreturn msg;",
    "x": 560,
    "y": 100,
    "wires": [["dashboard","alert"]]
  },
  {
    "id": "dashboard",
    "type": "ui_chart",
    "name": "Environment Dashboard",
    "x": 760,
    "y": 80,
    "wires": []
  },
  {
    "id": "alert",
    "type": "ui_toast",
    "name": "Alert Notification",
    "x": 760,
    "y": 140,
    "wires": []
  }
]

Lambda Function

Python
import json

def lambda_handler(event, context):
    temp = event.get('temperature', 0)
    moisture = event.get('soil_moisture', 0)

    risk = "LOW"

    if temp > 35 and moisture < 20:
        risk = "HIGH"

    return {
        "risk": risk,
        "data": event
    }

Basic ML Model

Python
Scikit-learn
import pandas as pd
from sklearn.ensemble import RandomForestClassifier

# Load dataset
data = pd.read_csv("forest_data.csv")

X = data[['temperature','humidity','soil_moisture','wind_speed']]
y = data['label']

# Train model
model = RandomForestClassifier()
model.fit(X, y)

# Test prediction
sample = [[36, 20, 15, 4]]
prediction = model.predict(sample)

print("Fire Risk:", prediction)

Credits

Liliana
6 projects • 4 followers

Comments