Case Study: LoRaWAN Livestock Monitoring Device Development Using STM32 LoRaWAN livestock monitoring device development using STM32. Firmware optimization, low-power design, RF tuning, private LoRaWAN integration, and pilot deployment preparation for cattle health monitoring in agriculture.

LoRaWAN Livestock Monitoring Device Development Using STM32

The purpose of this study is to describe how we developed a livestock monitoring solution based on LoRaWAN technologies. On behalf of the customer in Europe who requested this solution, we have created a cost-effective prototype using STM32 microcontroller technologies, which may be used for mass production at the customer's facility as well as for pilot deployment.

With livestock health being a growing concern for farmers today, it is essential that devices used to monitor livestock activity and health provide reliable, low-power operation within the expected long operational periods in rural areas.

The customer came to us looking for an existing LoRaWAN-based livestock monitoring device that has been designed specifically for chubby cattle.

They had previously built the device with basic hardware architecture and initial firmware development. However, many engineering tasks needed to be completed on the device before pilot deployments and scale production could occur.

Therefore, our goal was to review the existing system and optimize firmware and hardware performance, validate radio frequency (RF) communications, and be able to prepare the product for pilots within a designated area using a Private LoRaWAN infrastructure.

Initial Challenges

Initially, despite the project's completed working components, several technical challenges needed to be solved before the device was ready for production. The following were challenges experienced by the project:

  • Firmware optimizations were needed. The device firmware was developed based on the STM32 microcontroller and used the LoRaWAN communication stack. The power consumption of the device was unexpectedly high and issues in the performance of some telemetry processes were also noted.
  • The device was battery-operated and mounted to livestock. Therefore, the device needed to be able to operate on a single battery for an extended period of time without needing replaced.
  • The RF performance and placement of the antenna within the device enclosure needed to be validated prior to the device being used for reliable communications over large areas of a farm.
  • The device needed to connect and use a private LoRaWAN network server (LNS) instead of relying on public-network providers.
  • Although Gerber files, BOM, & PCB layouts were created before pilot/prototype manufacturing and production, a review of the designs was needed to facilitate an easy transition from those files to the production components for the manufacturing of the device.
LoRaWAN livestock monitoring device with STM32

Engineering Approach

1. Firmware Review and Architectural Enhancements to support the Wio-E5 LoRa and STM32

The embedded team executed a full code review of all firmware assets for the STM32 platform. The Wio-E5 LoRa module was used as the hardware platform.

The key areas of focus included:

  • Bravo Sensor telemetry handling
  • LoRaWAN communication routines
  • Power management logic
  • Device provisioning workflow

During our review, we discovered numerous locations in the firmware where the existing logic required devices to waken up when they did not need to, causing considerable battery drainage, due to inefficient communications scheduling.

We made modifications that included:

  • Optimization of sensor data acquisition periods
  • Improving our communication message scheduling for LoRa transmissions
  • Reworking/Refactoring our firmware modules so that they would be more sustainable over time
  • Implementing structured logging for debugging and to assist with device diagnostics

As a result of these improvements and modifications to the firmware, we have improved the maintenance of the firmware and increased the reliability of the system.

2. Low Power Optimization for Livestock Tracking Devices

One of the highest priority requirements for livestock tracking devices is battery life. To achieve longer battery life, we implemented a comprehensive low-power strategy that included:

  • Using the deep sleep mode of the STM32 microcontroller
  • Event-based wake up architecture
  • Sensor power gating (disabling unused sensors)
  • Optimized LoRa transmission cycles

The firmware was also re-designed such that the device would remain in sleep mode for most of its operational cycle, and only wake up for:

  • Scheduled telemetry transmissions
  • Sensor events
  • Network communications

As a result of these modifications, we were able to reduce power consumption significantly and to increase the expected lifetime of the battery.

3. Hardware and PCB Validation

Even though there is an existing hardware design, our engineering team completed a full review of:

  • PCB layout
  • Power Distribution
  • RF Trace Routing
  • Component placement

We worked with the mechanical engineering group to make sure the device enclosure did not impact RF performance of the device.

Also during this stage we verified:

  • Manufacturing files (Gerber, BOM, pick-and-place)
  • Availability on sourcing material for components
  • Hardware test points for debugging

There were minor adjustments made to the PCB to improve signal stability and better support the manufacturing process.

4. RF Tuning and Antenna Testing

It is important to have stable communication on an agricultural farm where animals are located in many locations across a large area. Our RF team was responsible for antenna tuning and RF verification testing in order to verify that the device would have a reliable LoRaWAN connection.

The process included:

  • RF signal strength measurements
  • Antenna impedance matching
  • Testing the range of the RF signal
  • Checking the quality of the RF signal in multiple environments

By optimizing and matching the antennas of the devices as well verifying the RF path, we were able to guarantee that the devices would have a reliable RF communication while being in remote areas of the farm.

5. Integrating Private LoRaWAN Infrastructure

Instead of using many public LoRaWAN services (called networks), the customer requested that their devices operate over a private LoRaWAN infrastructure.

We amended the firmware for the device to support this private LNS deployment and created device provisioning workflows which included:

  • Activating devices with keys
  • Securely joining the network
  • Configuring the network server

These enable smooth communication between devices, gateways and servers.

6. Device Provisioning and Deployment Workflow

For pilot deployment, the client needed a streamlined process for provisioning and deploying devices.

We created a structured workflow covering:

  • Device flashing and firmware installation
  • Device identity registration
  • Network activation and provisioning
  • Gateway connectivity verification

We also developed detailed flashing and onboarding documentation so that field technicians could deploy devices efficiently.

7. Pilot Deployment - Preparation

Once the firmware has been stabilized and the RF has been validated, we prepared the system for pilot deployment.

This phase included:

  • Prepare the final build of the firmware
  • Conduct validation tests of the hardware
  • Prepare to provision the devices
  • Prepare deployment documentation

The pilot units were configured to monitor livestock activity and periodically transmit telemetry data through LoRaWAN gateways.

The field data collected during the pilot phase will assist us in refining the product prior to mass production.

Results and Impact

By the end of the project phase, the livestock monitoring device successfully transitioned from a partially developed prototype to a pilot-ready IoT product.

Key outcomes included:

  • Optimized low-power firmware with significantly improved battery efficiency
  • Stable LoRaWAN communication with validated RF performance
  • Successful integration with a private LoRaWAN infrastructure
  • Manufacturing-ready hardware design
  • Structured device provisioning and deployment workflow

The system was ready for real-world pilot deployment on livestock farms, where it could monitor cattle activity and transmit data reliably across large areas.

Summary

We demonstrated that using a well-defined engineering process can result in turning an existing prototype into a production-ready Internet of Things (IoT) device. Through firmware optimization, low-power design, RF validation, and deployment processes, we helped our client enable them to move quickly towards pilot deployments and future mass manufacturing.

The end result is a reliable livestock monitoring device based on LoRaWAN technology and designed for rigorous use in difficult agricultural conditions, giving farmers real-time updates on the status of their livestock.

What Our Clients Say About Us

Client satisfaction is our ultimate goal. Here are some kind words of our precious clients they have used to express their satisfaction with our service.

Leadership That Leads Worldwide

With a physical presence in over 15 countries and a global footprint spanning 25+ countries, we are ready to serve you anywhere. Location, language, or culture is never a barrier, because our global team can work with you in your language. Our strong international team ensures seamless collaboration across borders We have a strong tech team, highly recognized in their domains, with extensive technical expertise.