CASE STUDY: SMART AGRICULTURE

FarmSense
FlightSensor

Transitioning a sophisticated agricultural IoT device from a fragile prototype to a deterministic, manufacturable product using Zephyr RTOS and Nordic nRF9160.
Nordic nRF9160
Zephyr RTOS
MQTT
farmsensor
SYS_STATUS: ONLINE CONN: LTE-M PWR: SOLAR_MPPT
BATT: 4.12V EVENTS: 142/hr

The Challenge: The Prototype Plateau

FarmSense had a functional proof-of-concept for the FlightSensor, a device monitoring insect activity via acoustic classification. However, the firmware sat in the "Valley of Death" between a demo and a mass-producible product.

Legacy Issues

  • 1. Hybrid C/C++ Codebase: Lack of standardization created race conditions and blocked FOTA implementation.
  • 2. Custom "Black Box" Drivers: Custom logging and RTC implementations prevented the use of power-saving sleep modes.
  • 3. Non-Deterministic: Sensor reading threads were blocked by cellular upload latency.

Mission Objectives

  • 1. Migrate to Nordic Connect SDK (NCS) for long-term support.
  • 2. Implement Zephyr RTOS for thread safety and power management.
  • 3. Optimize Solar PMIC logic for off-grid longevity.

The Solution: Event-Driven Architecture

We decoupled the monolithic super-loop into asynchronous modules communicating via the Zephyr Event Manager. This ensures high-priority insect detection is never blocked by low-priority cloud syncing.
FIG 1.0: SYSTEM ARCHITECTURE
ACOUSTIC_SENS
ENV_SENSORS
PMIC_SOLAR
APP EVENT MANAGER
Zephyr Message Bus
<SensorDataEvent>
<PowerStateEvent>
<CloudPubEvent>
AWS IoT Core
MQTT / TLS 1.2
SD Storage
Zephyr FS Subsystem

Standardization & Long-Term Viability

We migrated the codebase from ad-hoc C++ libraries to native Zephyr subsystems. By adhering to the Zephyr device tree standard, we unlocked the native power of the Nordic Connect SDK (NCS).

This architectural alignment was the prerequisite for implementing a robust Over-The-Air update mechanism, critical for a device deployed in agricultural fields where physical maintenance is cost-prohibitive.

Power Management

Replaced manual LED toggling with a dedicated PowerMgmt module controlling the PMIC states.

Data & Config

Migrated from custom JSON parsers to Zephyr Settings and File System subsystems.

Logging System

Implemented custom logging backend to save offline logs to SD Card and send them when device comes online.

AWS File management

Store large data files directly to AWS S3 buckets, compress them on device for efficiency.

Resilient FOTA Architecture

STATUS: ACTIVE
BOOTLOADER: MCUBOOT
ORCHESTRATION: AWS IOT JOBS
SECURITY: ECDSA SIGNED IMAGES

For a solar-powered device, "bricking" during an update is a catastrophic failure. We engineered a fail-safe, dual-bank update strategy.

  • 01

    Cryptographic Verification

    The bootloader rejects any image lacking a valid manufacturer signature (ED25519), preventing supply chain attacks.

  • 02

    Background Download

    Updates download to a secondary flash partition while the device continues normal operation. No downtime during transfer.

  • 03

    Atomic Rollback

    MCUboot performs a "test boot" of the new image. If the system crashes or fails to confirm health, it automatically reverts to the previous version.

agriculture
Working with Hacod significantly accelerated our device development. Our product greatly benefited from the expertise and skills provided by Hacod's engineers. Thanks to our collaboration, we were able to achieve results twice as fast as anticipated. The development work was executed at the highest level, and the outcome far exceeded our expectations.
Shailendra Singh
Shailendra Singh
Co Founder, FarmSense Inc

Technical Specifications

MCU
Nordic nRF9160
Architecture
ARM Cortex-M33
OS
Zephyr RTOS
Connectivity
LTE-M / NB-IoT
Language
C (C99 Standard)
Cloud
AWS IoT Core
Update Mech
FOTA (HTTP/MQTT)
Edge AI
Decision Tree
100%
Thread Safety
<10µA
Sleep Current
OTA
Remote Updates Enabled