Farm Overview
SaFa Naturals IoT Farm · Sirajganj
--:--
Farm Overview
Real-time status across all grow rooms
Active Rooms
3
↑ 1 from last week
Live Batches
4
2 near harvest
Today's Yield
2.3 kg
↑ 8% vs yesterday
Active Alerts
2
1 critical, 1 warning
Outdoor Weather · Sirajganj
🌡️
—°C
Loading…
—%
Outdoor RH
— m/s
Wind
—°
Feels Like
7-Day Yield (kg)
Active Alerts
Environment Monitor
Live sensor readings · auto-refresh every 5s
Current Readings · Room A
All OK
Temperature & Humidity · 24h
CO₂ & O₂ Levels · 24h
VPD & Dew Point Trend · 24h
Optimal Range Reference
Production Tracker
Batch lifecycle · harvest logs · biological efficiency
Active Batches
Batch IDSpeciesRoomStage ColonisationDays InEst. HarvestStatus
Yield Per Batch (kg)
Biological Efficiency (%)
Recent Harvest Log
BatchFlushDateWeight (kg)BE%RoomNotes
Long-run Analytics
Historical trends · correlations · performance benchmarks
Monthly Yield (kg)
BE% Trend Per Batch
30-Day Harvest Heatmap
Low yield
High yield
Temp vs Yield Correlation
Contamination Breakdown
Energy & Equipment
Power monitoring · equipment control · efficiency
Today (kWh)
18.4
Projected: 24.2 kWh
This Month
412
kWh · ৳ 3,296
Active Load
2,037 W
7 devices active
Cost / kg
৳ 18.4
↓ 6% vs last month
Hourly Power Consumption (W)
Equipment Status & Control
Data Points & Schema Reference
Complete sensor taxonomy · Supabase table schemas · collection frequency
Environmental Sensors Every 60s
ParameterUnitSensorOptimal RangeAlert Threshold
Temperature°CDHT22 / SHT3123 – 27 °C<20 or >30
Relative Humidity%RHDHT22 / SHT3185 – 92 %<75 or >97
CO₂ ConcentrationppmMH-Z19B / SCD40600 – 1,000>1,500
O₂ Level%ME2-O2 / KE-2519.8 – 21<19.0
Airflow / FAE Ratem/sSFM3000 / Hot-wire0.3 – 0.7<0.2
VPD (calculated)kPaDerived: T + RH0.3 – 0.7>0.9
Light IntensityluxBH1750 / TSL2591100 – 500>1,000
Dew Point°CDerived: T + RH16 – 20
Substrate & Water Quality Every 5 min
ParameterUnitSensorOptimal RangeAlert Threshold
Substrate Moisture%Capacitive soil probe60 – 75 %<55 or >85
Substrate Temp°CDS18B20 probe22 – 26 °C>28
Substrate pHpHAtlas EZO-pH6.0 – 7.0<5.5 or >7.5
Water pH (irrigation)pHAtlas EZO-pH6.0 – 7.0<5.8 or >7.5
Water ECmS/cmAtlas EZO-EC0.8 – 2.5>3.5
Water Temp°CDS18B2018 – 24 °C>28
Daily Water UsageL/dayYF-S201 flow meterTarget depends on room
Dissolved O₂ (water)mg/LAtlas EZO-DO6 – 9<4
Production & Batch KPIs Per event
MetricUnitCollected AtNotes
Spawn Run DurationdaysInoculation → 100% colonisationBenchmark: 14–21 days
Pin Initiation DatedateFirst visible pinsDays after spawn: 18–25
Flush Harvest WeightkgEach harvest eventTrack F1, F2, F3 separately
Biological Efficiency%Post-harvest (each flush)BE% = (yield/dry substrate)×100
Days to First HarvestdaysInoculation → F1Benchmark: 22–28 days
Total Yield / BatchkgAll flushes summed3–4 flushes typical
Substrate Dry WeightkgPre-inoculationUsed to calculate BE%
Contamination Rate%Per batch inspectionTarget <5% of bags
Contamination TypeenumVisual inspectionBacterial / Trichoderma / Mould
Spawn Rate Used%InoculationTypically 10–20% w/w
Energy & Equipment Every 15 min
ParameterUnitDeviceNotes
Power Consumption (total)kWhSmart energy meterDaily + monthly rollup
Per-device PowerWSmart plug / CT clampHVAC, humidifier, fans, UV, sensors
Equipment UptimehrsRelay state logOn/off log per device
HVAC Duty Cycle%Derived from on/off logTarget 40–70%
Humidifier Cycles/hrcountRelay logIndicates humidity stability
Fan SpeedRPMPWM feedback / tachometerCorrelates to CO₂ clearance
UV HourshrsRun-time counterReplace bulb at 8,000 hrs
Energy Cost / kg৳/kgCalculatedTotal kWh × ৳8 / yield
Supabase SQL — Paste this into your Supabase SQL Editor to create all sensor tables
-- ══════════════════════════════════════════════════════
-- SaFa Naturals IoT Farm · Supabase Schema
-- Run in: Supabase Dashboard → SQL Editor → New Query
-- ══════════════════════════════════════════════════════

-- 1. SENSOR READINGS (60-second interval, per room)
CREATE TABLE sensor_readings (
  id           BIGSERIAL PRIMARY KEY,
  created_at   TIMESTAMPTZ DEFAULT NOW(),
  room_id      TEXT NOT NULL,           -- 'A', 'B', 'C'
  temperature  NUMERIC(5,2),            -- °C
  humidity     NUMERIC(5,2),            -- %RH
  co2_ppm      INTEGER,                 -- ppm
  o2_pct       NUMERIC(4,2),            -- %
  airflow_ms   NUMERIC(4,2),            -- m/s
  vpd_kpa      NUMERIC(4,3),            -- kPa (calculated)
  light_lux    INTEGER,                 -- lux
  dew_point    NUMERIC(5,2)             -- °C (calculated)
);

-- 2. SUBSTRATE READINGS (5-minute interval, per room)
CREATE TABLE substrate_readings (
  id            BIGSERIAL PRIMARY KEY,
  created_at    TIMESTAMPTZ DEFAULT NOW(),
  room_id       TEXT NOT NULL,
  moisture_pct  NUMERIC(5,2),
  substrate_temp NUMERIC(5,2),
  substrate_ph  NUMERIC(4,2),
  water_ph      NUMERIC(4,2),
  water_ec_ms   NUMERIC(5,3),           -- mS/cm
  water_temp    NUMERIC(5,2),
  water_used_l  NUMERIC(7,3)
);

-- 3. PRODUCTION BATCHES
CREATE TABLE farm_batches (
  id              TEXT PRIMARY KEY,      -- e.g. 'BAT-2025-041'
  created_at      TIMESTAMPTZ DEFAULT NOW(),
  species         TEXT NOT NULL,
  room_id         TEXT NOT NULL,
  inoculation_date DATE NOT NULL,
  substrate_kg    NUMERIC(6,3),          -- dry weight
  spawn_pct       NUMERIC(4,1),
  stage           TEXT DEFAULT 'Inoculated',
  colonisation_pct INTEGER DEFAULT 0,
  pin_date        DATE,
  expected_harvest DATE,
  status          TEXT DEFAULT 'active', -- active | completed | contaminated
  notes           TEXT
);

-- 4. HARVEST EVENTS
CREATE TABLE harvest_events (
  id          BIGSERIAL PRIMARY KEY,
  created_at  TIMESTAMPTZ DEFAULT NOW(),
  batch_id    TEXT REFERENCES farm_batches(id),
  flush_num   SMALLINT NOT NULL,
  harvest_date DATE NOT NULL,
  yield_kg    NUMERIC(7,3),
  be_pct      NUMERIC(5,2),             -- biological efficiency
  room_id     TEXT,
  notes       TEXT
);

-- 5. CONTAMINATION LOG
CREATE TABLE contamination_log (
  id            BIGSERIAL PRIMARY KEY,
  created_at    TIMESTAMPTZ DEFAULT NOW(),
  batch_id      TEXT REFERENCES farm_batches(id),
  room_id       TEXT,
  type          TEXT,                    -- Bacterial | Mould | Trichoderma
  bags_affected INTEGER,
  total_bags    INTEGER,
  action_taken  TEXT,
  resolved      BOOLEAN DEFAULT FALSE
);

-- 6. ENERGY LOG (15-minute interval)
CREATE TABLE energy_log (
  id          BIGSERIAL PRIMARY KEY,
  created_at  TIMESTAMPTZ DEFAULT NOW(),
  device_id   TEXT NOT NULL,            -- 'hvac-a', 'humidifier-b', etc.
  room_id     TEXT,
  watts       NUMERIC(8,2),
  is_on       BOOLEAN DEFAULT TRUE,
  kwh_total   NUMERIC(10,4)
);

-- 7. ALERT LOG
CREATE TABLE alert_log (
  id          BIGSERIAL PRIMARY KEY,
  created_at  TIMESTAMPTZ DEFAULT NOW(),
  room_id     TEXT,
  severity    TEXT NOT NULL,            -- 'ok' | 'warn' | 'crit'
  parameter   TEXT,
  value       NUMERIC,
  threshold   NUMERIC,
  message     TEXT,
  resolved_at TIMESTAMPTZ
);

-- ── INDEXES for time-series queries ──
CREATE INDEX idx_sensor_room_time   ON sensor_readings (room_id, created_at DESC);
CREATE INDEX idx_substrate_room     ON substrate_readings (room_id, created_at DESC);
CREATE INDEX idx_harvest_batch      ON harvest_events (batch_id, flush_num);
CREATE INDEX idx_energy_device_time ON energy_log (device_id, created_at DESC);
CREATE INDEX idx_alerts_severity    ON alert_log (severity, created_at DESC);

-- ── ROW LEVEL SECURITY ──
ALTER TABLE sensor_readings ENABLE ROW LEVEL SECURITY;
ALTER TABLE farm_batches    ENABLE ROW LEVEL SECURITY;
ALTER TABLE harvest_events  ENABLE ROW LEVEL SECURITY;
ALTER TABLE energy_log      ENABLE ROW LEVEL SECURITY;
ALTER TABLE alert_log       ENABLE ROW LEVEL SECURITY;

-- Allow authenticated users (admin) full access
CREATE POLICY "admin_all" ON sensor_readings   FOR ALL TO authenticated USING (true);
CREATE POLICY "admin_all" ON farm_batches      FOR ALL TO authenticated USING (true);
CREATE POLICY "admin_all" ON harvest_events    FOR ALL TO authenticated USING (true);
CREATE POLICY "admin_all" ON energy_log        FOR ALL TO authenticated USING (true);
CREATE POLICY "admin_all" ON alert_log         FOR ALL TO authenticated USING (true);
Recommended Hardware Stack
Controller Node
ESP32 — main MCU per room, Wi-Fi + BT
Raspberry Pi 4 — central gateway + local DB
4G LTE dongle — backup internet for remote farm
UPS module — 12V battery backup for ESP32
Sensor Modules
SHT31 — temperature + humidity (±0.3°C, ±2%)
SCD40 — CO₂ (NDIR, ±50ppm), includes T+H
BH1750 — light intensity
Atlas EZO-pH — substrate & water pH
Atlas EZO-EC — electrical conductivity
Control & Actuation
4-channel relay — HVAC, humidifier, fans, UV
PWM controller — variable fan speed
PZEM-004T — AC power monitoring per circuit
Supabase Realtime — push sensor data every 60s
Threshold alerts — POST to Supabase alert_log