A production-ready IoT monitoring system for real-world temperature & humidity tracking. Built with a secure ingestion pipeline, realtime dashboard, device heartbeat, alerting system, and mobile-friendly responsive UI.
Realtime Dashboard: https://io-t-temperature-humidity-monitorin.vercel.app/
Repository: https://github.com/mA4rK0/IoT-Temperature-Humidity-Monitoring-System
flowchart TD
%% Device layer
subgraph DEVICE["Edge Device"]
ESP32["ESP32 (esp32-01) + DHT22<br/>β’ Read temp & humidity<br/>β’ Heartbeat (periodic POST)"]
DEVTOOLS["Serial / USB / OTA<br/>(development & debug)"]
end
%% Network
WIFI["Wi-Fi / Internet<br/>(ESP32 β Vercel API)"]
%% Server layer
subgraph VERCEL["Vercel β Next.js API"]
API["/api/ingest<br/>β’ Validate Authorization header<br/>β’ Sanitize payload<br/>β’ Insert β Supabase (sensor_data)<br/>β’ Trigger alerts & record β alerts table"]
end
%% Database & realtime
subgraph SUPABASE["Supabase"]
DB["Postgres: sensor_data table<br/>& alerts table"]
RT["Realtime: broadcast INSERT events"]
end
%% Frontend & clients
DASH["Next.js Dashboard<br/>β’ Realtime subscribe (Supabase)<br/>β’ Charts, recent readings, device status<br/>β’ Mobile-optimized UI"]
CLIENT["Client: Browser / Mobile"]
%% Alerting
TELE["Telegram Bot (Bot API)<br/>β’ Send alert messages to chat"]
%% Flow connections (top β bottom)
ESP32 -->|POST JSON β| WIFI
WIFI --> API
API -->|write| DB
DB -->|broadcast| RT
RT --> DASH
DASH --> CLIENT
API -->|trigger alert| TELE
DEVTOOLS --> ESP32
- ESP32 reads temperature & humidity from a DHT22 sensor.
- Device sends a secure HTTP POST (JSON) to a Next.js API endpoint using a
Authorizationheader. - API validates the device β inserts the data into Supabase PostgreSQL.
- Supabase Realtime instantly broadcasts new rows to the dashboard.
- Next.js Dashboard updates charts + tables + device status in realtime.
- Alerting engine triggers Telegram messages when thresholds exceed limits.
- Heartbeat system automatically marks device as Online or Offline.
- π‘ Realtime temperature & humidity monitoring
- π ESP32 β Next.js ingestion pipeline
- ποΈ Supabase PostgreSQL storage
- β‘ Supabase Realtime push updates
- π‘οΈ Secure device authentication (
Authorization) - π¨ Modern, animated dashboard UI (Next.js + Tailwind + Framer Motion)
- Fully responsive
- Touch-friendly charts
- Compact data layout for phones
- Mobile status widgets
- Telegram Alerts for high/low temperature or humidity
- Threshold-based warnings
- Timestamp included in alert payload
- Optional silent mode
- Device marked Online if last data < X seconds
- Marked Offline automatically
- Visual indicator on dashboard
- Useful for cold storage, greenhouse, lab monitoring
- 24-hour charts for temperature & humidity
- Animated line charts (Recharts)
- Recent 10 readings table
- Local time formatting
- ESP32 DevKit
- DHT22 Sensor (or DS18B20 alternative)
- Jumper wires
- Breadboard (optional)
- WiFi network
ESP32 Board DHT22 Module (3-pin)
βββββββββββββββββββ ββββββββββββββββ
β β β β
β [3V3] βββββββββ€ VCC (Pin 1) β
β β β β
β [GND] βββββββββ€ GND (Pin 3) β
β β β β
β [GPIO4]βββββββββ€ DATA (Pin 2) β
β β β β
βββββββββββββββββββ ββββββββββββββββ
DHT22 VCC β 3.3V
DHT22 GND β GND
DHT22 Data β GPIO 4
- ESP32
- DHT22
- Arduino Framework
- Next.js 14 API Route
- Supabase PostgreSQL
- Supabase Realtime
- Supabase Auth
- Next.js 14
- TailwindCSS
- Recharts
- Framer Motion
- Responsive Mobile Layout
http.begin(SERVER_URL);
http.addHeader("Content-Type", "application/json");
http.addHeader("Authorization", String("Bearer ") + DEVICE_SECRET);
String json = "{\"device_id\":\"esp32-01\",\"temperature\":";
json += temp;
json += ",\"humidity\":";
json += humidity;
json += "}";Full firmware: iot_code.ino
Path: /api/ingest
const headerSecret =
req.headers.get("Authorization") ||
req.headers.get("x-Authorization") ||
req.headers.get("authorization");
const expected = `Bearer ${DEVICE_SECRET}`;
if (!headerSecret || headerSecret !== expected) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}- Validates device
- Sanitizes incoming payload
- Inserts data to Supabase
- Returns inserted row
File: /app/api/ingest/route.ts
- Temperature + humidity cards
- Device status indicator
- 24-hour animated charts
- Recent readings table
- Last update time
- Mobile optimization
- Smooth transitions
temperature > TEMP_MAXhumidity > HUM_MAX
ALERT
Device: esp32-01
Type: humidity_high
Value: 82.5
Time (Asia/Jakarta): 12/01/2025, 01:04:26 PM
Timestamp (UTC): 2025-12-01T06:04:26.085791+00:00
URL: https://io-t-temperature-humidity-monitorin.vercel.app/
- Telegram Bot API
- Next.js server-side alert dispatcher
- Integrated inside ingestion route
- Each ingestion updates a
last_seentimestamp - Dashboard calculates:
- If
now - last_seen < 60sβ Online - Else β Offline
- If
Green dot = Online
Red dot = Offline
SUPABASE_SERVICE_KEY=YOUR_SUPABASE_SERVICE_KEY
DEVICE_SECRET=YOUR_CUSTOM_DEVICE_SECRET
TELEGRAM_TOKEN=YOUR_TELEGRAM_BOT_TOKEN
TELEGRAM_CHAT_ID=YOUR_TELEGRAM_CHAT_ID_API
NEXT_PUBLIC_SUPABASE_URL=YOUR_SUPABASE_PROJECT_URL
NEXT_PUBLIC_SUPABASE_ANON_KEY=YOUR_SUPABASE_ANON_KEY
NEXT_PUBLIC_SITE_URL=YOUR_PUBLIC_SITE_URL
ALERT_TEMP_THRESHOLD=YOUR_TEMP_THRESHOLD
ALERT_HUM_THRESHOLD=YOUR_HUM_THRESHOLD
ALERT_MINUTES_BETWEEN=YOUR_MINUTES_BETWEEN
TIMEZONE=YOUR_TIMEZONE
npm install
cp .env.example .env.local
npm run devLocal dashboard:
http://localhost:3000/
- Deploy to Vercel
- Add all environment variables
- Enable Supabase Realtime:
select * from supabase_realtime.add_realtime_publication('sensor_data');- Flash ESP32 with correct
SERVER_URLDEVICE_SECRET
- Data will appear instantly on dashboard
- Alerts will fire automatically
IoT-Temperature-Humidity-Monitoring-System
βββ LICENCE
βββ README.md
βββ config.example.h
βββ config.h
βββ docs/
β βββ iot-temperature-humidity-dashboard.png
βββ iot_code.ino
βββ front-end/
βββ eslint.config.mjs
βββ example.env
βββ next-env.d.ts
βββ next.config.ts
βββ package.json
βββ pnpm-lock.yaml
βββ postcss.config.mjs
βββ tsconfig.json
βββ public/
β βββ vercel.svg
βββ src/
βββ app/
β βββ api/
β β βββ ingest/
β β βββ route.ts
β βββ favicon.ico
β βββ globals.css
β βββ layout.tsx
β βββ page.tsx
βββ lib/
βββ useSensorRealtime.ts
βββ useSupabaseClient.ts
- Multi-device support
- MQTT ingestion mode
- Multi-user access control
- CSV/Excel export
- Long-term (30-day) analytics
- Chart smoothing + anomaly detection
Marko
IoT β’ Embedded Systems β’ Robotics β’ Cloud Integration
Building real-world systems that connect hardware, cloud, and people.
MIT License β free to use & modify.
