Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to configurate LoRa for best distance? #90

Closed
MauriPastorini opened this issue Jan 23, 2018 · 19 comments
Labels

Comments

@MauriPastorini
Copy link

@MauriPastorini MauriPastorini commented Jan 23, 2018

Hi, I was wondering how can we configurate the LoRa with the library for the best distance? Something like changing the data rate, baud rate and modulation. And how to request which values had been set for confirmation.

Thank you

@morganrallen

This comment has been minimized.

Copy link
Collaborator

@morganrallen morganrallen commented Jan 23, 2018

First step is getting a better antenna. The stub and wires these usually come with are rubbish. I used a proper 800-850MHz and that increased my range significantly (828 meters so far). In that same test I had the following settings.

Bandwidth: 250E3 (less might have been better)
Frequency: 915E6 (866E6 would have been better, duh, antenna)
Spread Factor: 9
Preamble: 8
C/R Denominator: 8

I tried a follow up test but it didn't work at all due to not taking transmission time into account. So something to keep in mind, the longer your range, the longer you need to wait between TXes. Here's a handy spreadsheet to calculate On Air Time.
https://docs.google.com/spreadsheets/d/1voGAtQAjC1qBmaVuP1ApNKs1ekgUjavHuVQIXyYSvNc/edit#gid=0

@morganrallen

This comment has been minimized.

Copy link
Collaborator

@morganrallen morganrallen commented Jan 23, 2018

Oh, CRC was disabled too.

@Hoel

This comment has been minimized.

Copy link

@Hoel Hoel commented Jan 25, 2018

Hi,
On this topic, what is the default BW when not explicitely set in the app? I did not find any reference to setSignalBandwidth in the init, so i wonder what the library default to.

@morganrallen

This comment has been minimized.

Copy link
Collaborator

@morganrallen morganrallen commented Jan 25, 2018

Looks like 125kHz is the default.

http://www.mouser.com/ds/2/761/sx1276-944191.pdf Page 113

@Hoel

This comment has been minimized.

Copy link

@Hoel Hoel commented Jan 26, 2018

@MauriPastorini

This comment has been minimized.

Copy link
Author

@MauriPastorini MauriPastorini commented Jan 26, 2018

Excellent morganrallen, many thanks!
Sorry about the really basic questions but besides the antenna,

Bandwith: If reduce the bandwith at minimum, lets say 7.8E3, am I going to have better distance?
Spread factor: For distance which is better? More or less? Between the 6 and 12.
Preamble: For distance which is better? More or less? Between the 6 and 65535
Coding Rate: For distance which is better? More or less? Between the 5 and 8
CRC: For distance which is better? Enable or disable?

If anybody could answer this parameters for distance would be awesome

@morganrallen

This comment has been minimized.

Copy link
Collaborator

@morganrallen morganrallen commented Jan 26, 2018

Spread factor is going to be the one that determines distances the most (bandwidth second?). Higher = longer range AND longer TX time. All the other params will mostly affect transmission time.

@sandeepmistry

This comment has been minimized.

Copy link
Owner

@sandeepmistry sandeepmistry commented Feb 5, 2018

Thanks @morganrallen!

I'm closing as answered for now.

@saedelman

This comment has been minimized.

Copy link

@saedelman saedelman commented Feb 13, 2018

@MauriPastorini - the answers provided are not quite complete. Please download and play with the Semtech "Lora Calculator Tool" that you can download from their website (Windows only). It will clearly show you how the spreading factor (SF), Bandwidth (BW) and coding rate (CR) affect time-on-air (affects power consumption) and receiver sensitivity (affects distance). If you don't care about time on air/power consumption, set the bandwidth to a minimum and SF to maximum. You'll get an incredible link budgets with line of sight communication of 100km or more. Check out Andreas Spiess' Youtube videos on Lora for a test he did over very large distances. The antenna had very little impact.

@saedelman

This comment has been minimized.

Copy link

@saedelman saedelman commented Feb 13, 2018

@MauriPastorini - One additional detail that is often overlooked - the lower the bandwidth, the more stable of a clock you need driving the Semtech chipset. For example, a number of Hope RF modules use a crystal oscillator with 10ppm drift, which means you cannot select bandwidths of less than 41.7 kHz (31.25 kHz may work) or you will not be able to demodulate any packets. Note that operation in high G environments will affect clock drift as well. In general, if you are designing strictly based on link budget (receiver sensitivity), choose the higher bandwidths (more immune to clock drift). For example, SF 10, BW 500 kHz and CR 4/5 yields a receiver sensitivity of -126 dBm with an on-air time of approx. 100ms for a 32-byte packet (6 byte preamble) but SF 9, BW 250 kHz and CR 4/5 also yields a receiver sensitivity of -126dBm with a similar on-air time (around 109ms). The latter allows for a maximum crystal drift of 72ppm whereas the 500kHz bandwidth will allow 144ppm drift. Therefore, for the same link budget, I would choose the wider bandwidth (500kHz) and and corresponding larger spreading factor (10) (less prone to interference than SF 9). Hope this helps.

@morganrallen

This comment has been minimized.

Copy link
Collaborator

@morganrallen morganrallen commented Feb 13, 2018

Thanks for this more detailed response, this would be extremely useful as a footnote in the docs if you feel like writing up a "Quick Guide to Range Considerations".

@saedelman

This comment has been minimized.

Copy link

@saedelman saedelman commented Feb 13, 2018

@morganrallen - one of the best presentations on LoRa that I have come across is from Matt Knight at Bastille Networks - Reversing Lora. Skip to "Introducing LoRa".

A couple more comments on this, you recommended in a previous post to set the C/R to 8 (ref. C/R Denominator: 8), this effectively sends your message twice and doubles your on-air-time (and doubles current-consumption). If it is important to have your message received at the other end within a certain period of time, consider sending data more frequently. E.g. if your receiver needs to see data ever 30 seconds, send data every 15 seconds. This has the benefit of providing more up-to-date data (rather than send two copies of the same data with C/R 8) and you space the packets in time (possibly avoiding temporal interference).

In the event you are using LoRa modulation outside of a gateway configuration (e.g. communication from node to node in a broadcast to all configuration), the longer the on-air-time the more collisions you will encounter (multiple nodes talking at the same time). I personally don't use any C/R above 6 for that reason alone.

There have been comments about whether CRC checks should be turned on. These should always be turned on even when you have an application-level checksum. What is the sense of having the LoRa modem send you a garbage packet? In addition, the cost of sending you the garbage packet is not zero. In many cases, the LoRa modem is connected by UART (or I2C) and at speeds of 57600, the cost of sending you a bad packet can be tens of milliseconds and then you have to instruct the modem to restart the listening process and during this whole process you are missing out on receiving other packets. Turn it on. Always.

@morganrallen

This comment has been minimized.

Copy link
Collaborator

@morganrallen morganrallen commented Feb 13, 2018

I recently learned another reason to leave CRC on. Even if the CRC check fails, the data is still available.

From SX1276 datasheet page 30.

It is important to notice that all the received data will be written to the FIFO data buffer even if the CRC is invalid.
This allows for post-processing of received data for debug purposes for instance.
It is also imporant to note that when receiving, if the packet size exceeds the buffer memory allocated for the Rx it will overwrite the transmit portion of the data buffer

In the case of sending "human consumable data" like a text message, even a corrupt data can be useful.

@saedelman

This comment has been minimized.

Copy link

@saedelman saedelman commented Feb 13, 2018

@morganrallen - Yes, excellent point.

@universam1

This comment has been minimized.

Copy link
Collaborator

@universam1 universam1 commented Feb 14, 2018

@saedelman This is really valuable information! Would like to encourage you to post this findings to the FAQ!

@halukmy

This comment has been minimized.

Copy link

@halukmy halukmy commented Feb 15, 2018

please update readme and faq for better distance settings

@saedelman

This comment has been minimized.

Copy link

@saedelman saedelman commented Feb 15, 2018

The following table is based on midband frequency of 915MHz (North America - you'll get better results when using 868MHz) and sender and receiver isotropic antenna gains of 1 (e.g. a whip antenna without any gain)

Distance - SF/BW
10km - 7/500
20km - 8/500
30km - 9/500
40km - 10/500
60km - 11/500
80km - 12/500
100km - 11/250
125km - 12/250

Although there are other possible combinations of SF/BW possible to achieve the indicated distances, the above table is based on minimizing time-on-air (and therefore minimal power consumption and maximum data rate). The above table is strictly based on free space path loss and therefore distances must be line-of-sight. Note that it is not just a matter of the tips of your send/receive antenna seeing each other without obstructions, there is a so-called Fresnel zone that needs to be entirely clear of obstructions. This zone is shaped like a "blimp" suspended between the tips of the transmit/receive antennas. The maximum diameter of the "blimp" is a function of distance. There are many good tools out there to plot the Fresnel zones between two geographic points - see https://www.loxcel.com/3d-fresnel-zone (not free - no affiliation).

@tarun-kumar-m

This comment has been minimized.

Copy link

@tarun-kumar-m tarun-kumar-m commented Nov 20, 2018

The following table is based on midband frequency of 915MHz (North America - you'll get better results when using 868MHz) and sender and receiver isotropic antenna gains of 1 (e.g. a whip antenna without any gain)
Distance - SF/BW

Please can you provide reference for these calculations as I want to experiment with different SF/BW and different ISM band (868 MHz) to understand possible communication range.

@enriqueromero

This comment has been minimized.

Copy link

@enriqueromero enriqueromero commented Oct 17, 2019

Hi guys,
So I get that CRC should be on. My question is more max transmitting power out of a LoRa module.
In the file LoRa.cpp file the max power is set to:
setTxPower(17); is this really the max?
Also, is anything to be done with following in the Lora.h file:

#define PA_OUTPUT_RFO_PIN 0
#define PA_OUTPUT_PA_BOOST_PIN 1

Note: in my case, I'm only transmitting 32 bytes but I need max range-reliability(who doesn't) :)
Thanks in advance.
ER

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants
You can’t perform that action at this time.