Embedded·2023

LoRaWAN Agricultural Environment Monitoring System

A low-power LoRaWAN environment monitoring system built for smart agriculture, supporting soil moisture, temperature, light, and pH monitoring — solar-powered for over 3 years of continuous operation

clientSmart Agriculture Startup
duration8 months
categoryEmbedded
stack
STM32L4LoRaWANChirpstackGrafanaInfluxDBNode.jsSolar PowerLow Power

Project Overview

A LoRaWAN environment monitoring system developed for a smart agriculture startup. Powered by the STM32L4 ultra-low-power MCU and equipped with solar panels and lithium batteries, the system achieves battery-free operation for over 3 years. It monitors critical agricultural parameters including soil moisture, temperature, ambient light, and soil pH, with data transmitted to the cloud platform via LoRaWAN.

Currently, 2,000+ sensor nodes have been deployed, covering 500+ hectares of farmland.

Core Technologies

1. Ultra-Low Power Design

Overall system average power consumption < 50uA, achieving extremely long battery life:

// STM32L4 low-power mode switching
void enter_stop_mode_2(uint32_t sleep_seconds) {
    // Set RTC wake-up
    HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, sleep_seconds,
                                 RTC_WAKEUPCLOCK_CK_SPRE_16BITS);

    // Disable non-essential peripherals
    disable_peripherals();

    // Enter STOP2 mode (approximately 1.5uA)
    HAL_SuspendTick();
    HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
    HAL_ResumeTick();

    // Reinitialize clock after wake-up
    SystemClock_Config();
}

// Sensors powered only during measurement
void sensor_measure_cycle(void) {
    // Enable sensor power
    HAL_GPIO_WritePin(SENSOR_PWR_GPIO, SENSOR_PWR_PIN, GPIO_PIN_SET);
    HAL_Delay(100);  // Wait for stabilization

    // Read data
    float soil_moisture = read_soil_moisture();
    float temperature = read_temperature();
    float light = read_light_sensor();

    // Disable sensor power
    HAL_GPIO_WritePin(SENSOR_PWR_GPIO, SENSOR_PWR_PIN, GPIO_PIN_RESET);

    // Send LoRaWAN packet
    send_lora_packet(soil_moisture, temperature, light);
}

2. LoRaWAN Class A Communication

Using LoRaWAN Class A mode to maximize battery life:

  • SF7-SF12 adaptive: Automatically adjusts based on signal strength
  • ADR enabled: Automatic transmit power adjustment
  • Confirmed mode: Confirmed uplink for critical data

3. Solar Power System

  • Solar panel: 2W monocrystalline silicon solar panel
  • Charge IC: BQ25895 intelligent charge controller
  • Battery: 18650 lithium battery 3400mAh x 2
  • MPPT: Maximum power point tracking

System Architecture

                    Solar Panel
                         |
+------------------------+------------------------+
|              Sensor Node (STM32L4)               |
|  +---------+ +---------+ +---------+ +-------+  |
|  |  Soil   | |  Temp   | |  Light  | |  pH   |  |
|  | Moisture| |         | |         | |       |  |
|  +---------+ +---------+ +---------+ +-------+  |
|                      |                           |
|               +------+------+                    |
|               |   SX1262    |                    |
|               |  LoRa Module|                    |
|               +------+------+                    |
+----------------------+---------------------------+
                       | LoRaWAN
                       v
              +-----------------+
              | LoRaWAN Gateway |
              | (RAK7268)       |
              +--------+--------+
                       | 4G / Ethernet
                       v
              +-----------------+
              |   Chirpstack    |
              |  Network Server |
              +--------+--------+
                       |
          +------------+------------+
          v            v            v
    +----------+ +----------+ +----------+
    | InfluxDB | |  Grafana | |  Alert   |
    |          | |          | |  System  |
    +----------+ +----------+ +----------+

Project Results

  • Coverage range: Single gateway covers 3km radius
  • Battery life: Verified operation exceeding 3 years
  • Data accuracy: Moisture +/-3%, Temperature +/-0.3 degrees C
  • Water savings: Farmers save an average of 25% on water usage

Client Testimonial

"With this system, we can precisely monitor the condition of every plot of farmland. Irrigation and fertilization are much more efficient now." — Farm Manager

$ ls projects/embedded/

More work in Embedded.