As I wanted to start experimenting with LoRa at lowest possible costs I bought a set of LoRa Bee modules from Dragino. At US$36 ( including shipping) for a set of two, it was the cheapest option at the time (Second half of 2016). That they also came with a neat antenna was definitely a plus.
But when it became time to actually connect them and send some data,I found this a little bit harder than expected.
First the 'Bee' form factor itself. Its got a 2 mm pitch header that will not fit a standard breadboard. And the pins are too small for standard female to male jumper wires.
Second it is 3.3V only. So I bought an Arduino Mini Pro, 8MHz - 3.3V version, and made some jumper wires from an IC socket and a standard header.
It's connected as follows: NSS-10, MOSI-11, MISO-12, SCK-13.
The WAZIUP LoRa Project
Next we need some software to drive it. And here it gets a bit harder. There are so many options, many extensively documented but usually in an experimental state. I found the article by Congduc Pham, 'A DIY low-cost LoRa gateway' to come closest to what I wanted to achieve. And it actually contains a lot of information on connections, theory and applications. Professor Pham developed a simple protocol for just transferring data from multiple end-points to central server, without the overhead of the full LoRaWAN stack. All this as part of a 'WAZIUP' project that aims to bring this type of networking to sub-Saharan African countries.
By just following the instructions in the .pdf it's easy to install the program to the Arduino and get the software on the Raspberry pi.
A few pitfalls that I found while getting this all to work:
- The instructions tell you to clone the GIT repository . But GIT is not installed by default on Raspbian. Use the following commands to get it :
$ sudo apt-get update
$ sudo apt-get install git-core
- Compiling the Lora Gateway software for Raspberry Pi B+. Since it is a B+, I compiled it for the the Raspberry Pi 2 , but later I found that my board is the original Raspberry Pi B+, which actually is a Raspberry 1. So if nothing happens after you start the lora_gateway, check your version.
- Minimal time between messages. I started with the 'Arduino_LoRa_temp' program, but I changed the time between messages on the Arduino to 1 minute ( idlePeriodInMin = 1; ). After a while I noticed that the gateway did not receive every message, but actually only one in two. It looks like the software limits the amount of transmitted bytes per hour. After increasing the interval to 2 minutes it worked fine. When using the 'Arduino_LoRa_InteractiveDevice' program I noticed that this has no limitations, and you can send multiple messages with short intervals. Officially there is a limit on the available radio time (Time On Air or ToA) of 1%, meaning you should not have actual transmissions for more than a total of 3.6 seconds per hour. This is explained in section 29 of the FAQ.
- The driver software is called SX1272.cpp, but I have a RF95 . The SX1272 is identical to the RF-95 as used on the Lora Bee.
- When the messages are received on the gateway, but the message itself is unreadable they ar probably AES encrypted, and the gateway does not decode this. For testing it's easier to disable AES. Just comment out the define:
//#define WITH_AES
- CAD = Channel Activity Detection.
- SIFS = Short InterFrame Space
What it looks like on the RPi when it's running:
(And a minor issue, actually only related to the Rasperry Pi: SSH is now disabled on Raspbian. I could not connect through SSH to my Raspberry Pi running Raspbian Lite. An article on the RPi site explains that on newer version SSH is disabled by default. It also has the solution: just add a file 'ssh' to the root folder of the SD card. Make sure you change the password..)
What's really cool about the code is that mr. Pham made clever use of the ArduPi library so the code for the Raspberry Pi and the Arduino is (almost) identical.
LoraWan
When you want to go for a solution that is compatible with the LoraWan network, I suppose nothing beats the simplicity of the LoPy, an integrated module with Lora, WiFi and bluetooth, programmed in Pyton. There is a nice introduction on Element14.Using LoraWan and the associated 'The Things Network' requires a nearby gateway. Which, if none is available, you can build yourself. At a total cost of about €200,- this is definitely not a bad deal. But if that's a little too much for just some simple experiments you can also build a super cheap single channel gateway.