LoRa duty cycle
Overview
This sample demonstrates how to use lora_recv_duty_cycle() (blocking) and
lora_recv_duty_cycle_async() (callback-based) to let the radio autonomously
alternate between short RX windows and sleep, waking the MCU only when a
packet is received.
The receiver first uses the blocking API to receive 4 packets, then switches to the asynchronous API for 10 more.
Two boards are needed. By default the sample starts in receiver mode. Hold button 0 during boot to select sender mode.
The sender transmits with a long preamble (100 symbols) so that the duty-cycling receiver is guaranteed to detect it during one of its RX windows.
Building and Running
Build and flash on two boards with a lora0 alias, for example
nucleo_wl55jc or nrf52840dk/nrf52840 with the SX1261 shield:
west build -b nucleo_wl55jc samples/drivers/lora/duty_cycle
west flash
Sample Output (receiver)
[00:00:00.235,000] <inf> lora_duty_cycle: Synchronous duty cycle reception (rx=50 ms, sleep=450 ms)
[00:00:01.456,000] <inf> lora_duty_cycle: RX 12 bytes, RSSI: -55 dBm, SNR: 9 dB
[00:00:01.456,000] <inf> lora_duty_cycle: payload
64 75 74 79 63 79 63 6c 65 20 20 30 |dutycycle 0
...
[00:00:20.000,000] <inf> lora_duty_cycle: Asynchronous duty cycle reception
[00:00:25.000,000] <inf> lora_duty_cycle: RX 12 bytes, RSSI: -55 dBm, SNR: 9 dB
[00:00:25.000,000] <inf> lora_duty_cycle: payload
64 75 74 79 63 79 63 6c 65 20 20 34 |dutycycle 4
Sample Output (sender)
[00:00:00.235,000] <inf> lora_duty_cycle: Sender mode (preamble=100 symbols)
[00:00:00.235,000] <inf> lora_duty_cycle: Expected packet airtime: 1565 ms
[00:00:01.800,000] <inf> lora_duty_cycle: Sent packet 0