Lora Shield

From Wiki for Dragino Project
Jump to: navigation, search

INTRODUCTION

Dragino Lora Shield


What is the Dragino Lora Shield

The Dragino Lora Shield is a long range transceiver on a Arduino shield form factor and based on Open source library.The Lora Shield allows the user to send data and reach extremely long ranges at low data-rates.It provides ultra-long range spread spectrum communication and high interference immunity whilst minimising current consumption.


The Lora Shield based on SX1276/SX1278 targets professional wireless sensor network applications such as irrigation systems, smart metering, smart cities, smartphone detection, building automation, and so on.


Using Semtech’s patented LoRa™ modulation technique the Lora Shield 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.


These devices also support high performance (G)FSK modes for systems including WMBus, IEEE802.15.4g. The Lora Shield deliver exceptional phase noise, selectivity, receiver linearity and IIP3 for significantly lower current consumption than competing devices.


Lora Shield with Leonado




Hardware version info

Hardware Source is in: Lora Shield hardware source.

  • Lora Shield v1.0: The first hardware release for the Lora Shield.
  • Lora Shield v1.2: Connect the DIOs to Arduino IO. Change i-pex connector to SMA connector.
  • Lora Shield v1.3: Remove 5v to 3.3v LDO, use 3.3 directly from Arduino +3.3v pin.
  • Lora Shield v1.4: Add 3 resistors R9/R10/R11. Purpose is to provide possibility to change the Arduino pin connect to Lora CS pin, so Arudino can easier to connect to multi SPI devices. by default, R9 is populated and R10/R11 is not populated. So lora CS is connected to Arduino D10.



Wireless Specifications of RFM95W

  • 168 dB maximum link budget.
  • +20 dBm - 100 mW constant RF output vs.
  • +14 dBm high efficiency PA.
  • Programmable bit rate up to 300 kbps.
  • High sensitivity: down to -148 dBm.
  • Bullet-proof front end: IIP3 = -12.5 dBm.
  • Excellent blocking immunity.
  • Low RX current of 10.3 mA, 200 nA register retention.
  • Fully integrated synthesizer with a resolution of 61 Hz.
  • FSK, GFSK, MSK, GMSK, LoRaTM and OOK modulation.
  • Built-in bit synchronizer for clock recovery.
  • Preamble detection.
  • 127 dB Dynamic Range RSSI.
  • Automatic RF Sense and CAD with ultra-fast AFC.
  • Packet engine up to 256 bytes with CRC.
  • Built-in temperature sensor and low battery indicator.





Features

  • Compatible with 3.3v or 5v I/O Arduino Board.
  • Frequency Band: 915 MHZ/868 MHZ/433 MHZ (Pre-configure in factory)
  • Low power consumption
  • Compatible with Arduino Leonardo, Uno, Mega, DUE
  • External Antenna via I-Pex connector

Power Consumption

Power Consumption



Use Examples

Example1 -- Use with LMIC library for LoraWAN compatible

LMIC library is LoraWAN compatible.

This demo include:

  • How to use Lora Shield to set up single channel gateway for TTN network.
  • How to use Lora Shield to set up a Lora Node.
  • How is the communication between the Lora Node and Lora Gateway.

Use the LMIC with 868MHZ Dragino Lora boards:

The full instruction is in this link: [1]


Use the LMIC with 915MHZ Dragino Lora boards:

The operations similar to "Use the LMIC with 868MHZ Dragino Lora boards".

You need to make following changes here:


1.Copy this code to you IDE and upload the sketch to your Arduino board:

There,you can also add below code to your sketch to check the current emission frequency:

Serial.println(LMIC.freq);


2.Edit "config.h"

change
#define CFG_eu868 1

to

#define CFG_us915 1

3.Edit "lmic.c",about on the line 760,

change
void LMIC_disableChannel (u1_t channel) {
    if( channel < 72+MAX_XCHANNELS )
        LMIC.channelMap[channel/4] &= ~(1<<(channel&0xF));
}

to

void LMIC_disableChannel (u1_t channel) {
    if( channel < 72+MAX_XCHANNELS )
        LMIC.channelMap[channel/16] &= ~(1<<(channel&0xF));
}


4.Edit the "main.cpp" to "Set center frequency" on your Raspberry Pi.

change

uint32_t freq = 868100000; //in Mhz! (868.1)

to

uint32_t freq = 915000000; //in Mhz! (915.0)


The other operations please refer to Use the LMIC with 868MHZ Dragino Lora boards.



Example2 -- Use the RadioHead Library With Arduino Boards

The RadioHead Library simplifies communication between the Arduino Board and the Lora Shield.We can find it here: http://www.airspayce.com/mikem/arduino/RadioHead/ To use it in your project you just have to copy it in your Arduino project folder (next to your main Arduino project file .ino).

Compile Notice:

  • After putting the lIbrary in the right place, you have to also modify the frequency to the frequency you want to use, the position of this is setFrequency() in the file: arduino-xxx\libraries\RadioHead\RH_RF95.cpp;
  • The RF95-server sketch use the led=9 to show the status. please change it to other LED , such 8. because 9 is connected to the lora module's RESET pin. you will see 'init fail' in the default server sketch

Then ,we can easily to use it to do some experimentation.

RadioHead Examples



In this example,we use two Lora Shields to transmit and receive signal,there are some project in the RadioHead Library,the operation is as follows:

  • Connect two Lora Shields with Arduino board and connect them to computer via the USB cable;

We used the Lora Shield+Arduino UNO as the server to transmit signal and the Lora Shield+Aduino MEGA2560 as the client to receive signal here.


Lora Shields and Arduino boards

Connect the Lora Shield and Arduino,and connect them to computer.


Connection


  • Open the IDE and choose the right example;


Choose the example


  • Configure the IDE settings and upload the two skteches to Aduino.


Configure the IDE settings of MEGA


Configure the IDE settings of UNO

After configure the IDE settings,upload the skteche to Aduino.Check the Serial Moniter and we can view the running result of the two boards.


Running result of MEGA


Running result of UNO



Example3 -- How to get sensor data from a remote Arduino via Wireless Lora Protocol

LoRa Temperature Project


This is an example to show how to get sensor data from a remote Arduino via Wireless Lora Protocol. The exampels requries below hardwares:


1) Client Side: Arduino + Lora Shield (868Mhz) + DS18B20 (Temperature Sensor).

2) Server Side: Arduino + Lora Shield (868Mhz) + Yun Shield + USB flash.


make sure the USB flash has this file datalog.csv in the data directory of root.

Requrie below software: Radiohead library from: http://www.airspayce.com/mikem/arduino/RadioHead/...

Client side will get the temperature and keep sending out to the server via Lora wireless. Server side will listin on the Lora wireless frequency, once it get the data from Client side, it will turn on the LED and log the sensor data to a USB flash.

The full instruction is in this link: http://www.instructables.com/id/How-to-Get-Sensor-Data-From-a-Remote-Arduino-Via-W/


Example4 -- LMIC-RAW-915

This example is for the Lora Shield 915 users.We use the library "arduino-lmic" in this project.Over here,we use the things below to complete this project.

  • Dragino Lora Shield(915) x 2
  • Arduino board x 2
  • Antenna (915MHZ) x 2
  • USB cable
  • Power supply

Connected the hardware,edit the "config.h" of LMIC library,change the "#define CFG_eu868 1" to "#define CFG_us915 1".This example requires DISABLE_INVERT_IQ_ON_RX to be set.Uncomment "#define DISABLE_INVERT_IQ_ON_RX" (line 59 of config.h),save settings.

LMIC config 1
LMIC config 2

Open the IDE(1.6.8 here),choose the correct board and correct port,then upload the sktech "lmic-raw-915" to the two arduino boards.

LMIC_RAW_915

Open the Serial Monitor and you can see the running result as below:

Running result of raw-915




Example5 -- Set up as a Lora Gateway using the LowCostLoRaGw library

The LowCostLoraGw source code provides good examples to shows how to use RPi to set data to the IoT provider and Dropbox. The Lora Shield and Lora and Lora/GPS Hat can work with these examples, by doing some modifications as below:


When use Lora Shield with Arduino, what need to modify is:

In the sketch: 
// uncomment if your radio is an HopeRF RFM92W or RFM95W
#define RADIO_RFM92_95 
In the code: SX1272.h
change #define SX1272_RST  3 to #define SX1272_RST  9
change #define SX1272_SS 2 to #define SX1272_SS 10

When use Lora/GPS HAT with RPi 2/3, what need to modify is:

Solder the pin22 and pin24. for CS pin use in this library. 
otherwise you will see below error: 
pi@raspberrypi:~/lora_gateway$ sudo ./lora_gateway
Unrecognized transceiver.
...
Use Lora /GPS HAT with LowCostLoraGw source code




Example6 -- Upstream/Downstream to ThingSpeak IoT Server

Examples for ThingSpeak are in the LG01 user manual. Please click here for details.

ThingSpeak SetUp
ThingSpeak Test Result

The Examples Include:

  • How to upload get data from remote LoRa wireless node and upload it to ThingSpeak
  • How to get commands in ThingSpeak and control a remote LoRa wireless node's relay



Usage Notice

You have to be aware that Radio link quality and performances are highly dependent of environment.

Better performances can be reached with:

  • Outdoor environment.
  • No obstacles.
  • No high level radio interferer in the ISM 868MHz band.
  • At least 1 meter above the ground.



Radio performances are degraded with:

  • Obstacles: buildings, trees...
  • Inner buildings environments.
  • High ISM 868MHz band usage by other technologies.

Radio communication are usually killed with bad topographic conditions. It is usually not possible to communicate through a hill, even very small.



Order Infomation

  • Lora Shield 868: Load with RFM95W-868S2, support 868M frenquency
  • Lora Shield 915: Load with RFM95W-915S2, support 915M frenquency
  • Lora Shield 433: Load with RFM98W-433S2, support 433M frenquency



Schematic

Lora Shield Schematic



Frequent Ask Questions (FAQs)

I have order Lora Shield v95-868, while the chip on lora shield shows RF96?

The Lora Shield v95-868 is equied with HopeRF RFM95W-868-S2. This module has a mark RF96 on it. it doesn't mean the chip is RFM96w, but it means the chip is using the SX1276 chip.

Mean While, The Lora Shield v95-915 S2 with mark RF96 on the IC. The Lora Shield v98-433 S2 with mark RF98 on the IC and use the sx1278 chip.


===I want to use the Lora Shield to connect to the Things Network by OTAA,how can I get the DevEUI? In the Arduino sketch with OTAA you need to setup APPEUI and DEVUI with LSB (less significant bit first), but APPKEY with MSB (more significant bit first). In the example skecth for OTAA the comments says that it doesn't matter if APPKEY if LSB or MSB, but it does, you must set it up with MSB!

And regarding DevEUI, I found that it depends on the Lora transmitter: t RFM95W cannot give a unique DEVEUI so it's ok to use a random one.

Reference