DEV Community

Cover image for SLX LoRaSense: LoRa measurements and environmental sensing
Marco
Marco

Posted on Originally published at siliconlogix.it

SLX LoRaSense: LoRa measurements and environmental sensing

The project

SLX LoRaSense measures and analyses a LoRa link using two STM32WL nodes and a C++20 desktop application. One node sends a packet every five seconds; the other receives it and forwards the radio measurements and communication status to the computer.

The software tracks the signal, compares it with a reference and identifies changes that persist over time. Its main measurements are Packet RSSI, which indicates the received level, and SNR, the signal-to-noise ratio. Diagnostic counters help distinguish radio behaviour from transport problems between the receiver and the PC.

The project can support wireless device development, installation diagnostics and studies of radio channel variations. Adding physical sensors extends the same architecture to environmental monitoring.

LoRa and link parameters

LoRa uses chirp spread spectrum modulation: symbols are represented by signals whose frequency changes over time. It suits short messages, with parameters that allow a trade-off between data rate, receiver sensitivity and channel occupancy. Semtech describes the LoRa physical layer.

LoRaWAN defines the network built on top of the radio link. It introduces devices, gateways, servers and communication procedures. LoRaSense uses direct communication between its two nodes, an SLX application protocol and a receiver connected to the PC. It does not require a gateway or cloud service. Integration with LoRaWAN would add the protocol stack and management of the credentials required by the network. The LoRa Alliance describes that architecture.

At a fixed bandwidth, spreading factor determines symbol duration. Increasing it can improve sensitivity, but also increases the time needed to transmit a message. Narrowing the bandwidth changes the sensitivity–data rate trade-off as well. Coding rate controls the redundancy added for error correction. These parameters must be compatible between transmitter and receiver. Semtech application note AN1200.86 discusses the modulation characteristics.

The SLX firmware uses the following radio profile:

Radio parameter Configuration
Centre frequency 868.300 MHz
Bandwidth / spreading factor 250 kHz / SF7
Coding rate / preamble 4/5 / 8 symbols
Header / radio CRC Explicit / enabled
Payload / nominal interval 32 bytes / 5,000 ms
Configured transmit power 10 dBm
Calculated time on air 35.968 ms per packet

With SF7 and a 250 kHz bandwidth, symbol duration is Tsymbol = 2^SF / BW = 0.512 ms. The 32-byte payload, with the settings above, has a calculated time on air of 35.968 ms. This is approximately 0.719% of the five-second interval.

Time on air helps size the traffic load, particularly when several nodes share a channel. Link design also needs to account for antennas, orientation, attenuation and interference. Configured power, sensitivity and range describe different properties: usable distance depends on the installation and available link margin. Band, power and antenna must be selected for the applicable operating conditions.

STM32WL nodes and desktop software

The transmitter, or beacon, prepares packets and sends them at regular intervals. The receiver checks each message, reads Packet RSSI and SNR from the radio, then adds timestamps and counters. The board UART, accessible through its USB-to-serial converter, transfers the records to the PC at 115,200 baud, 8N1.

Connection between the LoRaSense beacon, receiver and desktop software

The beacon transmits; the receiver associates RSSI, SNR and counters with each packet. The software processes the measurements and updates link status.
The nodes use the Wio-E5-LE-HF module with STM32WLE5JC. The LE variant is single core, and its datasheet specifies a maximum module output power of 14 dBm in the 868/915 MHz bands. The firmware configures the RF path and clock reference for this variant. Moving to another module requires checking these details, together with pin availability and interfaces. Seeed documents the device characteristics.

The application uses C++20, Dear ImGui, GLFW and OpenGL. Reception and analysis run separately from rendering: the graph refresh rate does not set the packet rate. The interface presents the latest available data, reference status and link diagnostics.

The analysis core is distributed as a separate binary library, accessed through an SDK with a version 1 C ABI. This separation allows the interface and integrations to evolve against a defined contract with the algorithms. Windows and Linux builds are available.

Firmware and message protocol

SLX firmware 0.1.3 has two roles: beacon and receiver. The boards are programmed through ST-LINK; the Wio USB connection exposes serial communication for reading data and sending local commands.

The radio message occupies 32 bytes. It includes format identification, version, node, boot, transmission attempt sequence, transmit counters, radio profile and an application CRC. Node and boot identifiers distinguish the source and its restarts. A change of identity or profile starts a new analysis segment.

The sequence advances when an attempt is prepared. The TxDone counter advances when the radio confirms completion of a transmission. The payload carries the completions preceding the current attempt, so calculating delivery rate requires comparing consistent counters within the same segment. The link does not use acknowledgements or retransmissions.

Communication between receiver and PC uses NDJSON, with one JSON object per line. Records distinguish samples, device information, command responses and errors. The parser retains partial lines until the delimiter, enforces length limits and handles discontinuities. Duplicates, out-of-order messages and overflows are not treated as new valid measurements.

The CRC detects accidental corruption of a message. An application that needs to identify an authorised sender also requires authentication, key management and protection against replayed packets. These requirements affect protocol format, memory usage and time on air.

RSSI, SNR and variation analysis

Packet RSSI is the received power indicator associated with a packet, expressed in dBm. A less negative value indicates a higher level. SNR is the signal-to-noise ratio, expressed in dB. The software displays them separately because they describe different aspects of reception.

Indoors, the signal reaches the antenna along direct and reflected paths. People, doors and objects can change their contributions. A variation can therefore appear as either an increase or a decrease in level, even while transmitter and receiver remain in the same positions.

To compare the signal over time, the software builds a reference from at least 120 seconds of observation and a sufficient number of samples. It uses the median RSSI and the median absolute deviation, or MAD. The reference remains fixed until recalibration or a change that invalidates it.

The filtered signal is the median of the last five accepted samples. Its departure from the reference is scaled by the reference dispersion:

m     = median(reference RSSI)
MAD   = median(|RSSI − m|)
sigma = max(1.4826 × MAD, 0.5 dB)
delta = filtered RSSI − m
variation index = |delta| / sigma
Enter fullscreen mode Exit fullscreen mode

The index expresses how far the level has moved from its initial behaviour. The factor 1.4826 gives MAD a robust scale; it does not establish a Gaussian distribution. The 0.5 dB lower bound avoids division by zero when the initial values are constant.

Entering the variation state requires an entry threshold, while returning to the stable state uses a lower threshold. Temporal persistence prevents a single sample from causing a transition. Window duration, coverage and sample count determine whether enough data is available to apply the criterion.

With a packet every five seconds, the nominal sampling frequency is 0.2 Hz. An event shorter than the interval can escape sampling. The period must therefore suit the speed of the phenomenon being monitored, as well as power consumption and radio traffic.

A missing packet remains missing data: replacing it with zero would distort the signal. The software distinguishes signal variation from insufficient data and loss of the link. Statistics based only on received packets also need care, since they may exclude the poorest reception conditions.

Environmental monitoring

LoRaSense can be extended by connecting temperature, humidity, CO₂, level or soil moisture sensors to the nodes. The sensor measures the physical quantity and the node transmits its value. RSSI and SNR continue to describe the radio link and can help diagnose communication. Semtech presents several uses of LoRa in environmental monitoring.

Integration requires selecting the sensor, implementing its driver and defining a payload that carries value, unit and sample status. Power supply, environmental protection and calibration depend on the application. A greenhouse node has different requirements from a device used in a plant room or on industrial equipment.

A second application is analysing radio channel disturbances. With antennas and profile fixed, it is possible to study how the link changes between environmental states, such as an open or closed door. Associating a variation with an event requires a specific criterion, because different movements and objects can produce similar responses.

Environmental sensor measurements and analysis of changes in the radio link

Monitoring can use sensors of physical quantities or analysis of radio channel variations, with different interpretation criteria.
Research into LoRa sensing includes systems such as WideSee, by Chen and colleagues, which addresses detection and localisation with dedicated hardware and processing. LoRaSense works with the indicators available for each Wio packet. Developing a recognition function requires selecting signals, geometry and criteria suited to the target event.

Multiple links can provide information about different radio paths. Such a network requires transmission planning, collision management and comparable measurements. Estimating distance from RSSI is a separate problem: it needs a model calibrated for the environment and an assessment of its error.

Possible applications

Applications depend on the sensors connected to the nodes and the information required. Some concern communication quality; others use LoRa to collect distributed physical measurements.

Scenario Useful information Development and verification required
Plant rooms and warehouses Radio quality trends after changes to shelving, obstacles or installation Before-and-after measurements, fixed antennas, multiple locations and interference diagnostics
Greenhouses and cultivation Temperature, air humidity and soil moisture Dedicated sensors, environmental protection, calibration and power assessment
Buildings and conservation Microclimate or air quality, together with link status Appropriate sensors, comparison with reference instruments and application-specific thresholds
Doors, panels and fixed settings Radio differences between repeatable states Independent state reference, blind evaluation and control of unrelated movements
Embedded development and production Traceability of firmware, profile, errors and response over time Defined fixtures and conditions, RF instruments for quantitative measurements and acceptance criteria
Area disturbances across multiple links Comparison of variations along different radio paths More nodes, traffic planning, labelled datasets and validation in separate environments

For battery-powered devices, the transmission interval must be selected together with the acquisition cycle. Slowly changing quantities may only need less frequent transmissions or a message triggered by crossing a threshold. Consumption includes the sensor, processing, radio and idle periods: the module’s sleep current alone does not describe the autonomy of the complete board.

Recognising an environmental change involves detection performance, false alarms and response time. Thresholds must be assessed under conditions different from those used to tune them, including interference and changes unrelated to the phenomenon of interest.

Development and integration

Separating firmware, protocol and application allows the system to be adapted to the installation. Sensors can be added, the acquisition period changed, data collected from multiple receivers, or the software connected to existing company systems.

Moving to a LoRaWAN network requires integration with gateways and servers. A local application can retain the USB receiver and use the PC for analysis and supervision. The choice depends on node count, coverage, available power and infrastructure management.

Silicon LogiX develops custom embedded firmware, protocols and technical applications. Measurement hardware and software are designed around the required quantities, installation conditions and system response times.

Talk to us about your monitoring system

Technical references

Top comments (1)

Collapse
 
crtdrops profile image
Israel Negrete Lepe •

Keeping a lost packet as missing data instead of a zero, and carrying TxDone in the payload so delivery is computed inside one segment, are the two details most link tools skip.

Your battery line matches what we found designing a water meter with a LoRaWAN version and a GPRS version: the LoRaWAN one had no radio problem, and once the radio is that cheap, the budget moves to the sleep current of the whole board (regulator, pull-ups, sensor on standby) and the cell's self-discharge.

One question on the variation index: the median runs over the last five accepted samples, so if a person or a door blocks the path hard enough to drop packets, the strongest disturbance shows up as a gap, not as a delta. Does a run of missed sequence numbers feed the variation state, or does it only count as insufficient data?