Krishi Sakhi logoKrishi Sakhi

Hardware Data Roadmap (IoT)

Ingestion Options

  • HTTP Webhook: Gateway posts JSON to /api/iot/ingest signed with HMAC.
  • MQTT Broker: Devices publish to topics; subscriber service writes to DB.
  • LoRaWAN (TTN/ChirpStack): Uplink webhooks to /api/iot/ttn.

Data Model (Prisma)

Two core tables:

  • SensorDevice: farmId, name, type, unit, connectivity, metadata, apiKeyHash, lastSeenAt.
  • SensorReading: deviceId, at, value, unit, quality, raw (indexed by deviceId, at).

Security & Provisioning

  • Admin registers SensorDevice → binds to Farm → issues device API key (store only hash).
  • All ingestion over TLS. Verify HMAC signature per request. Rate-limit per device.
  • Validate units and value ranges; mark quality: ok/warn/error.

Minimal Working Slice (1–2 days)

  1. Add SensorDevice & SensorReading models; migrate.
  2. Build POST /api/iot/ingest with HMAC auth.
  3. Admin: Register sensor, bind to farm, generate API key (QR optional).
  4. POST from a test ESP32/gateway; store reading; update lastSeenAt.
  5. Dashboard: show latest soil moisture and last seen.
  6. Advisory: trigger low-moisture alert; push notification.
  7. Chat: include latest sensor snapshot in context for richer answers.

See repository root: HARDWARE_INTEGRATION.md for full details.