A Calculator that calculate the time on air of LoRa packet. Based on the formula in Semtech's datasheet.
TL;DR: This calculator is for pure LoRa modem, not for LoRaWAN. The demo is avaliable here.
LoRa is a exteremely powerful modulation method that can transmit data over 3km away. But one of the down side of LoRa is the very long, up to a few milliesecond, symbol time. Result in the very long time on air of the packet. Thus, calculating the total time on air is crutial for designing the timing of upper layer protocol. However, the tool to calculate air-time provided by Semtech is only avaliable on Windows operation system. Moreover, most of the calculator tha I had found aim to LoRaWAN, not for pure LoRa. As a result, this little project was borned. It's my pleasure that this tool also helped you :)
The symbol time of LoRa Modulation follows this equation:
Where SP means Spreading Factor, and BW stands for Bandwidth.
Once we have the symbol time, we can calculate the total time on air via the following equation:
This equation have so many magic number that is not specified in the datasheet. Anyway, the result had been confirmed by the Semtech who knows all of the detail inside the blackbox. So, let's just write a calculator to calculate it!
I was wondering whether the air-time had been given in the datasheet is correct. So I performed the following experiment to validate the correctness of this calculator.
I use USRP-B210 software-defined-radio and gqrx to capture the raw I/Q data of LoRa signal transmitted by SX1276 at 920MHz unlicensed band. Then analysis it with inspectrum. The overall result provide an excellent prove to the correctness of calculator which is a good news for me. The detailed result is shown as below.
The following image shows the ToA of payload. With 11bytes payload and 4/8 coding rate.
The result of calculation is 32symbols and 1.024ms symbol time, which matchs the truth.
The following image shows the ToA of payload. With 11bytes payload, CRC checksum, and explict header. Encoded with 4/8 coding rate.
The result of calculation is 40symbols and 1.024ms symbol time, which matchs the truth.
The following image shows the ToA of whole packet, preamble and payload. With 11bytes payload and 6preamble. Encoded with 4/6 coding rate.
The calculated ToA is 794.624ms, 335.872ms, and 458.752ms respectively; which also matchs the measured result.
P.S: The ToA of preamble measured in the above figure is only measured 10symbols. But there is actually 10.25symbols.