LoRa is a Long-Range radio technology developed by Semtech. Here is a definition from Semtech's LoRa FAQ:
"LoRa (Long Range) is a modulation technique that provides significantly longer range than competing technologies. The modulation is based on spread-spectrum techniques and a variation of chirp spread spectrum (CSS) with integrated forward error correction (FEC). LoRa significantly improves the receiver sensitivity and as with other spread‐spectrum modulation techniques, uses the entire channel bandwidth to broadcast a signal, making it robust to channel noise and insensitive to frequency offsets caused from the use of low cost crystals. LoRa can demodulate signals 19.5dB below the noise floor while most frequency shift keying systems (FSK) need a signal power of 8-10dB above the noise floor to demodulate properly. The LoRa modulation is the physical layer (PHY), which can be utilized with different protocols and in different network architecture – Mesh, Star, point to point, etcetera."
What are the main parameters of LoRa radios?
Throughput and range depend on 3 main LoRa parameters: BW, CR and SF. BW is the physical bandwidth for RF modulation (e.g. 125kHz). Larger signal bandwidth allows for higher effective data rate, thus reducing transmission time at the expense of reduced sensitivity. CR, the coding rate for forward error detection and correction. Such coding incurs a transmission overhead and the lower the coding rate, the higher the coding rate overhead ratio, e.g. with coding_rate=4/(4+CR) the overhead ratio is 1.25 for CR=1 which is the minimum value. Finally SF, the spreading factor, which can be set from 6 to 12. The lower the SF, the higher the data rate transmission but the lower the immunity to interference thus the smaller is the range.
What is the typical range of LoRa radio technology?
Most of tests performed by Semtech and other companies show radio range of about 15-20kms in line-of-sight condition with BW=125kHz and SF=12. The range can be greatly increased if the antennas can be set up higher. Some High Altitude Ballooning experiences have reported range of several hundredths of kms. Under non line-of-sight condition such as in a dense urban area or indoor scenarios, the maximum range is about 2kms.
What is the usual LoRa topology?
With the longer range the usual LoRa topology is a star: end-devices (IoT device) will send data to a gateway which is usually assumed to have Internet connection to be able to push received data to Internet servers. Note that several gateways can be deployed to cover a larger area and it may happen that a message from an end device is received by several gateways. Filtering for duplicated messages can be realized at the Internet server level, or more generally at a layer above the gateway.
What is LoRa/GPS HAT?
The Dragino Lora/GPS HAT is a expansion module for LoRaWan and GPS for use with the Raspberry Pi. This product is intended for those interested in developing LoRaWAN solutions.
The Lora/GPS HAT is based on the SX1276/SX1278 transceiver. The add on L80 GPS (Base on MTK MT3339) is designed for applications that use a GPS connected via the serial ports to the Raspberry Pi such as timing applications or general applications that require GPS information.
The transceivers of the Lora/GPS HAT feature the LoRa™ long range modem that provides ultra-long range spread spectrum communication and high interference immunity whilst minimizing current consumption. The Lora/GPD HAT can achieve a sensitivity of over -148dBm using a low cost crystal and bill of materials. The high sensitivity combined with the integrated +20 dBm power amplifier yields industry leading link budget making it optimal for any application requiring range or robustness. LoRa™ also provides significant advantages in both blocking and selectivity over conventional modulation techniques, solving the traditional design compromise between range, interference immunity and energy consumption.
This board can calculate and predict orbits automatically using the ephemeris data (up to 3 days) stored in internal flash memory, so the HAT can fix position quickly even at indoor signal levels with low power consumption. With AlwaysLocate™ technology, the Lora/GPS HAT can adaptively adjust the on/off time to achieve balance between positioning accuracy and power consumption according to the environmental and motion conditions. The GPS also supports automatic antenna switching function. It can achieve the switching between internal patch antenna and external active antenna. Moreover, it keeps positioning during the switching process.
In this project we will learn, how sensors in different locations, data will be sent to the server/gateway via LoRa technology. In this example, a node (Sensor data collector) and a server/gateway used for save sensor data. The Node sends temperature to server/gateway. We have used both sides (Node and Server) of the Raspberry Pi.
In this example, Lora/GPS HAT to be attached to the Raspberry Pi according to Table 1:
You can also use any other LoRa module. This project has also been tested with Adafruit RFM95W LoRa Radio Transceiver Breakout.
- Connect the Lora/GPS HAT to Raspberry Pi;
- Use
raspi-config
to ensure that SPI can be used on RPi;
- Use
sudo apt-get install wiringpi
to install the GPIO access library written in C for the BCM2835 used in the Raspberry Pi;
- This example tested with Raspberry Pi 1 B, B+, Zero, 2 and 3.
- Used operating system : Raspbian Stretch.
Note: This setting is same for the server/gateway and node.
The tutorial consisted of two parts:
1. Preparation Node or Client
2. Preparation Server or Gateway
Part 1 : Preparation Node or Client1-Wire Digital Temperature Sensor
To measure the temperature, the DS18B20 used. In 1-Wire sensors, all data is sent down one wire, which makes it great for micro controllers such as the Raspberry Pi, as it only requires one GPIO pin for sensing. In addition to this, most 1-Wire sensors will come with a unique serial code (more on this later) which means you can connect multiple units up to one micro controller without them interfering with each other. The DS18B20+ has a similar layout to transistors called the TO-92 package, with three pins: GND, Data (DQ), and 3.3V power line (VDD). You’ll also need some jumper wires, a breadboard and a 4.7kΩ (or 10kΩ) resistor.
Add the following lines to /boot/config.txt
and reboot the Pi:
dtoverlay=w1-gpio,gpiopin=21
Also requires bcm2835 library to be already installed:
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.55.tar.gz
tar zxvf bcm2835-1.55.tar.gz
cd bcm2835-1.55
./configure
make
sudo make check
sudo make install
Get the RadioHead
library from following link:
git clone https://github.com/idreamsi/RadioHead
cd RadioHead/examples/raspi/rf95/
Compile and execute the client:
make
sudo ./rf95_client
If everything is correct, you will see the image below.
6 here is the number of every Node. For easier identification we consider a number for each Node.
Part 2 : Preparation Server or GatewayIn the server side, get the RadioHead
library again. Compile and execute the server:
git clone https://github.com/idreamsi/RadioHead
cd RadioHead/examples/raspi/rf95/
make
sudo ./rf95_server
If everything is correct, you will see the image below.
Our approach is to enable information passing between the gateway program (basically running in a transparent manner) and post-processing operation implemented by end-users in a high-level language such as python. We provide a simple post_processing.py
python script to demonstrate how save sensor data in log file or even send to the cloud server such as thingspeak
and etc. Note how the server or gateway is launched now:
sudo ./rf95_server | python ./post_processing.py -a filename
The log file can be seen here.
Special thanks to Edwin for help about this project.
Resourcehttp://www.semtech.com/wireless-rf/lora/LoRa-FAQs.pdf
http://www.dragino.com/products/module/item/106-lora-gps-hat.html
https://github.com/dragino/Lora/
Comments